Streaming
Use streaming when you want to show model output as it is generated instead of waiting for the full response. OpenModels supports OpenAI-compatible streaming through POST /chat/completions with stream: true.
Base URL:
Endpoint:
Request
Set stream to true in the request body:
cURL
Use -N so cURL does not buffer the response:
The response is sent as server-sent events:
Read each data: event, append choices[0].delta.content when present, and stop when you receive [DONE].
Python
Node.js
Handling streamed output
- Append text deltas in order.
- Treat missing
delta.contentas normal. Some chunks only carry metadata. - Keep a local buffer if you need to save the final answer.
- If the connection drops after text has started streaming, decide whether retrying could duplicate user-visible output.
- Log your client request id, model ID, endpoint, and any
error.request_idreturned by the gateway.
Billing
Streaming changes how output is delivered, not how usage is billed. Credits are consumed based on actual input and output token usage.