Overview
Text generation endpoints support Server-Sent Events (SSE) streaming. Setstream: true to receive output token by token as it’s generated.
Streaming-Enabled Endpoints
/v1/chat/completions— OpenAI compatible/v1/messages— Claude Messages/v1/responses— OpenAI Responses API
Example
SSE Data Format
Each chunk is a singledata: {json} SSE event:
data: [DONE].
Final Frame Usage & Billing (cost)
The last data frame before[DONE] carries the usage and the charge of the call:
usage.costis the actual quota charged for this call (integer); use it for per-call reconciliation- It is sent by default; explicitly passing
stream_options: {"include_usage": false}disables it - With the OpenAI SDK, the final chunk’s
chunk.usagecontains this data