|
Every enterprise AI platform hits the same wall. One team gets one Azure OpenAI deployment. Six months later there are eleven apps, four agent frameworks, three model providers, keys scattered across repos and a token bill nobody can explain. The AI Gateway is the pattern that fixes it: one governed front door for every model, tool and agent call. Here's why you need one, what should (and shouldn't) go through it, and how APIM, LiteLLM and OmniRoute compare.
What an AI Gateway Actually IsAn AI Gateway is a governed front door for all LLM traffic. Applications and agents stop calling model endpoints directly and call the gateway instead. The gateway then:
Apps & Agents
→
Authenticate
→
Apply policy
→
Route
→
Measure
→
Models
On Azure, the AI Gateway is built on Azure API Management (APIM), which now ships a dedicated set of LLM-aware policies. That's why this is more than "put an API gateway in front of it": a traditional API gateway counts requests, while an AI Gateway counts tokens, and in the LLM world tokens are money.
Key ideaAn AI Gateway doesn't replace your agent runtime or your application. It governs how AI is consumed, not where your apps run.
Seven Reasons You Need One (Before Your CFO Tells You)1Cost control that works at the token levelA single runaway agent loop can burn through a month's budget in an afternoon. The 2Chargeback and showback without guessworkWith 3Resilience across deployments and regionsModels get throttled (HTTP 429), regions have bad days, and PTU capacity is finite. APIM backend pools support priority and weighted load balancing, plus a circuit breaker that respects 4Consistent safety and guardrailsInstead of trusting every team to implement content moderation, the gateway can enforce it centrally with the 5No more keys scattered across codeThe gateway uses its managed identity to talk to Azure OpenAI and Foundry, so provider keys never leave the platform. Consumers authenticate to the gateway with Entra ID tokens. Rotating credentials or revoking a misbehaving app becomes one change in one place, not a hunt through twelve repos. 6Freedom to change models without breaking appsModels get versioned, upgraded, and retired constantly. When apps call a logical model name on the gateway rather than a hard-coded deployment, the platform team can test a new version in non-production, then switch production routing without anyone redeploying their app. 7One place to govern tools and agents, not just modelsThe AI Gateway has grown beyond LLMs. APIM can now expose REST APIs as MCP servers, front existing MCP servers with OAuth and policies, and manage A2A (agent-to-agent) APIs. As agents start calling tools and each other across teams, you get the same authentication, throttling, and audit trail you already have for models. The Reference Pattern: Hub, Spoke, and a Clear Line Between ThemThe pattern I see working best in enterprise landing zones has three layers:
Some design decisions I recommend:
The Part Most Architectures Get Wrong: What Should Not Go Through the GatewayIt's tempting to put everything behind the gateway. Don't.
Rule of thumbMediate where governance adds value (tokens, trust boundaries, external parties). Go direct where it only adds latency.
What It Looks Like in PracticeHere's a trimmed-down inbound policy that captures the essentials: Entra ID auth, a per-app token budget, token metrics, managed identity to the backend, and a load-balanced backend pool. <policies>
<inbound>
<base />
<!-- 1. Authenticate the caller with Entra ID -->
<validate-azure-ad-token tenant-id="{{tenant-id}}">
<audiences>
<audience>api://ai-gateway</audience>
</audiences>
</validate-azure-ad-token>
<!-- 2. Token budget per calling application -->
<llm-token-limit
counter-key="@(context.Request.Headers.GetValueOrDefault("x-app-id","unknown"))"
tokens-per-minute="20000"
estimate-prompt-tokens="false"
remaining-tokens-header-name="x-remaining-tokens" />
<!-- 3. Emit token usage for chargeback -->
<llm-emit-token-metric namespace="ai-gateway">
<dimension name="AppId" value="@(context.Request.Headers.GetValueOrDefault("x-app-id","unknown"))" />
<dimension name="API ID" />
</llm-emit-token-metric>
<!-- 4. No keys: gateway uses its managed identity -->
<authentication-managed-identity resource="https://cognitiveservices.azure.com" />
<!-- 5. PTU-first pool with PAYG spillover (priority + circuit breaker) -->
<set-backend-service backend-id="llm-backend-pool" />
</inbound>
</policies>
Add Not Only APIM: Open-Source AI Gateways Worth KnowingAPIM is the natural choice in an Azure landing zone, but the AI gateway pattern isn't tied to one product. Two open-source projects come up in almost every conversation I have with engineering teams, and they solve quite different problems. LiteLLM: the open-source enterprise gatewayLiteLLM is one of the most widely adopted open-source AI gateways. You can use it as a Python SDK or run it as a proxy server (the gateway mode) that exposes 100+ providers, including Azure OpenAI, Foundry, Bedrock, Vertex AI, Anthropic, vLLM and NVIDIA NIM, behind a single OpenAI-compatible API. Gateway mode gives you most of the building blocks from this article:
Where it fits on Azure: a multi-cloud or multi-provider estate where the platform team wants a code-first, self-hosted gateway, or a workload that needs a provider APIM doesn't cover natively. Run it on AKS or Azure Container Apps inside a spoke with private networking, back it with Azure Database for PostgreSQL and Azure Managed Redis, and put it behind your Landing Zone ingress like any other workload.
Pattern I likeFor larger enterprises: APIM at the edge, LiteLLM behind it. APIM owns enterprise identity, WAF integration and the policies security teams already know; LiteLLM handles provider-specific translation and routing. Keep it to two layers: every extra hop adds latency and one more thing to operate.
OmniRoute: the developer's AI routerOmniRoute is a different kind of tool. It's an MIT-licensed, local-first gateway built for individual developers and coding tools such as Claude Code, Codex, Cursor, Cline and Copilot. You point your tools at one endpoint and OmniRoute handles:
Know where your prompts goIt's a great productivity tool for personal use, hackathons and experiments, but it's not an enterprise governance layer, and the project is honest about that: it keeps its own list of providers flagged as terms-of-service risks and notes that free tiers change frequently. When a request can fall back to a free third-party provider, you no longer control where your prompt (and your code) is processed or retained. For corporate code or regulated data, point developer tools at your governed gateway instead.
Quick comparison
My rule of thumb: for an Azure-first enterprise, start with APIM. Add LiteLLM when your provider mix or code-first requirements outgrow it. Use OmniRoute for personal productivity, never as the front door for company data. And whatever you self-host, treat it like any other critical dependency: pin versions, verify container images, and scan your supply chain. Pitfalls I've Seen in the Field
Adoption Checklist
My TakeIn 2023 the question was "which model should we use?" In 2026 it's "how do we let fifty teams use a dozen models, hundreds of tools and a growing number of agents safely, affordably and visibly?" The AI Gateway is how you answer that without slowing anyone down. Build it early, keep it focused on governance rather than making it a proxy for everything, and your AI platform will scale with the business instead of against it. Next in this series: AI networking on Azure, covering private endpoints, DNS, egress control for agents, and the subnet sizing mistakes that bite later.
References
AI gateway capabilities in Azure API Management Access Foundry models through a gateway (Azure Architecture Center) llm-token-limit policy llm-emit-token-metric policy llm-content-safety policy Enable semantic caching for LLM APIs Backends, load balancing and circuit breaker in APIM Authenticate and authorize access to LLM APIs Log LLM prompts, completions and token usage Expose REST APIs as MCP servers Secure MCP servers in APIM Agent-to-agent (A2A) APIs in APIM Configure AI Gateway in Microsoft Foundry Bring your own model (via AI gateway) to Foundry Agent Service Govern MCP tools by using an AI gateway AI Gateway hands-on labs (GitHub) Azure AI Landing Zones (GitHub) LiteLLM (GitHub) OmniRoute (GitHub)
0 Comments
Leave a Reply. |
Author
Mohammad Al Rousan is a Microsoft Most Valuable Professional (MVP) in Azure, a cloud architect, and a recognized leader in enterprise AI and data platforms. With over a decade of hands-on experience, he specializes in designing and scaling secure, production-grade solutions across Azure AI, Databricks, and modern cloud-native architectures. Top 10 Microsoft Azure Blogs
Archives
September 2026
Categories
All
|



RSS Feed