Skip to main content
Streaming lets your application display tokens as they are generated instead of waiting for the full response. This dramatically improves perceived latency for end users.

Basic Streaming

Each chunk is a ModelResponse object. During streaming, most chunks contain a small piece of the content. The final chunk includes usage metrics.

Streaming with Tools

When the model decides to call a tool during streaming, you’ll receive chunks with tool_calls instead of content:
When using agents, tool execution during streaming is handled automatically. You receive high-level events like ToolCallStartedEvent and ToolCallCompletedEvent instead of raw chunks. See Running Agents for details.

Streaming with Reasoning

Models that support reasoning (like DeepSeek Reasoner or OpenAI o1) emit reasoning content before the final answer:

Collecting the Full Response

To stream output to the user while also capturing the complete response:

Streaming vs Non-Streaming