Inference API
Stream responses
Receive model output incrementally through the OpenAI Server-Sent Events format.
Enable streaming
Set stream to true. OpenAI-compatible SDKs expose the result as an iterator and handle the final sentinel automatically.
stream.py
1stream = client.chat.completions.create(
2 model="your-serving-name",
3 messages=[{"role": "user", "content": "Hello"}],
4 stream=True,
5)
6
7for chunk in stream:
8 if chunk.choices and chunk.choices[0].delta.content:
9 print(chunk.choices[0].delta.content, end="", flush=True)Tools and protection
LLM Firewall runs before the stream starts. Supported tool calls are executed or forwarded using the same rules as a non-streaming request.
API example
Receive stream events incrementally; replace my-model with a compatible model.
Set QDIV0_API_KEY to an account tk_ key or personal uk_ key. A personal key uses its default account unless you select another with X-Account-ID.
api-example.sh
1curl --fail-with-body \
2 --no-buffer \
3 --request POST \
4 "https://api.qdiv0.com/v1/chat/completions" \
5 -H "Authorization: Bearer $QDIV0_API_KEY" \
6 -H "Content-Type: application/json" \
7 --data '{"model":"my-model","messages":[{"role":"user","content":"Hello"}],"stream":true}'