Skip to main content
Set stream: true on a chat completions request to receive the response as server-sent events.

Event format

  • The response has the content type text/event-stream.
  • Each event’s data is a JSON object with object: "chat.completion.chunk". The new text is in choices[].delta.content.
  • Reasoning arrives in delta.reasoning and delta.reasoning_details. Tool call arguments arrive in delta.tool_calls.
  • The stream ends with the line data: [DONE].

Usage on the final chunk

boolean
true adds a final chunk with usage, sent before data: [DONE]. Without it, the stream has no usage data. Billing is the same either way.

Read a stream

Timeouts

  • A stream can be silent for up to 4 minutes, for example while the model reads a long prompt. Set the client read timeout above 4 minutes. A shorter timeout can close a stream that is still working.
  • If nothing arrives for 4 minutes, the stream ends with an upstream_timeout error event.
  • A request can run for up to 60 minutes — see Tiers and limits. A stream that reaches the limit also ends with upstream_timeout.

Errors during a stream

If the request fails before the first event, the response is an ordinary error with an HTTP status and a JSON body — see Errors. If it fails after the stream started, the last event is an error, and the stream closes. A timeout has the code upstream_timeout and the message “The request exceeded its time limit.”; any other failure has upstream_error:
A stream that ends without data: [DONE] and without an error event lost its connection. A stopped stream cannot be resumed; a new request is charged separately — see What is billed. The x-request-id response header identifies the request for support.
Last modified on October 5, 2026