Anatomy of a Production AI Gateway

9 min read Module 1 of 10 Lesson 2 of 28

What you'll learn

  • Name the six layers common to every production AI gateway and what each one owns
  • Explain the difference between a gateway's control plane (config, keys, policy) and data plane (the request path)
  • Map LiteLLM, TensorZero, Portkey, and Envoy AI Gateway onto this shared architecture
  • Identify which layer a given production requirement belongs to before reaching for a gateway feature
Building this at your company? For enterprise and company teams taking this to production: book a 30-minute session with our AI engineers for architecture guidance, code review, and a rollout plan for your use case.
Book a Team Session

Lesson 1 established why a gateway exists. This lesson opens it up and names its parts, because every gateway you will touch in this course, LiteLLM, TensorZero, Portkey, Envoy AI Gateway, is built from the same six layers, just with different implementations and different trade-offs in speed, deployment model, and feature depth. Knowing the layers means you can evaluate any new gateway that shows up in 2026 in about five minutes, by asking what each layer does and how it’s implemented, instead of reading its entire marketing page.

The Six Layers

flowchart TD
    A["1. Ingress & Auth\n(TLS, virtual keys, rate limits)"] --> B["2. Request Normalization\n(OpenAI-shaped schema in)"]
    B --> C["3. Routing Engine\n(which model, which deployment)"]
    C --> D["4. Provider Adapters\n(schema out, error normalization)"]
    D --> E["5. Cache & Cost Layer\n(exact/semantic cache, budget check)"]
    E --> F["6. Observability\n(traces, logs, metrics per request)"]

    style A fill:#EEF0F7,stroke:#6366F1,color:#0F172A,rx:8px,ry:8px
    style B fill:#EEF0F7,stroke:#6366F1,color:#0F172A,rx:8px,ry:8px
    style C fill:#4338CA,stroke:#4338CA,color:#ffffff,rx:8px,ry:8px
    style D fill:#EEF0F7,stroke:#6366F1,color:#0F172A,rx:8px,ry:8px
    style E fill:#F7F8FC,stroke:#0D9488,color:#0F172A,rx:8px,ry:8px
    style F fill:#F7F8FC,stroke:#0D9488,color:#0F172A,rx:8px,ry:8px

Ingress and auth terminates the incoming connection, validates the caller’s virtual key (not a raw provider key, Lesson 19 covers why), and applies the first rate-limit check before any provider is touched. Request normalization validates the incoming payload against the gateway’s canonical schema, almost always OpenAI’s Chat Completions shape (Lesson 5), so every downstream layer works against one predictable structure regardless of which client sent the request. The routing engine is the decision-making core: given the requested model name (or an alias like "fast-cheap"), the caller’s policy, and live health/latency signals, it picks exactly which provider, model, and API key will actually serve this request, this is where Module 4’s routing strategies live. Provider adapters do the mechanical translation, taking the normalized request and turning it into whatever shape Anthropic, Gemini, or a self-hosted vLLM server expects, then translating the response and any errors back into the canonical shape. The cache and cost layer checks for a cache hit before spending a token, and after a real call, checks whether it fits within budget and increments the caller’s spend, this is where Module 6 lives. Observability wraps the whole request in a span, recording model, tokens, latency, and cost, this is Module 8.

Control Plane vs Data Plane

A second useful split cuts across those six layers: the control plane is configuration that changes rarely, the list of available models, which teams have which budgets, routing policy, and the data plane is the hot path that executes on every single request. This split matters practically because it dictates a performance requirement: the data plane must read control-plane state from memory (or a fast local cache), never make a synchronous database round-trip per request, or gateway overhead becomes the slowest part of the whole call. TensorZero’s marketing claim of sub-millisecond p99 overhead at 10,000+ queries per second, and it is written in Rust specifically to keep the data plane out of any interpreted-language garbage collector’s way, is a direct consequence of taking this split seriously.

Mapping Real Gateways onto This Architecture

GatewayDeployment modelWhere it’s strong
LiteLLM (proxy)Single Python process, one config.yaml, self-hosted or managedBroadest provider coverage (100+), simplest to start, this course’s primary tool from Module 3 onward
TensorZeroRust binary, tensorzero.toml, Postgres or ClickHouse for observabilityLowest per-request overhead, built-in evaluation and experimentation tooling
Portkey (open-source gateway)Node.js process or managed, JSON “Gateway Config” per request or globallyRich per-request config (loadbalance, fallback, cache, retry composed in one JSON object), 50+ built-in guardrails
Envoy AI GatewayKubernetes-native, CRDs (AIGatewayRoute, AIServiceBackend) on top of Envoy GatewayFits teams already running Envoy/Istio-adjacent infrastructure, CNCF-governed

All four implement the same six layers, they just draw different lines around deployment complexity versus configurability. This course builds hands-on with LiteLLM starting in Module 3 because its config format is the most direct way to see all six layers in one readable file, then compares it against the other three in Lesson 27 once you have enough context to evaluate the trade-offs for yourself. Next, Lesson 3 places the gateway relative to two alternatives you have probably already used: calling a provider SDK directly, and relying on a framework’s built-in fallback logic.

Knowledge Check

3 questions to test your understanding

1 In gateway architecture terms, what is the difference between the control plane and the data plane?

2 A team needs per-tool rate limiting, response caching, and provider failover, but does not need a Kubernetes-native CRD-based control plane. Which class of gateway from this lesson best fits, based purely on deployment model?

3 Which layer is responsible for turning a provider-specific error (like a 529 overloaded response from Anthropic) into a decision to try a fallback model?

Go further with expert guidance

Ready to build production AI?
Talk to our R&D team.

These courses give you the foundation. Our embedded AI teams take you from prototype to production in 30–90 days, with your team, your codebase, your goals. Book a free strategy call to see how we can accelerate your AI initiative.

30 minutes · No obligation · Expert AI engineers, not sales reps

AI Architecture Review

Audit your current stack and identify high-impact improvements

Project Review

Get expert feedback on your AI implementation and codebase

Team Mentoring

Upskill your engineers with hands-on AI coaching sessions

AI Strategy

Define your AI roadmap, prioritization, and implementation plan