Skip to main content
Set stream: true to receive the answer as it is written, as server-sent events in OpenAI’s format. Without it, one JSON response arrives when generation finishes. Both modes have the same output allowance. Stream when answers are long or when people watch them appear. A JSON response can take minutes for a long answer, so set your HTTP client timeout above the gateway’s -second model deadline, or stream.

Chat Completions

Each event is a chat.completion.chunk. The plan arrives first, as delta.reasoning_content, then the answer as delta.content. Tool calls stream as delta.tool_calls. The stream ends with data: [DONE]. The last chunk carries usage only when you send stream_options: { include_usage: true }. That chunk has an empty choices array.

Responses API

Events follow OpenAI’s Responses format: response.created and response.in_progress, then response.output_item.added, response.content_part.added and response.output_text.delta for the answer, and response.function_call_arguments.delta and .done for function calls. The last event is response.completed, or response.incomplete when the output limit ended the answer. The Responses API doesn’t stream the plan.

Cancelling

Close the connection to stop generation. You pay for the tokens already sent, and the request shows up in Logs with status 499 client_closed. The API never returns that status to you.

Errors during a stream

Errors before the stream starts come back as a JSON error with an HTTP status. If the model stream breaks off after that, the connection ends with an error, without data: [DONE] (Responses: without response.completed), and the request appears in Logs with upstream_error or upstream_timeout. Retry it. See Errors.
Last modified on December 5, 2026