Eugene Chernenko

AI, Engineering Management, Distributed Systems, SRE, Productivity

AI Infra Runs on Streams

2026-11-15

Look at a modern internal AI platform from the outside and it resembles standard web plumbing: a client sends an HTTP POST request and gets text back. In reality, production AI inference behaves nothing like a traditional request-response REST API. Because LLM generations can run for over a minute—and GPUs are expensive, preemptible resources—the entire stack is built around Server-Sent Events (SSE) streaming.

[Claude Code / Web UI] ──(SSE Stream) ──▶ [LiteLLM Gateway] ──▶
  (Client / Harness)                       (Router / Proxy)

──(SSE Stream)──▶ [Global Spot GPUs + SGLang]
                   (GLM / Qwen / Clef)

Decoupling the gateway from the GPU runtime via a standard streaming contract is what lets teams blend frontier cloud APIs with cheap, globally hunted spot GPUs without breaking developer workflows.

Client to Gateway: How Claude Code & Web UIs Talk to LiteLLM

Whether a user is typing into a browser chat interface or running an autonomous coding harness like Claude Code, every turn begins with an HTTP POST (typically to /v1/chat/completions or Anthropic's /v1/messages) with "stream": true.

Instead of holding the socket silent until generation finishes, the server immediately responds with Content-Type: text/event-stream and leaves the TCP connection open. As the model samples tokens one by one, tiny data: {...} chunks drip back to the client in real time.

This streaming contract solves three operational problems:

LiteLLM sits in the middle of this pipe on stable, always-on CPU infrastructure. To clients, it looks like a single unified API. Under the hood, it translates API dialects in real time (such as converting Anthropic-formatted streams for Claude Code into OpenAI-formatted streams for self-hosted models), captures token usage from the final stream chunk for cost metering, and handles retries if a spot node disappears mid-stream.

Gateway to Metal: Talking to Any SSE-Compatible Backend

Because LiteLLM acts purely as a protocol-translating proxy, it does not care what generates the tokens or where that hardware lives. As long as a backend exposes an HTTP endpoint yielding OpenAI-compatible SSE chunks, LiteLLM can route traffic to it — including across a global pool of preemptible spot GPUs (such as NVIDIA H200 or RTX PRO 6000 instances).

That standard SSE boundary lets infrastructure teams mix and match specialized inference runtimes on the backend:

The Architectural Payoff

Standardizing on SSE streams through a central gateway separates developer experience from compute volatility. Coding harnesses and web chat apps get a single, reliable endpoint, while platform teams stay free to hunt for cheap spot GPUs anywhere in the world, swap inference engines from vLLM to SGLang, or route between self-hosted open models (like Qwen, GLM, or Clef) and metered frontier APIs behind the scenes.