Skip to main content
AI / MLLLM FundamentalsDiagramBeginner

Token Streaming

KO: 토큰 스트리밍·EN: Token Streaming·JA: トークンストリーミング

A delivery pattern that pushes LLM output tokens incrementally via Server-Sent Events (SSE) as they are decoded, rather than blocking until the entire response completes

Table of Contents

Structure Diagram

SSE Token Streaming Delivery Cycle
SSE Stream1. Decode To…2. Push SSE …3. Increment…4. Done / Ab…
2/42. Push SSE Chunk
Delta event frame
Quick Answer

What is Token Streaming?

A delivery pattern that pushes LLM output tokens incrementally via Server-Sent Events (SSE) as they are decoded, rather than blocking until the entire response completes. It is a core concept in LLM Fundamentals within AI / ML.

Core Principles

Generating a 1,000-token response can take several seconds. Instead of blocking on a blank spinner until completion, Token Streaming streams decoded token deltas over Server-Sent Events (SSE) or WebSockets the instant they are produced.

Users begin reading as soon as TTFT elapses, and they can cancel runaway or off-track generations mid-flight to save both time and output token costs.

Practical Takeaways

  • Disable proxy buffering: Reverse proxies like Nginx buffer small chunks by default. Set Content-Type: text/event-stream, Cache-Control: no-cache, and X-Accel-Buffering: no.
  • Propagate client aborts upstream: Wire browser AbortController disconnects to cancel the upstream LLM API call so you do not pay for discarded tokens.
  • Handle partial markdown & JSON cleanly: Use streaming-safe markdown renderers or partial JSON parsers when updating structured UI components incrementally.

Notable Examples

  • ChatGPT & Claude Interfaces: Stream markdown paragraphs and syntax-highlighted code blocks token by token.
  • Agent Event Streams: Multiplex token deltas alongside structured tool_call, tool_result, and citation events on one SSE channel.
  • Streaming TTS Voice Bots: Flush each completed sentence from the token stream directly into text-to-speech for low-latency audio.