Streaming
Stream responses in real-time with multiple consumption patterns. All streams are built on a reusable stream architecture that supports concurrent consumers.
Text Streaming
getTextStream()
Stream text content as it’s generated:
Each iteration yields a small chunk of text (typically a few characters or a word).
Reasoning Streaming
getReasoningStream()
For models that support reasoning (like o1 or Claude with thinking), stream the reasoning process:
Message Streaming
getNewMessagesStream()
Stream incremental message updates in the OpenResponses format:
This stream yields:
ResponsesOutputMessage- Assistant text/content updatesOpenResponsesFunctionCallOutput- Tool execution results (after tools complete)
Full Event Streaming
getFullResponsesStream()
Stream all response events including tool preliminary results:
Event Types
The full stream includes these event types:
Tool Call Streaming
getToolCallsStream()
Stream structured tool calls as they complete:
getToolStream()
Stream tool deltas and preliminary results:
Concurrent Consumers
Multiple consumers can read from the same result:
The underlying ReusableReadableStream ensures each consumer receives all events.
Cancellation
Cancel a stream to stop generation:
Streaming with UI Frameworks
React Example
Server-Sent Events (SSE)
Next Steps
- Tools - Create tools and multi-turn streaming with tools