Skip to main content

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

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

  • Native streaming support
  • Returns usage in final chunk
  • Supports all features (tools, vision, audio)
  • Native streaming support
  • Reasoning content in separate delta field
  • Supports prompt caching in streaming
  • Ultra-fast streaming performance
  • May use fake streaming for JSON schema
  • Excellent for real-time applications
  • Native streaming support
  • Citations available in stream
  • Tool calls streamed incrementally
  • Local streaming
  • No network latency
  • Thinking content in separate field

Best Practices

  • Always use streaming for user-facing applications
  • Show typing indicators or placeholders
  • Handle partial tool call arguments gracefully
  • Implement timeout handling
  • Log partial responses before errors
  • Provide fallback to non-streaming on errors
  • Streaming reduces perceived latency
  • Monitor time-to-first-token (TTFT)
  • Use async for concurrent streams
  • Enable include_cost_in_streaming_usage
  • Save final chunks for usage data
  • Build complete response for detailed metrics