Alternative to Socket.IO streaming - uses standard HTTP Server-Sent Events (SSE). Ideal for server-side integrations, SDKs, and environments where WebSockets aren’t available.
Returns text/event-stream; charset=utf-8 with SSE-formatted JSON chunks.
Each line is prefixed with data: followed by a JSON object and two newlines.
data: {"type":"connected","message":"Stream connected"}
data: {"type":"stream","prompt":"The capital","delta":"The capital"}
data: {"type":"stream","prompt":"The capital of France is Paris.","delta":" of France is Paris."}
data: {"type":"tool_call","call_id":"tooluse_abc123","name":"search_uploads","arguments":null,"displayInfo":{"icon":"search","label":"Searching documents"}}
data: {"type":"tool_result","call_id":"tooluse_abc123","name":"search_uploads","arguments":{"query":"France capital"},"response":"...","responseLength":512,"responseDurationMs":150,"success":true}
data: {"type":"complete","success":true,"usage":1234,"outputs":["The capital of France is Paris."],"model":"us.anthropic.claude-sonnet-4-5-20250929-v1:0","cached":0,"completion":42}
data: {"type":"done"}
| Type | Description | Key Fields |
|---|---|---|
connected | Stream established | message |
stream | Text chunk from AI | prompt (cumulative), delta (incremental) |
tool_call | Tool invocation started | call_id, name, arguments, displayInfo |
tool_result | Tool execution completed | call_id, name, response, success, responseDurationMs |
complete | Final response with metrics | success, usage, outputs, model, cached, completion |
error | Processing error | error.message, error.status |
done | Stream ended | (none) |
Content-Type: text/event-stream; charset=utf-8
Cache-Control: no-cache, no-transform
Connection: keep-alive
Content-Encoding: none
Transfer-Encoding: chunked
X-Accel-Buffering: no
Close the HTTP connection to cancel the request. The server will detect the disconnect and abort any in-progress AI generation.
JWT token passed in x-access-token header
SSE stream of AI response chunks
Server-Sent Event payload structure for HTTP streaming.
Each event is a JSON object sent as data: {json}\n\n.
The type field determines which other fields are present.
Event type indicator:
connected: Stream established successfullystream: AI-generated text chunk (cumulative + delta)tool_call: Tool/function invocation started (RAG, web search, etc.)tool_result: Tool/function execution completed with resultscomplete: Final response with usage metrics and full outputerror: Error occurred during processingdone: Stream terminated — no more events will followconnected, stream, tool_call, tool_result, complete, error, done