Skip to main content
Set "stream": true to receive the response incrementally as Server-Sent Events (SSE). Pass -N (or --no-buffer) to curl so it prints chunks as they arrive.

Chat Completions

Each event is a line data: <json> carrying a chat.completion.chunk:
Stream (abridged)
  • First chunkdelta.role: "assistant", finish_reason: null
  • Content chunksdelta.content holds the next token(s)
  • Final chunk → empty delta, finish_reason set (stop, length, …)
  • Usage chunk → only when stream_options.include_usage is true; it has an empty choices array and a usage object
  • Terminatordata: [DONE]
To reassemble the text, concatenate every choices[0].delta.content. Because the gateway emits the exact OpenAI shape, client.chat.completions.create(..., stream=True) in any OpenAI SDK works unchanged.

Responses API

The Responses API streams semantic events instead of generic chunks. Each event has both an event: line and a data: line, and a monotonically increasing sequence_number.
Events arrive in this order: Aggregate the delta fields from response.output_text.delta events to build the text; read final token usage from response.completed.

Messages (Anthropic)

POST /v1/messages streams Anthropic’s semantic events, so the official anthropic SDK’s client.messages.stream(...) works unchanged. Like the Responses API, each event has an event: line and a data: line. (A bare claude-... model id routes to Anthropic; any provider/model id also works here — see SDKs & integrations.)
Events arrive in this order: Concatenate delta.text from content_block_delta events to build the output; read the final token usage (and stop_reason) from message_delta. Note the usage on message_start is zeroed — real token counts are only known at the end.