stream: true to receive semantic Server-Sent Events instead of waiting for one final JSON response.
Use this when you want to render text progressively, react to tool calls early, or inspect structured lifecycle events.
Enable Streaming
Event Lifecycle
Per the protocol tests, a normal text stream looks like this:delta values from response.output_text.delta events.
What to listen for
response.output_text.deltafor visible textresponse.function_call_arguments.deltafor tool argumentsresponse.completedfor the final snapshot[DONE]for the stream terminator
Manual SSE Parsing Example
Tool Call Streaming
When the model emits a tool call, the stream includes argument deltas such asresponse.function_call_arguments.delta followed by response.function_call_arguments.done.
Error Events
If an error occurs after headers are already sent, the stream may emit anerror event and then a failed terminal event before [DONE].
Common mistakes
- treating the stream as plain text instead of parsing structured events
- ignoring tool or reasoning deltas because the client only listens for text
- forgetting that usage and the final response snapshot arrive at the end, not in each text delta