Back to Blog

LLM Routing Guide: Best Multi-Model Gateway Strategy

Tutorials and Guides7944
LLM Routing Guide: Best Multi-Model Gateway Strategy

Multi‑model routing implements decision‑making logic between application clients and multiple large‑model services. It distributes incoming requests to appropriate models and providers based on cost, latency, capability, quota and failure status. It also performs automatic fail‑over when errors or timeouts occur. As of September 2026, available solutions fall into four distinct layers: local tool‑side routing, self‑hosted gateways, managed aggregation platforms, and intelligent routing algorithms.

The tool‑side routing layer runs on developer local machines, represented by claude‑code‑router (37 000 GitHub stars) and cc‑switch (130 000 GitHub stars). The self‑hosted gateway layer includes LiteLLM (57 790 stars), Kong AI Gateway, Bifrost, Higress, New‑API and TensorZero, supporting more than 100 model back‑ends and six routing strategies. Managed aggregation platforms are third‑party cloud services, including OpenRouter (5.5 % commission), Vercel AI Gateway (zero commission), Cloudflare AI Gateway, and 4sapi. Users can subscribe to 4‑16 model vendors under one single API key. The intelligent routing algorithm layer includes RouteLLM (claimed 85 % accuracy, saving 95 % inference cost), Not Diamond, OpenRouter Auto Router and LiteLLM Auto Router.

Selection should focus not merely on benchmark numbers, but on deciding which layer executes routing logic, how fail‑over triggers, where raw data persists, and maintenance responsibilities. This article compares official documentation and community datasets, delivers comparison matrices, scenario‑based recommendations and a ten‑item evaluation checklist.

What Is Multi‑Model Routing and Why Layered Architecture Matters

Multi‑model routing sits between end‑user applications and LLM service providers. It assigns each request to proper models and vendors, switches targets for failures or timeouts, and unifies authentication logic. It addresses four core pain‑points for mixed‑model production:

Routing logic can run on completely different infrastructure locations, hence the layered design:

LayerExecution LocationTarget AudienceRepresentative Projects
Tool‑side local routingDeveloper local workstationCoding‑agent usersclaude‑code‑router, cc‑switch
Self‑hosted gatewayPrivate servers / KubernetesCompany‑wide production workloadsLiteLLM, Kong, Higress, New‑API, Bifrost, TensorZero
Managed aggregationThird‑party cloud platformTeams avoiding self‑maintenanceOpenRouter, Vercel AI Gateway, Cloudflare AI Gateway, 4sapi
Intelligent routing algorithmEmbedded inside upper‑layer routing componentsTeams expecting complex automatic model selectionRouteLLM, Not Diamond, OpenRouter Auto Router, LiteLLM Auto Router

Practical stacks commonly combine two layers: tool‑side routing for local developer workstations and self‑hosted or managed aggregation gateways for production traffic.

Layer 1: Tool‑Side Local Routing

Tool‑side local routing works as a local proxy gateway for coding‑agent applications. Requests from Claude Code, Codex and similar agents hit local endpoints, then the proxy forwards traffic toward selected LLM providers. It solves the pain‑point “each agent maintains its own isolated provider configuration”.

ProjectGitHub StarsPositioningRouting CapabilitiesSupported Agents
claude‑code‑router (CCR)37 028Local model gateway / control plane, default listen address 127.0.0.1:3456Route by request headers and conditions; rewrite prompts; retry; fall‑back; token counting; orderly back‑offClaude Code, Claude Design, Codex, Grok CLI, Kimi CLI, Kilo Code, OpenCode, PI, ZCode, WorkBuddy
cc‑switch130 629Desktop‑side unified configuration managerDoes not proxy traffic itself; one‑click toggle of provider settings; centrally manage API keys and skill setsClaude Code, Claude Desktop, Codex, Gemini CLI, Grok Build, OpenCode, OpenClaw, Hermes

Key differences: CCR acts as runtime proxy; all agent traffic flows through it. cc‑switch edits local configuration files of each agent directly; agents send requests to providers without intermediate proxy hops.

CCR supports OpenAI Chat Completions, Anthropic Messages, Gemini Generate Content, OpenRouter, DeepSeek, SilconFlow, Moonshot, Kimi Code, Mistral, ZAI, Bailian plus custom compatible endpoints. Additional features include Fusion for vision‑incapable model adaptation, ToolHub, request logging, provider resolution, latency statistics, token counting and cost estimation. It can be installed as desktop application or via npm install @musistudio/claude‑code‑router. 22 providers are supported as of current release.

Agent Harness also implements routing within this layer. The dsh‑llm‑pi‑ai component in DeepSeek Harness defines multiple routing entries inside a providers dictionary. Each entry configures protocol, endpoint, API key whitelisting and model lists. Configuration updates apply on next request without extra proxy processes. This native‑agent routing serves only one specific agent instance.

Best‑fit scenarios: Individual developers and small teams. Ideal for sharing provider configurations across multiple coding‑agent tools and automatic switching when certain vendors throttle traffic. Not suitable as production‑facing ingress gateway.

Layer 2: Self‑Hosted Gateway

Self‑hosted gateways deploy inside private infrastructure. All model‑access traffic goes through this gateway. Routing, authentication, quota control and logging stay within internal networks. Multiple categories of self‑hosted solutions exist.

Specialized LLM‑Focused Gateways

ProjectStarsLicenseBack‑end SupportRouting StrategiesHighlight Features
LiteLLM57 790Custom license100+ LLMs, unified OpenAI‑compatible APIsimple‑shuffle(default), weighted‑latency, usage‑based‑routing, v2 adaptive routing, least‑busy, cost‑based‑routing, custom rulesBuilt‑in circuit‑breaker(allowed_fails default 3), cooldown_time default 5 seconds, 429 status cool‑down, retry policies mapped to error codes; Key‑level team quota management; Beta Auto Router
Bifrost7 745Apache‑2.023+ providers, 1000+ model variantsAutomatic back‑off, cross‑key & cross‑provider load‑balance, adaptive load‑balancing for enterprise tier5 k RPS under 100 ms latency; reported 50‑times faster than LiteLLM; npm deployment; session caching; MCP gateway capability
Portkey Gateway(open‑source)12 875MIT1 600+ LLMs, 50+ guardrailsRetry, cross‑key load‑balance, conditional routing, auto‑fallback, circuit‑breaker, request‑timeout handlingLocal runtime support; integrated PRISMA AIRS observability; repository last update May‑2026
TensorZero11 716Apache‑2.0Major mainstream providersBuilt‑in A/B testing, routing, retry, back‑offGateway latency below 1 ms; tracing & observability; evaluation pipelines integrated with private databases
New‑API47 050AGPL‑3.0Domestic & international LLMs, compatible OpenAI‑style APIWeighted traffic splitting, automatic fail‑over, user‑level rate‑limitFormat conversion between OpenAI and Claude‑Messages schema; token‑group billing; multi‑login user management
One‑API36 686MITDomestic & international LLMsChannel management and key distributionSingle‑file executable; repository effectively inactive since Jan‑2026

Three practical evaluation points:

  1. LiteLLM delivers the most comprehensive feature set. It implements six routing algorithms, error‑based retry & cool‑down, routing priority, context‑window pre‑check and geographic filtering. Official documentation warns high routing complexity may degrade throughput; simple‑shuffle remains default strategy.
  2. Bifrost and TensorZero prioritize raw performance. Both implemented in Rust / Go, delivering microsecond‑to‑millisecond overhead, suitable for high‑QPS workloads. Adaptive load‑balancing and cluster‑mode features are locked within enterprise plans.
  3. New‑API represents widely‑adopted self‑hosted solution in domestic developer communities. Strengths include comprehensive domestic‑model coverage, format conversion and token‑granularity consumption statistics. Routing strategy options are relatively limited (weighted distribution plus retry). Its README explicitly reminds operators to complete filing, real‑name registration and log‑retention compliance requirements for public‑facing deployments.

AI Extensions Built On Cloud‑Native API Gateway Infrastructure

ProjectStarsOriginAI Routing FeaturesHighlights
Kong AI Gateway44 076Kong API Gateway7 load‑balancing algorithms: round‑robin, weighted‑hash, least‑connections, lowest‑latency(EWMA), lowest‑usage(cost‑aware), semantic routing(prompt‑model similarity), priority‑based fail‑overCross‑provider fail‑over across incompatible‑schema back‑ends; circuit‑breaker max_fails / fail_timeout; configurable error‑redirection trigger; failover_criteria for http‑429; semantic cache, prompt‑guard, PII masking; advanced enterprise‑only modules
Higress9 270Alibaba open‑source, CNCF project, built upon Istio + EnvoyAI routing management: domain matching, weight distribution, downgrade configuration, consumer‑side throttling, per‑provider downgrade rules, health‑check recoveryPre‑integrated with Alibaba‑cloud, DeepSeek, Azure OpenAI; semantic cache, RAG, prompt templates; consumer‑quota control; real‑time token consumption metrics; remote MCP‑server support; one‑command Docker deployment
Envoy AI Gateway1 984Envoy Gateway sub‑projectTwo‑tier gateway pattern: authentication layer and routing layer; global flow‑control; self‑hosted model‑cluster endpoint selectorOpenAI, Azure OpenAI, Gemini, Vertex, Bedrock, Mistral, Cohere, Grok, DeepSeek mixed‑model traffic support
Apache APISIX17 070Apache top‑level projectAI‑gateway plug‑in suiteRe‑use existing APISIX deployment dashboard

Domestic platforms differ significantly from overseas aggregation services. Overseas aggregators focus on pure routing capabilities. Domestic platforms act more like unified‑entry marketplaces with billing built‑in; routing strategies are mostly closed‑source. Fail‑over logic depends on upper‑layer self‑hosted or tool‑side routing. Three critical selection criteria for domestic platforms: model‑coverage matching requirements, discount & quota‑curve alignment, and protocol compatibility with OpenAI / Anthropic formats (determines direct integration with Claude‑Code‑class agents).

Layer3: Managed Aggregation Platforms

Managed aggregation platforms are fully‑managed third‑party services. Developers submit requests to one single API entry‑point; the platform handles multi‑provider traffic forwarding, quota splitting and fail‑over. Representative services: OpenRouter, Vercel AI Gateway, Cloudflare AI Gateway, 4sapi. Users subscribe to multiple vendors under one key.

Advantages: Zero operation overhead; ready‑built multi‑vendor pool. Drawbacks: data passes through third‑party infrastructure; custom routing logic may be limited by platform capabilities; extra commission fees may apply. Teams with strict data‑sovereignty constraints need to review data‑residency clauses carefully.

Layer4: Intelligent‑Routing Algorithm Layer

Intelligent‑routing introduces classification or statistical models to decide target model selection. Simple requests get cheaper lightweight models; complex reasoning tasks go to flagship models, instead of purely static manual rules.

SolutionFormDecision InputPublic Evaluation MetricsStatus
RouteLLMOpen‑source framework, Python SDK & OpenAI‑compatible servicePrompt complexity classification; configurable cost‑vs‑accuracy thresholdsMT‑Bench evaluation: matching flagship‑model quality with 85 % cost reduction; 95 % quality retentionRepository last updated Aug‑2024; research prototype
Not DiamondCommercial API, oriented for programming‑agent scenariosPredict optimal target model for given input, executed inside gateway or Harness20 %‑55 % inference‑cost reduction; accuracy improvement reportedSOC2‑ISO‑27001 certified; commercial paid service
OpenRouter Auto RouterBuilt‑in OpenRouter feature, no extra‑costLight‑weight classifier categorizes prompts into ~30 task types; selects optimal model by cost/quality trade‑offNo independent public accuracy figuresBeta feature
LiteLLM Auto RouterEmbedded inside LiteLLM self‑hosted gateway, BetaMulti‑dimensional classifier: prompt metadata, token statistics, task‑type tags; four preset complexity grades(SIMPLE / MEDIUM / COMPLEX / REASONING)No independent public accuracy metrics; documentation warns accuracy may evolveBeta feature

Practical Deployment Scenarios

  1. SaaS multi‑tenant scenario: Use managed aggregation such as 4sapi as upstream. Combine self‑hosted gateway for fine‑grained per‑tenant quota splitting. Connect two‑to‑three official‑model APIs plus one aggregation‑provider for fail‑over. Apply weighted‑shuffle routing plus error‑based cool‑down. For heavy domestic‑model workloads, treat aggregation service as one upstream entry‑point and steer low‑priority traffic toward it.
  2. Cost‑first public‑facing applications: Adopt managed‑aggregation providers, set routing sort key to cost or ttft. Enable model‑level automatic fail‑over.
  3. Domestic enterprise compliance requirements (no cross‑border data outflow, audit requirements): Self‑host gateway as front‑end; only connect domestic‑model APIs and domestic aggregation endpoints. Apply Higress token‑throttling and consumer‑quota management to handle failure and cost control. New‑API works well for pure domestic‑model internal distribution.
  4. Highly uneven prompt‑complexity distribution: Activate intelligent‑router mode. Run LiteLLM Auto‑Router in observation mode for two weeks, collect cause= tag distribution inside logs, then decide whether to enable LLM‑based classification or stick to static rule‑based routing. Do not enable intelligent routing directly in production without observation cycles.

Ten‑Item Evaluation Checklist

Before adopting any multi‑model‑routing solution, validate each checklist item:

  1. Protocol compatibility: Support OpenAI Chat Completions and Anthropic Messages simultaneously? Determines compatibility with Claude‑Code / Codex‑style tool‑chains.
  2. Fail‑over trigger conditions: Which error codes trigger provider switching? Whether connection time‑outs count as failures. LiteLLM implements special cool‑down logic for status‑429 responses.
  3. Routing granularity: Whether you can allocate traffic according to user groups, model types, or request‑tags.
  4. Provider‑key mapping: One‑model supports multiple rotating API‑keys? Can traffic‑volume split ratio be defined per‑key.
  5. Cache capability: Prompt‑cache transmission support (Anthropic‑style marker headers); semantic‑cache capability. Cache can deliver up to 4‑fold cost‑reduction for workloads such as GLM‑5.3.
  6. Fee‑structure breakdown: Model input/output rates, recharge commission, subscription discounts, BYOK costs. OpenRouter charges 5.5 % commission; Cloudflare collects 5 %; Vercel offers zero‑commission tiers; 4sapi offers preferential pricing.
  7. Quota‑rule details: Whether subscription‑quota resets monthly; support for downgrading subscriptions.
  8. Data‑residency: Zero‑data‑retention options? OpenRouter zdr=true flag; Vercel no‑persistence toggle.
  9. Observability: Log retention period, log‑storage quota limits. Can logs expose resolved‑actual‑provider and real‑model identifiers after routing resolution.
  10. Maintenance vitality: Repository latest‑push timestamp. One‑API and RouteLLM show obvious stagnation; Portkey open‑source repository saw no commits for 5‑months at time‑of‑writing. Always verify activity before selection.

Frequently‑Asked‑Questions

Q: Are multi‑model‑routing and LLM gateway the same concept?
A: Not exactly. Gateway describes deployment form (unified entry‑point). Multi‑model‑routing is one capability inside gateways (model‑selection and provider‑switching). Tool‑side‑router and Agent‑Harness built‑in provider‑routing implement routing functions without being full‑featured gateways. Managed‑aggregation platforms act as both gateway and routing‑engine.

Q: How does weighted‑load‑balancing work in OpenRouter‑style implementations?
A: Probabilistic weighted sampling. Example: $1‑per‑million‑token provider gets selected nine‑times more frequently than $3‑per‑million‑token counterpart. order parameter switches from probabilistic sampling to strict sequential attempt order.

Q: Can self‑hosted gateways achieve high‑availability?
A: LiteLLM itself does not deliver native HA. Bifrost enterprise‑cluster‑mode, Kong and Higress offer mature multi‑replica deployment patterns. These are cloud‑native gateway‑extension capabilities, not core‑routing‑engine functions.

Q: Can domestic‑aggregation‑platforms serve as complete gateways?
A: Managed‑aggregation‑platforms mostly expose closed‑source routing logic without user‑configurable strategies. Use them as upstream back‑ends behind self‑hosted or tool‑side‑routing layers. Their value lies in discount procurement rather than flexible routing capability.

Q: Is intelligent‑routing worth deploying?
A: It brings value when over 70 % of total traffic consists of simple prompts and you can tolerate minor quality fluctuations. RouteLLM reports 85 %‑cost‑saving on MT‑Bench test‑set, but cannot guarantee identical effect for your real‑world prompt distribution. Always run observation‑mode first.

Q: One‑API vs New‑API?
A: New‑API inherits core One‑API logic and keeps active updates in 2026, adding format‑translation, cache‑billing and user‑rate‑limiting functions. One‑API repository stopped meaningful iteration after Jan‑2026.

Conclusion

Multi‑model‑routing selection should follow layer‑by‑layer logic: Developers use claude‑code‑router locally to manage coding‑agent switching and fallback. Production‑traffic for companies deploys self‑hosted gateways such as LiteLLM or Kong AI Gateway. Teams unwilling to operate infrastructure adopt managed‑aggregation platforms like OpenRouter, Vercel AI Gateway or 4sapi.

For self‑hosted gateways: Kong AI Gateway offers most comprehensive feature coverage. Higress and New‑API deliver best domestic‑model compatibility. For managed‑aggregation platforms: OpenRouter implements most complete load‑balance algorithms. 4sapi presents competitive pricing plans for domestic‑model discounted procurement.

If you adopt LiteLLM, pay attention: its default simple‑shuffle policy distributes traffic equally by provider count, not by token‑volume. Traffic proportion may deviate from expectation when model‑token consumption differs drastically. Always audit real‑world traffic metrics after launch.

International access: https://4sapi.com
Domestic access: https://4sapi.cn

Tags:LLM RoutingAI GatewayMulti Model AILiteLLMOpenRouterClaude CodeCodexModel Router

Recommended reading

Explore more frontier insights and industry know-how.