Introducing Duet Autopilot.
Learn more
Glossary

AI gateway

An AI gateway is a middleware layer that sits between an application and one or more large language model providers, centralizing authentication, rate limiting, routing, caching, observability, and cost controls behind a single endpoint. Instead of every product team wiring its own retries and key management directly into a provider's API, all traffic passes through the gateway first.

It plays the same role for AI traffic that an API gateway plays for microservices, adapted to the realities of LLM calls: token-based pricing, model failover, and prompt-level logging. AI gateways have become a standard layer in the production LLM stack as organizations move from one prototype calling one model to dozens of features calling several providers across teams.

The gateway is where governance actually lives — which team can call which model, how much they can spend, what gets logged, and what happens when a provider has an outage. It converts AI usage from a pile of ad hoc integrations into infrastructure a platform team can operate.

The problem an AI gateway solves

Teams shipping AI features quickly tend to hit the same wall at the same time. API keys end up scattered across a dozen services with no central rotation policy, and nobody can say with confidence how much a given feature costs per month because spend is split across separate provider accounts.

When a provider has a bad day — elevated latency, a partial outage, a model deprecation — there is no shared mechanism to fail over to a backup. Logging, if it exists at all, is inconsistent from team to team, which becomes a real liability once a compliance team asks what customer data has passed through a third-party model.

An AI gateway consolidates all of this behind one control plane. Every downstream service calls the gateway rather than the provider directly, and the gateway becomes the single place where policy is enforced and where someone looks first when something breaks.

What an AI gateway actually does

Provider abstraction and routing. A gateway exposes one API surface, often OpenAI-compatible, and forwards requests to whichever backend is configured, with fallback across providers. This overlaps closely with an LLM router, which most gateways include as an internal component.

Authentication and cost governance. Rather than distributing raw provider keys, the gateway issues virtual keys scoped to a team or customer, and enforces quotas — requests per minute, tokens per minute, monthly spend ceilings — with dashboards that break down cost by model or feature.

Caching and observability. Exact-match caching avoids paying twice for an identical prompt, and semantic caching extends that to near-duplicate requests, cutting both latency and bill size. Every request is logged in structured form — prompt, completion, latency, token counts, and cost — searchable and exportable to a data warehouse.

Safety controls. Because every request already passes through one chokepoint, that is the natural place to redact personally identifiable information, filter unsafe content, and screen for jailbreak attempts before a response reaches an end user.

AI gateway, API gateway, and LLM router

An API gateway — the Kong or Apigee category — is the classic front door for microservices: authentication, routing, rate limiting, and payload transformation, all model-agnostic. It has no concept of a token or a prompt.

An AI gateway takes that same pattern and adds primitives specific to LLM traffic: token accounting, model failover, prompt logging, semantic caching, and content safety filters.

An LLM router is narrower still, deciding only which model should handle a given request. A gateway typically contains a router rather than competing with it.

Where the trade-offs show up

A gateway adds a network hop, which adds latency, however small. For high-throughput or latency-sensitive workloads that overhead has to be measured, not assumed away. Centralizing traffic through one layer also creates a single point of failure: if the gateway goes down, everything behind it goes down too.

There is also a build-versus-buy decision baked into the category. Open-source options give full control over where data flows but require a team to operate them. Hyperscaler offerings are convenient but tie routing decisions to one vendor's ecosystem, while enterprise platforms bundle governance and evals at the cost of some flexibility. The right choice depends on where prompts are allowed to travel and how much operational overhead a team wants to own.

Where an AI gateway fits in the AI stack

An AI gateway sits below the application layer and above the model providers, directly in the path of every production AI feature a company ships. For a customer-support AI agent handling conversations that include account numbers and order history, the gateway is where policies like zero data retention get enforced and PII gets redacted before it reaches a third-party model.

It is also where cost gets attributed back to a specific customer or workflow rather than disappearing into a single provider invoice. As support organizations run more volume through AI agents rather than human queues, the gateway layer is what keeps that traffic auditable, cost-controlled, and resilient to any single model provider having a bad day.

Deliver the concierge experiences your customers deserve

Get a demo