Skip to main content
Streaming delivers chat responses incrementally, giving users immediate feedback instead of waiting for the full response to generate. Meilisearch uses Server-Sent Events (SSE) to stream responses from the chat completions endpoint.
In code examples, replace WORKSPACE_NAME with the name of your workspace. On Meilisearch Cloud, the default workspace name is cloud.

Send a streaming request

Send a POST request to the chat completions endpoint with "stream": true. Non-streaming is not yet supported and returns a 501 Not Implemented error.
The -N flag in the cURL example disables output buffering, so you see each chunk as it arrives.

Understand the SSE response format

Meilisearch streams responses as Server-Sent Events (SSE) over a persistent HTTP connection. The wire format is deliberately OpenAI-compatible so you can point the official OpenAI SDKs, the Vercel AI SDK, or any other SSE-aware client at the endpoint without custom parsing. Concretely, each event on the wire follows three rules:
  • Every event is a line that begins with the literal prefix data: .
  • The payload after data: is a single JSON object shaped like an OpenAI chat.completion.chunk (same id, object, choices[].delta structure as /v1/chat/completions).
  • The stream terminates with the sentinel line data: [DONE]. The [DONE] marker is a literal string, not JSON, so parsers must check for it before calling JSON.parse.
Events are separated by blank lines. After consuming [DONE], close the reader and treat the connection as complete.

Content chunks

Regular content chunks contain the AI-generated text. Each chunk includes a small piece of the response in choices[0].delta.content:

Tool call chunks

When you include Meilisearch tools in your request, the stream also contains tool call chunks. These appear in choices[0].delta.tool_calls and carry search progress and source information:

End of stream

The stream ends with a finish_reason of "stop" followed by the [DONE] marker:

Handle streaming in JavaScript

Use the Fetch API to process the SSE stream in a browser or Node.js application:

Maintain conversation context

The chat completions endpoint is stateless. To maintain conversation history across multiple exchanges, accumulate messages and send the full history with each request.
For a complete example combining all tools with progress, sources, and history, see the chat interface guide.

Next steps