The language model of the Opensolr API servers, in the request and answer format of the OpenAI chat completions API: messages, tools the model may call, JSON output, streaming.
https://api.opensolr.com/solr_manager/api/chat_completionsContent-Type: application/json)email and api_key in the JSON body: Authentication01 · Body
index_nameRequiredYour index. Its owner's AI allowance is used.
messagesRequiredUp to 200 messages, roles system, user, assistant, tool, text only. At least one user message.
toolsOptionalUp to 128 function tools, as in the OpenAI format.
tool_choiceOptionalauto (default with tools), none, required, or one function by name.
max_tokensOptionalLongest answer, up to 8192. Default 1024. max_completion_tokens works too.
temperatureOptionalUp to 2. Anything below 0.7 is raised to 0.7.
top_p, stop, seedOptionaltop_p 0.05 to 1, stop 1 to 4 strings, seed a number.
response_formatOptionaltext, json_object, or json_schema with your schema.
streamOptionaltrue: the answer comes as Server-Sent Events, chunk by chunk, in the OpenAI format.
02 · Example
curl -s -X POST "https://api.opensolr.com/solr_manager/api/chat_completions" \ -H "Content-Type: application/json" \ -d '{"email": "YOUR_EMAIL", "api_key": "YOUR_API_KEY", "index_name": "my_index", "messages": [{"role": "user", "content": "What is the weather in Paris?"}], "tools": [{"type": "function", "function": {"name": "get_weather", "description": "Weather in a city", "parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}}}]}'
03 · Answer
{ "status": true, "id": "chatcmpl-...", "object": "chat.completion", "created": 1791720310, "model": "...", "choices": [ { "index": 0, "message": { "role": "assistant", "content": null, "tool_calls": [ { "id": "call_1", "type": "function", "function": { "name": "get_weather", "arguments": "{\"city\": \"Paris\"}" } } ] }, "finish_reason": "tool_calls" } ], "usage": { "prompt_tokens": 180, "completion_tokens": 22, "total_tokens": 202 } }
Run the tool yourself, add its answer as a tool message with the same tool_call_id, and call again. The model and its window: vdb_info gives them in llm. Values shown are an example.
Each answer counts one AI request. 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
ERROR_JSON_BODY_REQUIREDHTTP 200The body is not JSON.
ERROR_MESSAGES_REQUIRED, ERROR_USER_MESSAGE_REQUIREDHTTP 200No messages, or no user message.
ERROR_INVALID_MESSAGE_ROLE, ERROR_TEXT_MESSAGES_ONLY, ERROR_INVALID_TOOL_CALLSHTTP 200A message the format does not allow.
ERROR_INVALID_TOOLS, ERROR_INVALID_TOOL_CHOICE, ERROR_INVALID_RESPONSE_FORMAT, ERROR_INVALID_STOPHTTP 200A field that does not follow the format.
ERROR_CHAT_TOO_LONGHTTP 200The conversation does not fit the window of the model.
ERROR_CHAT_REQUEST_REFUSEDHTTP 200The model refused the request; detail says why.
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_UNAVAILABLE, AI_GENERATION_FAILEDHTTP 200The model did not answer. Retry.
WRONG_API_HOSTHTTP 404Called on opensolr.com.
ERROR_AUTHENTICATION_FAILEDHTTP 403The email and API key do not match.
05 · Related
The whole chat bot of your site in one call, searches and lookups included: assistant_chat.
Every error code and HTTP status of the API: API errors. Calls per minute and per hour: Rate limits.