Models and voice
Streaming
Server-Sent Events in the OpenAI format: data lines, a usage chunk and [DONE].
How it works
- Set "stream": true. The response is text/event-stream.
- Each event is a line starting with data: and an OpenAI chat.completion.chunk.
- The stream ends with data: [DONE].
- When the provider reports usage, a final chunk carries it; billing uses it.
- If the client disconnects, the call is billed for what was used so far.
curl -N https://setu.supremeai.services/api/setu/v1/chat/completions \
-H "Authorization: Bearer $SETU_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "quantum-lite",
"stream": true,
"messages": [{ "role": "user", "content": "Write a haiku about Kathmandu." }]
}'import os
from openai import OpenAI
client = OpenAI(base_url="https://setu.supremeai.services/api/setu/v1", api_key=os.environ["SETU_API_KEY"])
stream = client.chat.completions.create(
model="quantum-lite",
messages=[{"role": "user", "content": "Write a haiku about Kathmandu."}],
stream=True,
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)WebSockets
Not offered. Use Server-Sent Events.