Skip to main content
Stream LLM responses in real-time with full control over text, tool calls, and reasoning content.

Quick Start

StreamEvent

Every streaming chunk is wrapped in a StreamEvent with full context.

Event Types

REQUEST_START

Before API call is made

HEADERS_RECEIVED

HTTP 200 headers arrive

FIRST_TOKEN

First content delta (TTFT marker)

DELTA_TEXT

Text content chunk

DELTA_TOOL_CALL

Tool call chunk

STREAM_END

Stream completed

Reasoning Content

Models like o1, o1-mini, and deepseek-reasoner emit reasoning/thinking content before the final answer.

Multi-Agent Context

In multi-agent workflows, identify which agent emitted each event.

StreamMetrics

Track streaming performance with built-in metrics.

StreamEventEmitter

Each agent has its own emitter for thread-safe streaming.

Built-in Callbacks

Provider Support

Streaming with reasoning content is supported across providers:
LiteLLM automatically extracts reasoning content from provider_specific_fields.reasoning_content and emits it as StreamEvent(is_reasoning=True).

Best Practices

1

Use is_reasoning for UI

Style reasoning content differently (collapsed, dimmed, or hidden)
2

Track Metrics

Monitor TTFT and tokens/second for performance optimization
3

Handle Errors

Check for StreamEventType.ERROR events
4

Multi-Agent Safety

Each agent has its own emitter - no shared state
Don’t let callback errors break streaming. The emitter catches exceptions silently.