Guide
Streaming with SSE
Receive deltas as they are generated and reduce perceived latency.
Enable stream
cURL
curl https://code.verboo.ai/router/v1/chat/completions \
-H "Authorization: Bearer $VERBOO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "<MODEL_ID>",
"messages": [{"role": "user", "content": "Explain why low latency matters for developer tools."}],
"stream": true
}'Stream protocol
SSE events
data: {"choices":[{"delta":{"content":"Olá"}}]}
data: {"choices":[{"delta":{},"finish_reason":"stop"}]}
data: {"choices":[],"usage":{"prompt_tokens":12,"completion_tokens":8,"total_tokens":20}}
data: [DONE]- Each event starts with data: and ends with a blank line.
- Append choices[0].delta.content when present.
- The final event may include usage before [DONE].
Cancellation and failures
Avoid duplicate responses
If the connection drops after content arrives, a retry creates a new generation. Decide whether your app discards, keeps the partial output, or asks for a continuation.
Propagate client cancellation, configure a connection timeout, and use a longer timeout for the complete stream.