Best LLM Router / Blog

Questions readers ask: What's the difference between an LLM router and an LLM gateway?

An LLM router decides which model handles a request. An LLM gateway controls how that request is authenticated, limited, logged, and governed. They solve different problems, even when a single product supplies both. Separating those responsibilities helps developers decide what their infrastructure needs, who should own it, and which gaps a bundled product actually closes.

Why developers conflate routers and gateways — and why the conflation costs them

A developer chooses a product called a gateway, then discovers that its routing features do not provide the model-selection behavior the application needs. Another team deploys a router and assumes access controls come with it. The labels do not settle the question. Most LLM infrastructure products bundle routing and gateway functions, marketing the combination under names that reveal little about the underlying responsibilities.

Teams can over-invest in model selection before establishing governance, or mistake a governed endpoint for an optimized one. The useful distinction is therefore not what the product calls itself, but what each layer controls, when it acts, and which team owns its failures.

What a router does: selecting the right model before the call is made

A router is a pre-call decision layer that inspects a request and selects a model or provider based on task type, complexity, cost, latency, or availability. By sitting between the application and the available models, it centralizes selection logic that would otherwise be hardcoded into individual services. Changing model choices then need not mean changing that logic in every application.

Different routing strategies use different signals. Rule-based routing uses static headers, task tags, or user tiers, while weighted distribution assigns configured percentages of traffic without inspecting request content. Semantic or complexity-based routing compares prompt embeddings with labeled examples and assigns a complexity tier. Learned routing instead predicts model fit from training data. Failover handles recovery when the selected target fails, rate-limits, or times out.

Production deployments often combine two or three strategies, such as a complexity classifier, traffic weights, and a fallback chain. In a support system, a working-hours question can go to a lightweight model while technical troubleshooting goes to a more capable one. ML/AI engineering teams are usually in charge of these decisions. Their characteristic failure is a poor capability match or excess cost.

What a gateway does: governing every call after the routing decision

A gateway is a policy layer that wraps every LLM call with authentication, authorization, rate limiting, budget enforcement, and audit logging. For every selected model, the gateway validates who may call which models, applies quotas by user or team, and records prompts and responses for debugging, compliance, and cost attribution. Centralized API key management also keeps provider credentials from being distributed across applications.

The same layer can transform prompts, inject system context, strip PII, and apply content filters before dispatch. It can also transform responses after generation. Semantic caching reuses responses for similar requests, avoiding redundant calls and reducing latency and cost. These functions govern execution rather than determine the best model for a particular task.

An LLM gateway differs from a generic API gateway because ordinary HTTP traffic controls do not natively understand tokens, models, or prompts. LLM-specific features include token-aware limits, per-model cost tracking, and prompt caching. Platform, infrastructure, and security engineering teams are usually in charge of this layer. Without it, the characteristic exposure is uncontrolled access, missing audit records, or unenforced quotas.

The sharpest difference between the two layers: when each acts and what it controls

Timing and scope make the distinction precise. The router makes its selection before dispatch, optimizing for capability match, latency, and cost. The gateway wraps each resulting call, enforcing access, usage constraints, and recorded evidence. Recovery may require another routing decision, but that does not turn selection into policy enforcement.

A financial reporting application makes the separation concrete. Its router sends simple summary queries to GPT-4o Mini and complex cross-dataset analysis to Claude Opus. Its gateway permits only Finance team members to use the endpoint, enforces a defined daily request limit per user, and logs every prompt for audit. Both layers have done their jobs independently.

The logical request path is application, router, gateway, then model. The steps describe jobs that can share a product. A gateway can contain routing logic and fallback chains, but policy enforcement alone does not optimize model quality or cost per query. Conversely, a focused router does not ordinarily contain the full set of gateway controls.

Where routing pays for itself: cost reduction as the primary business case

The strongest economic case for routing is avoiding frontier-model prices for requests that lighter models can answer well. Savings depend on the workload mix. If easy queries form much of the volume, moving them to a cheaper model lowers average inference cost while complex queries retain access to stronger models. Those easy queries must be identified without sacrificing the required quality.

RouteLLM, developed by researchers from UC Berkeley, Anyscale, and Canva in 2024, demonstrated trained routing policies that met a stronger model’s quality target while assigning a large share of queries to a weaker, cheaper model. Preference data supplied evidence of which model users favored for similar inputs.

Rule-based and semantic routing can also capture savings. Learned routing can capture more, but needs training data and can drift as available models change. Internal data from a large set of accounts shows that teams usually move from rule-based to complexity-based routing once cost becomes a sizable part of the budget. Gateway caching and budget limits help avoid repeat calls and runaway spending, while per-query selection is worth more when there are many calls and a wide price gap between models.

Where a gateway becomes non-negotiable: compliance, multi-tenancy, and audit trails

The strongest reason to pay for a gateway comes when more than one team shares LLM access. Each needs isolated credentials, independent limits, and attributable spending. A router alone cannot enforce those boundaries. Without a shared place to enforce rules, one application can use up the organization’s API quota without regard for another team’s budget or rules for access.

Finance, healthcare, and legal workloads can require logged prompts and responses, PII detection, and output filtering. Those controls belong at the gateway, where policy can apply across teams. Centralized key management also reduces the attack surface and simplifies rotation.

Agentic workloads expand that governance scope further. A single request can start many model calls, tool uses, and reasoning chains. The control layer must therefore cover tool invocations and agent-to-agent traffic as well as individual prompt-and-response pairs. An application-specific router can optimize its own choices, but organization-wide rules need an organization-wide enforcement point.

How the product landscape blurs the boundary — and what to look past

Bundled products make the conceptual separation harder to see. TrueFoundry describes its platform as a complete AI control plane that covers gateway functions, model deployment, and agent infrastructure. Portkey has routing along with team management, access controls, compliance features, and enterprise audit trails.

LiteLLM’s proxy is MIT licensed and supports self-hosting, including fully air-gapped deployments. Portkey’s core AI gateway is also open-source and self-hostable. Other products are hosted-only, so a gateway label says nothing by itself about whether the deployment can meet a team’s privacy requirements.

For a team evaluating these products, the lesson is to look past the category name. Is routing, proxying, or policy enforcement the primary capability? Which team will own each responsibility, and do the governance controls apply organization-wide or only within one application?

An emerging risk: the router as an attack surface

A router can become a target in its own right. Adversarial inputs can manipulate the classification signal that ordinarily directs simple requests to cheaper models, inducing more expensive or less appropriate selections. A caller who has access can therefore exploit the way a model is chosen while staying within an access rule. Authentication alone does not address that threat.

Shafran et al.’s 2025 paper Rerouting LLM Routers documents adversarial manipulation of routing decisions. The 2026 follow-on Route to Rome Attack: Directing LLM Routers to Expensive Models via Adversarial Suffix Optimization examines inputs designed to force expensive model selection. These studies establish an attack surface whose prevalence across production systems remains undetermined. Gateway logs and rate limits do not, by themselves, reveal whether the preceding classification was manipulated.

For teams deploying semantic or learned routers, the practical implication is to apply adversarial robustness thinking to the classifier. Relevant controls include input validation, similarity floors that permit abstention, and audits of routing decisions during anomalous cost patterns. Bifrost’s complexity router, for example, uses a similarity floor below which the classifier abstains and weak matches fall through to normal routing. That cuts down on forced decisions, though the router can still be attacked.

What neither layer governs: the accuracy of the context the model reasons over

Even when a request is routed correctly and all governance rules are followed, its answer can still draw on outdated information. Consider the financial reporting application again. The router can select the right model and the gateway can authorize the caller, yet neither checks whether a revenue definition reflects the latest policy change. The infrastructure has behaved correctly within its scope.

Routing and governance are control-plane functions, while the information supplied to the model is a separate data concern. Financial research, cited intelligence, and compliance-sensitive applications need current evidence when answering questions about prices, regulations, policies, or events. Choosing a model cannot bring its static training data up to date.

A real-time web search API supplies a complementary grounding layer by retrieving current sources that can be cited and examined. Readers can then judge an answer by its sources as well as by what the model says. It does not turn routing or access control into factual verification.

How the two layers fit together in a production stack — and in what order to build them

For teams deciding what to build, the recommended sequence is gateway first, then routing once query volume and cost patterns justify optimization. The gateway provides immediate visibility into who calls which models, at what cost, while establishing an audit trail before a compliance review requires it. That order also fits typical staffing. The platform team is often ready before ML/AI engineers have enough data to tune routing policies.

Build order differs from request order. At runtime, an application or agent reaches the model router for selection, then the model gateway for governance, and finally the model. A bundled gateway-with-routing product can implement those responsibilities together. For agentic workloads, teams should plan governance for tool invocations, agent-to-agent calls, and grounding search calls before the architecture is locked.

Deployment constraints also belong in that decision. Teams with air-gap, data residency, or strict PII requirements should check deployment documentation for a supported self-hosting path, including for products described as “open source”.

Three questions keep the responsibilities separate in practice. “Which model?” is a routing question. “Who can call it, how often, and with what logged record?” is a gateway question. “Is what the model reasons over accurate and current?” is a data-grounding question that the control plane cannot answer.