Streaming events
The event sequence each endpoint sends when stream is true.
Streams are server-sent events with content-type: text/. Events are relayed as they arrive.
Sequences
data: {"id":"gen-...","choices":[{"index":0,"delta":{"role":"assistant","content":""}}]}
data: {"id":"gen-...","choices":[{"index":0,"delta":{"content":"Hello"}}]}
data: {"id":"gen-...","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
# with stream_options.include_usage
data: {"id":"gen-...","choices":[],"usage":{"prompt_tokens":14,"completion_tokens":7,"total_tokens":21}}
data: [DONE]event: response.created
event: response.in_progress
event: response.output_item.added
event: response.content_part.added
event: response.output_text.delta
event: response.output_text.done
event: response.content_part.done
event: response.output_item.done
event: response.completedevent: message_start
event: content_block_start
event: content_block_delta
event: content_block_stop
event: message_delta
event: message_stopChat Completions
Each chunk has choices[].delta. The last content chunk carries finish_reason.
The last chunk before data: [DONE] carries usage.
With stream_, that chunk has an empty choices array, as in OpenAI's API. Without it, the chunk keeps one choice with an empty delta.
Comment lines that begin with : may appear between events. Parsers skip them.
Responses
The event types include response.created, response.in_progress, response.output_, response.content_, response.output_, response.output_, response.reasoning.delta, response.reasoning.done, response.content_, response.function_, response.function_, response.output_, response.completed, response.incomplete, response.failed and error; other types are relayed as they arrive. The stream ends with one of three final events or with an error event. Each final event carries the final response object, with its usage when the provider reports it.
response.completedwhen the answer finishedresponse.incompletewhen it stopped early. The reason is inincomplete_details.response.failed
Messages
message_start opens with the input token count.
Each content block sends content_block_start, one or more content_block_delta events, and content_block_stop. Delta types are text_delta, input_json_delta, thinking_delta and signature_delta.
message_delta carries stop_reason and cumulative usage.output_tokens, then message_stop ends the stream.
ping events can appear anywhere, and an error event can appear mid-stream. Ignore event types you do not know.
Images
POST /v1/images streams only on models that support it.
The events are image_ as the image forms, then image_ with the final image and usage, then data: [DONE].
An error event can replace either.
Errors
A failure after the stream starts keeps HTTP 200 and arrives as an event.
- Chat Completions: a top-level
errorwithfinish_reason: "error" - Responses:
response.failedorerror - Messages: an
errorevent