Streaming
Instead of waiting for a long response all at once, you can receive it piece by piece (word by word). This gives the "typing" effect in chat UIs and improves perceived speed.
How to enable it
Add "stream": true to the request body:
bash
curl https://app.qevron.ai/v1/chat/completions \
-H "Authorization: Bearer $QEVRON_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "verinova",
"stream": true,
"messages": [{ "role": "user", "content": "Explain RAG in three bullet points." }]
}'python
stream = client.chat.completions.create(
model="verinova",
messages=[{"role": "user", "content": "Explain RAG in three bullet points."}],
stream=True,
)
for chunk in stream:
delta = chunk.choices[0].delta.content or ""
print(delta, end="", flush=True)javascript
const stream = await client.chat.completions.create({
model: "verinova",
messages: [{ role: "user", content: "Explain RAG in three bullet points." }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0].delta.content ?? "");
}Response format (SSE)
Streaming returns Server-Sent Events (SSE). With the Content-Type: text/event-stream header, each chunk arrives as a data: line:
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"role":"assistant"}}]}
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"RAG"}}]}
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":", "}}]}
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: [DONE]- Text in each chunk is in
choices[0].delta.content. - The final chunk has
finish_reasonset. - The stream ends with
data: [DONE].
Getting token usage in a stream
By default usage is not sent at the end of a stream. To include it:
json
{
"model": "verinova",
"stream": true,
"stream_options": { "include_usage": true },
"messages": [ ... ]
}In that case a chunk containing only usage is sent just before the end.
Which endpoints support streaming?
- Chat completions —
stream: true - Audio: TTS — audio chunks as SSE via
stream_format - Audio: STT — transcription piece by piece
- Responses API
Use an SDK
Rather than parsing SSE by hand, use the official openai SDK; it resolves the chunks for you.