Streaming — OneHub
Set "stream": true to receive token-by-token chunks.
Docs
Docs Quick Start Authentication SDK Setup Available Models Rate Limits Chat Completions Streaming List Models Embeddings Image Generation Text to Speech Speech to Text Billing & Wallet Webhooks ErrorsStreaming
With streaming enabled, responses arrive as SSE chunks in the OpenAI chat.completion.chunk format.
The stream terminates with a final data: [DONE] line.
Chunk format
data: {"id":"chatcmpl-xxx","object":"chat.completion.chunk","created":1722500000,"model":"openai/gpt-5-nano","choices":[{"index":0,"delta":{"content":"Hello"},"finish_reason":null}]}
data: {"id":"chatcmpl-xxx","object":"chat.completion.chunk","created":1722500000,"model":"openai/gpt-5-nano","choices":[{"index":0,"delta":{"content":" world"},"finish_reason":null}]}
data: {"id":"chatcmpl-xxx","object":"chat.completion.chunk","created":1722500000,"model":"openai/gpt-5-nano","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: [DONE]
curl
curl -N https://www.onehub.design/v1/chat/completions \
-H "Authorization: Bearer sk-onehub-xxx" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-5-nano",
"messages": [{ "role": "user", "content": "Count from 1 to 3." }],
"stream": true
}'
Node.js
import OpenAI from "openai";
const openai = new OpenAI({
baseURL: "https://www.onehub.design/v1",
apiKey: "sk-onehub-xxx",
});
const stream = await openai.chat.completions.create({
model: "openai/gpt-5-nano",
messages: [{ role: "user", content: "Count from 1 to 3." }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || "");
}
Notes
- Chunks reference the same
id,created, andmodelacross the whole stream. - Usage is not included in the final chunk for streams. Check your dashboard's usage log for exact totals.