What is an AI gateway?
An AI gateway is a middle layer that gives applications one access point to different AI models and centrally applies authentication, quotas, model routing, logging, cost and policy controls.
It differs from an MCP gateway in traffic type: an MCP gateway manages MCP traffic carrying tool and resource calls, while an AI gateway manages model calls. It differs from an AI firewall in focus: the firewall filters content for security, while the gateway manages access, routing and quotas. It is not just an API router; the two can be combined in one product.
- Topic
- Infrastructure and runtime
- Also known as
- LLM gateway, model gateway
How an AI gateway works
- Applications connect to models through the gateway; each request is authenticated and authorised by role.
- Per-user or per-application quotas and token rate limits apply, blocking excessive consumption.
- Requests are routed to the right model by rule (model routing); if a model fails, traffic falls back to another (model fallback).
- Every call is logged (audit log); policies such as data masking and content filters are applied.
In more detail
Semantic caching and KV-cache-aware routing
To reduce GPU cost and tail latency, modern AI gateways support semantic caching, returning cached answers when a new prompt is semantically equivalent to a prior query and prefix- or KV-cache-aware routing, which steers requests sharing common system prompts or conversation prefixes to the same inference replica so prefill computation is reused.
Streaming and token-based limits (RPM versus TPM)
Unlike classic REST APIs, LLM traffic relies heavily on Server-Sent Events (SSE) streaming and asymmetric input, output and reasoning token costs. An AI gateway therefore meters tokens asynchronously from streamed chunks, enforces both request-per-minute (RPM) and token-per-minute (TPM) budgets and manages circuit breakers across heterogeneous model backends.
Single point of failure, latency budget and high availability
Routing all AI traffic through a single gateway creates a potential latency hop and single point of failure (SPOF). Production deployments mitigate this with stateless, horizontally scaled gateway replicas, fast health checks, streaming pass-through without full-response buffering when latency is critical and strict separation between control-plane routing and heavy inspection workloads.
Commonly confused terms
| Term | How it differs |
|---|---|
| Traditional API gateway | A general API gateway manages HTTP microservices, routing and OAuth/JWT auth at the request level, whereas an AI gateway adds LLM-specific controls such as input/output token accounting, streaming (SSE) handling, semantic caching and model fallback. |
Why an AI gateway matters for on-premises AI
With several models and applications, each application writing its own identity, quota and logging logic creates both security gaps and maintenance burden; a gateway gathers them in one place. It also makes switching models easier: applications keep the same interface while the model behind it changes. Usage and cost become visible per unit. In-house, the gateway runs on the organisation's network and prompts and logs stay inside.
A public body routes its departments' AI calls through an in-house gateway; each call is authorised and logged and personal data is masked.
Common questions
How does an AI gateway differ from an MCP gateway?
An AI gateway manages applications' calls to models. An MCP gateway manages agents' MCP calls to tools and data sources; the two can be used together.
How does an AI gateway make switching models easier?
Applications connect to one stable interface. The model behind it can be changed through gateway configuration or routed to different models by use case case.
Related terms
- Model routing
- MCP gateway
- AI firewall
- AI audit log
- Token rate limit
- Model fallback
- Model serving
- Model-agnostic architecture
Sources
- NIST SP 800-204, Security Strategies for Microservices-based Application Systems
- OWASP Top 10 for LLM Applications 2025, LLM10: Unbounded Consumption
Related page on this site: Zylon page · In the glossary: Glossary, D to L