Basic Streaming
Setstream=True and use the streaming helper:
Sync Streaming (Python)
For Python scripts that don’t need async:When to Stream
Stream when:- Building chat interfaces where perceived latency matters
- Generating long-form content (articles, code, analysis)
- Running in terminals or logs where progress feedback helps
- You need to parse the complete response before displaying
- Using structured outputs with
.parse() - Response time is already fast enough
Streaming with Tools
Streaming works with tool-calling workflows. You’ll see the model’s reasoning and tool results as they happen:Next Steps
- Structured Outputs — Type-safe streaming with
.stream() - Examples — More streaming patterns