Overview
Streaming allows you to receive LLM responses incrementally as they’re generated, providing a better user experience. LiteLLM supports streaming across 100+ providers with a consistent interface.Quick Start
Streaming Across Providers
- OpenAI
- Anthropic
- Cohere
- Groq
Async Streaming
Streaming with Function Calls
Streaming with Reasoning
Handle reasoning content separately from final answers.Complete Response from Stream
Build a complete response object from streaming chunks.Error Handling
Streaming Usage Tracking
Fake Streaming
Some providers don’t support native streaming. LiteLLM can fake it.LiteLLM automatically detects when fake streaming is needed and handles it transparently.
Stream Timeout Configuration
OpenAI SDK Compatibility
Use LiteLLM with OpenAI’s SDK streaming patterns.Chunk Structure
Understanding the streaming chunk format:Provider-Specific Notes
OpenAI
OpenAI
- Native streaming support
- Returns usage in final chunk
- Supports all features (tools, vision, audio)
Anthropic
Anthropic
- Native streaming support
- Reasoning content in separate delta field
- Supports prompt caching in streaming
Groq
Groq
- Ultra-fast streaming performance
- May use fake streaming for JSON schema
- Excellent for real-time applications
Cohere
Cohere
- Native streaming support
- Citations available in stream
- Tool calls streamed incrementally
Ollama
Ollama
- Local streaming
- No network latency
- Thinking content in separate field
Best Practices
User Experience
User Experience
- Always use streaming for user-facing applications
- Show typing indicators or placeholders
- Handle partial tool call arguments gracefully
Error Recovery
Error Recovery
- Implement timeout handling
- Log partial responses before errors
- Provide fallback to non-streaming on errors
Performance
Performance
- Streaming reduces perceived latency
- Monitor time-to-first-token (TTFT)
- Use async for concurrent streams
Cost Tracking
Cost Tracking
- Enable
include_cost_in_streaming_usage - Save final chunks for usage data
- Build complete response for detailed metrics