Send your first chat completions request
Send a streaming request to the chat completions API route:modelis mandatory and must indicate a model supported by your chosensourcemessagescontains the messages exchanged between the conversational search agent and the usertoolssets up two optional but highly recommended tools:_meiliSearchProgress: shows users what searches are being performed_meiliSearchSources: displays the actual documents used to generate responses
Maintain conversation context
The chat completions endpoint is stateless. To maintain conversation history across multiple exchanges, you need to accumulate messages and send them with each request.Troubleshooting
Empty reply from server (curl error 52)
Causes:- Experimental features not enabled
- Missing authentication in requests
- Enable experimental features (see setup guide)
- Include Authorization header in all requests
”Invalid API key” error
Cause: Using the wrong type of API key Solution:- Use the “Default Chat API Key”
- Don’t use search or admin API keys for chat endpoints
- Find your chat key with the list keys endpoint
”Socket connection closed unexpectedly”
Cause: Usually means the OpenAI API key is missing or invalid in workspace settings Solution:-
Check workspace configuration:
-
Update with valid API key:
Chat not searching the database
Cause: Missing Meilisearch tools in the request Solution:- Include
_meiliSearchProgressand_meiliSearchSourcestools in your request - Ensure indexes have proper chat descriptions configured
Next steps
One-shot summarization
Generate single AI answers without conversation history.
Stream chat responses
Handle streaming responses for a real-time experience.
Display source documents
Show users which documents were used to generate responses.
Configure guardrails
Restrict AI responses to topics covered by your data.