AI gateway
A proxy between your app and model providers that adds logging, caching, limits, billing and fallbacks.
An AI gateway is a proxy between your application and model providers. The app calls the gateway, which forwards each request and adds logging, caching, rate limits, cost tracking and fallbacks in one place, so switching provider or model becomes a configuration change.
Instead of calling each provider directly, the app calls the gateway, which forwards the request. You get one place to see traffic and cost, switch providers and enforce limits. Some gateways also bill several providers from one balance. Hosted options such as Cloudflare AI Gateway offer analytics, caching, rate limiting, request retries and model fallback; self-hosted open source proxies do the same inside your own network. The trade is one more hop and, for hosted gateways, one more vendor in the data path, which matters for data residency and your data processing agreement.
A gateway is the natural home for model routing, a cost cap and LLM observability. It differs from a classic API gateway, which routes traffic to your own services and knows nothing about tokens or prompts. Its cache is usually an exact-match or a semantic cache of whole answers; it does not replace the provider’s own prompt caching.
Sources
- Cloudflare: Cloudflare AI Gateway developers.cloudflare.com
Related terms
- Model routing and fallback: Sending each request to the model that fits it, and to another one when the first fails.
- Cost cap: A hard spending limit enforced by your code, per user, per day or per month.
- LLM observability: Tracing every model call with inputs, outputs, latency, tokens, cost and the user outcome.
- Semantic cache: Reusing a stored model answer when a new question means the same as an earlier one, matched by embedding similarity rather than exact text.
- API gateway: A single entry point in front of backend services that handles routing, authentication, rate limits and TLS for all of them.
- Prompt caching: Reusing an identical prompt prefix across requests so it is cheaper and faster to process.
- Data residency (AI and cloud): Where your data is stored and processed, including where an AI model runs on it, and whether it can leave a region such as the EU.
