Streaming with Claude
Stream Claude API responses for real-time UX: server-sent events, token-by-token rendering, and production streaming patterns.
Last updated
After this section you can
- Trace the SSE event order and say which event carries text, tool arguments, stop_reason and usage
- Stream a tool-using turn safely, including eager input streaming and validation
- Recover a broken stream on current models and decide when not to stream
Streaming: Real-Time Token Delivery
A long answer can take many seconds to generate. Streaming sends it as server-sent events while it is written, so users see text at once and long requests stay clear of HTTP timeouts.
Streaming changes when you see the output, not how long it takes. The reply arrives as a fixed sequence of events; text and tool arguments exist only in the deltas, and stop_reason arrives near the end, in message_delta.