The out-of-the-box chat bot of your site, in one call: you send the conversation, Opensolr searches your index, looks up the facts it needs, and streams back the answer with the links of its sources.
https://api.opensolr.com/solr_manager/api/assistant_chatContent-Type: application/json)email and api_key in the JSON body: Authentication01 · Body
index_nameRequiredThe index of your site. Its owner's AI allowance is used.
messagesRequiredThe conversation: up to 21 messages, roles user and assistant, text only, the last one from the user. The last question is at most 4000 characters.
instructionsOptionalYour own instructions to the chat bot, up to 4000 characters.
timezoneOptionalYour time zone, such as Europe/Paris, so that today and dates are right. Default UTC.
visitor_ipOptionalThe public address of your visitor. One visitor gets at most 100 questions an hour on one index. It also answers questions about where the visitor is.
02 · Example
curl -sN -X POST "https://api.opensolr.com/solr_manager/api/assistant_chat" \ -H "Content-Type: application/json" \ -d '{"email": "YOUR_EMAIL", "api_key": "YOUR_API_KEY", "index_name": "my_index", "timezone": "Europe/Paris", "messages": [{"role": "user", "content": "Do you have a blue chair under 200 euros?"}]}'
03 · Answer
A stream of Server-Sent Events, one JSON per data: line:
data: {"type":"status","stage":"reading"}
data: {"type":"tool","name":"opensolr_site_search","args":{"query":"blue chair"}}
data: {"type":"text","text":"Yes: the [Blue chair](https://www.example.com/products/blue-chair) costs..."}
data: {"type":"done"}
statusWhat the chat bot is doing.
toolA search or a lookup it runs, with its arguments.
textA piece of the answer, as it is written, in Markdown with links.
doneThe answer is complete.
errorIt stopped: msg says why, for example ERROR_NO_ANSWER or ERROR_ASSISTANT_TIMEOUT after 60 seconds.
It searches your index by meaning, by exact words and by date, reads documents and pictures of your site, and looks up places, times, rates, VAT, distances, postal codes and IP locations: What the chat bot can look up. When the answer links none of its sources, their links are added at the end.
Each pass of the model that produces output counts one AI request, and the searches by meaning it runs count like vdb_search. Every plan includes a monthly allowance of AI requests: API Quota, Pricing. The allowance used is the one of the account that owns the index.
04 · Errors before the stream
ERROR_JSON_BODY_REQUIREDHTTP 200The body is not JSON.
ERROR_MESSAGES_REQUIRED, ERROR_USER_MESSAGE_REQUIRED, ERROR_MAX_21_MESSAGESHTTP 200No conversation, the last message is not the user's, or too many messages.
ERROR_MESSAGE_TOO_LONGHTTP 200The last question is longer than 4000 characters.
ERROR_VISITOR_QUESTIONS_LIMITHTTP 200This visitor asked 100 questions on this index in the last hour.
VECTOR_NOT_ALLOWED, ERROR_AI_MONTHLY_QUOTA_EXCEEDEDHTTP 200AI is off on the plan of the index owner, or the allowance is used up.
ERROR_LLM_UNAVAILABLEHTTP 200The model did not answer. Retry.
ERROR_NOT_CORE_OWNERHTTP 200The index is not yours.
WRONG_API_HOSTHTTP 404Called on opensolr.com.
ERROR_AUTHENTICATION_FAILEDHTTP 403The email and API key do not match.
05 · Related
The same chat bot without code, on your site: Three ways to add the chat bot. The model alone, with your own tools: chat_completions.
Every error code and HTTP status of the API: API errors. Calls per minute and per hour: Rate limits.