Running LLMs in production means routing each request to the best-fit model to cut costs, prevent outages, and get higher-quality responses.
That’s where an AI gateway solution can help.
We’ll help you leverage this type of solution by breaking down how they work and common 3rd-party vendors. But to start, let’s align on what an AI gateway is.
What is an AI gateway?
An AI gateway, also known as an LLM gateway, is a control layer between your apps and AI models that routes requests and centralizes governance so teams can run AI reliably in production.
It exposes a single API endpoint to manage, add, or swap providers and models without changing downstream integrations.
How AI gateways work
While every implementation differs, they typically include the following components:
Model access: you’ll be able to access hundreds of open and closed models from providers like OpenAI, Anthropic, Google, Qwen, and Bytedance
Routing logic: choose from a range of routing strategies, from an ordered fallback list to defining "best" by the benchmarks you weight, then letting the gateway score each model and route to the highest scorer
Merge Gateway lets you define a weighted blend of benchmarks to score every model and pick a winner
Cost governance: assign monthly budgets for a certain user or group of users (e.g., a customer) and get alerted when they’re approaching that budget
Observability: Leverage logs of every API request that passes through your AI Gateway, with details like the model used, end-to-end latency, and the number of input and output tokens consumed
Putting these components together, here’s how an AI gateway can work:
Once a request gets submitted, your app sends it to the gateway. The gateway scores the available models against your weighted benchmarks, routes to the best one (and fails over if it's down), checks if the customer is within budget, and returns the response through the same endpoint while fully logging it.
To help you avoid building and maintaining an AI gateway in-house, you can use one of the many popular solutions on the market.
Here’s a snapshot of your best options, along with the pros and cons of each:
Portkey
Portkey is an AI gateway and observability layer that sits between your app and multiple LLM providers to standardize requests, add routing/fallback, and give you logs, analytics, and governance controls.
Pros
Comprehensive and centralized observability (tracing, logs, cost/token analytics, etc.) across providers
Supports a broad range of LLMs (currently supporting more than 3,000 models)
Cons
Routing rules, policies, and virtual keys become their own surface to manage and keep in sync across environments, on top of your existing application config
The observability layer captures and stores prompt and response content along with metadata, which matters for sensitive workloads. Portkey offers PII redaction, retention controls, and self-hosting to address this, but configuring them correctly is on you
The Palo Alto Networks acquisition adds uncertainty to Portkey’s product roadmap, and could slow down their velocity, which can be detrimental for such a fast-changing product space
OpenRouter offers a simple way to route requests to different models and manage usage via a single integration.
Pros
Flexible free account to help you validate the API and the platform more broadly
While not super comprehensive, OpenRouter’s free plan lets you route requests to 25+ models and make 50 requests every day
Large Discord community to help you chat with other users and get tips for using the platform
Offers a simple onboarding process. For example, you can get your OpenRouter API key in seconds
Cons
Routing is optimized for provider/model selection only, with no ability to route by customer, feature, region, or use case
You’ll only get basic privacy controls and provider safeguards, with no enterprise DLP or prompt-injection protection
Cost tracking doesn't map to SaaS economics. Spend tracking is limited to org, workspace, and project level, so you can't attribute cost by customer, team, or feature
Merge Gateway is a production control plane for LLM traffic that provides a single API to multiple models, plus routing, cost controls, security/policy guardrails, and audit-ready observability.
Pros
Enforce per-customer and per-project model and region policies, filter sensitive data with built-in DLP and prompt-injection protection, and log every routing decision, cost, and outcome
Cap spend in real time by project, team, or customer tier, attribute every dollar to a model, provider, and team, and consolidate provider invoices into one. Instant automatic failover routes around provider outages with no code changes
Merge Gateway lets you set spending limits and consumption-based alerts
Offers “Build Your Own Router,” which lets you define what "best" means using weighted benchmarks or your own eval scores. The gateway scores each model and picks a winner per request, and shows which model won, why, and which rules fired
Jon Gitlin is the Managing Editor of Merge's blog. He has several years of experience in the integration and automation space; before Merge, he worked at Workato, an integration platform as a service (iPaaS) solution, where he also managed the company's blog. In his free time he loves to watch soccer matches, go on long runs in parks, and explore local restaurants.
Read more
7 best practices for authentication in AI agents
AI
Introducing the Universal Context Layer: a company brain that works with every AI tool and agent
Product
Instantly cut token spend in half: introducing Merge for Workforce