API
Streaming
Set "stream": true to receive output as Server-Sent Events (SSE) while the model generates it.
Chat Completions stream
curl -N https://api.llm-hub.dev/v1/chat/completions \
-H "Authorization: Bearer $LLMHUB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.6-sol",
"stream": true,
"stream_options": {"include_usage": true},
"messages": [{"role": "user", "content": "Write a haiku"}]
}'Each event is a data: line with a chat.completion.chunk. The text is in choices[0].delta.content. The stream ends with data: [DONE].
Token usage is sent in a final chunk with empty choices only when you set stream_options.include_usage to true.
With the OpenAI SDK
stream = client.chat.completions.create(
model="gpt-5.6-sol",
messages=[{"role": "user", "content": "Write a haiku"}],
stream=True,
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")Responses streams use typed events (see Responses); Anthropic Messages streams use the Anthropic event format.
Last updated
