LLM Router: Route Requests by Complexity | Bifrost

Bifrost's LLM router classifies each request as simple, medium or complex and sends it to the model you pick for that tier. Open source and self-hosted.

BIFROST ROUTERS

LLM Router: Send Every Request to the Right Model

Bifrost classifies each request as Simple, Medium or Complex and sends it to the model you choose for that tier. Easy requests go to a fast model, hard ones to a stronger model, and your application code does not change.

Open Source | Self-Hosted | No Code Changes

In the example below, the semantic classifier tiers most requests, a decision model answers the one no phrase matches, a follow-up turn reuses its session tier, and each tier goes to its own model. [Get started free] [Read the docs]

  • Simple tier. groq · llama-3.1-8b-instant
  • Medium tier. openai · gpt-4o-mini
  • Complex tier. anthropic · claude-opus-4-5

LLM Router at a Glance

Complexity tiers
3 Simple, Medium and Complex, each with its own model.
Classifiers
3 A decision model, semantic matching, or an LLM.
Code changes
0 Applications keep calling the same API. The router picks the model.
Routing scopes
5 Virtual key, user, team, customer or global.

DEFINITION

What Is an LLM Router?

An LLM router decides which model answers each request, so the choice no longer lives in application code. In Bifrost, a router classifies every request by complexity and sends each tier to its own model. You can run several routers side by side, each with its own classifier settings, models and traffic figures.

  • Classifier. Assigns each request a tier: Simple, Medium or Complex. Choose a decision model, semantic matching, or an LLM classifier.
  • Models. The model each tier sends to. A tier can split traffic across several weighted models, each with its own API key and fallbacks.
  • Routing. Which requests the router takes: a scope, a priority, an optional CEL condition, and an on/off switch.

HOW IT WORKS

How Model Routing Works in Bifrost

Every request follows the same five steps. A router needs no routing rules of its own: once it is on, it classifies matching requests and routes them.

  1. 01Routing rules run first. The router takes the request as your existing routing rules left it.
  2. 02Routers are tried in scope order. Virtual key, user, team, customer, then global. Within a scope, the lower priority goes first, and only routers that are on are tried.
  3. 03The first matching router takes the request. Its condition must hold. Each router classifies a request at most once.
  4. 04The request goes to the tier's model. When a tier has several models, Bifrost makes a weighted pick between them.
  5. 05Key allowlists and load balancing run last. The virtual key's provider allowlist and load balancing still apply to the routed request.

CLASSIFIERS

Three Classifiers: Decision Model, Semantic or LLM

Each router uses one classifier, and you can combine them: run semantic routing first and let a decision model answer only the requests no phrase matches confidently. [Choosing a classifier]

Decision modelSemanticLLM classifier
How it decidesA decision model picks the tier whose definition, signals and examples fit bestEmbeds the request and takes the tier of the nearest reference phraseA chat model reads the request with a classification prompt and replies with a tier
What you maintainNothing to start. Optionally a definition, signals and examples per tierReference phrases per tier: 150 shipped, up to 750Nothing to start. Optionally the prompt
Cost per requestOne decision call. Typesafe Jev typically answers in 600 to 800 msOne embedding call plus a vector lookup, usually much faster than a decision callOne chat completion, the slowest of the three
WarmupNonePhrases are embedded in the background after each changeNone
Best whenYou want good tiers without curating data, or traffic is variedTraffic is predictable, latency matters most, and you want exact control through examplesYou want to describe tiers in your own words and can afford a chat call per request

Complexity Tiers You Can Edit

The decision model reads a definition, signals and examples for every tier on every request, and you can rewrite any of them.

Ships with working defaults for Simple, Medium and Complex. It judges the work, not the wording: length, format and tone do not count. Typesafe Jev is the default decision model, with OpenAI, Gemini, OpenRouter, Cloudflare, Perplexity, Ollama, Azure, Databricks or a custom provider as alternatives. A confidence threshold leaves low-confidence requests on the model they asked for. [Tier guidance]

Semantic Routing with Reference Phrases

The semantic classifier embeds the latest user message and uses the tier of the nearest reference phrase.

150 reference phrases shipped, 50 per tier, and up to 750 of your own. A similarity floor decides when the nearest phrase is not close enough. A decision model or an LLM can answer as a fallback when no phrase matches. System prompts and assistant replies are never embedded. [Semantic classifier]

One Model per Tier, with Weights and Fallbacks

Pick the model for each tier, or split a tier across several.

Each target sets a provider, a model, or both, with an optional API key. Weights split a tier across models, and the weights in a tier sum to 1. Fallbacks are set per target, so each tier has its own chain. Leave the provider or the model empty to keep what the request asked for. [Router models] [LLM gateway] [Adaptive Routing]

Session-Aware Routing

Keep a conversation on a model strong enough for its hardest turn.

A session's tier can rise from Simple to Medium to Complex, but never falls. Once a session reaches Complex, Bifrost stops classifying it. Sessions are identified by the x-bf-session-id header, and Claude Code and Codex sessions are recognized automatically. Only the tier is stored, under a hashed session ID, for 24 hours of inactivity. [Session-aware routing]

Logs, Traces and Metrics for Every Routing Decision

See which router took a request, the tier it got, and how that tier was decided.

Each log entry records the router, the tier and the mechanism: semantic, decision, llm, session or skipped. Filter request logs by router and by tier. Span attributes carry the tier, mechanism and score into your traces. Prometheus counters track classifier requests and their cost. [Router observability] [AI observability]

SETUP

Set Up an LLM Router in Four Steps

Use the dashboard, the `/api/routing/model-routers` API, or a `model_routers` entry in `config.json`. [Routers configuration docs]

  1. 01Create a router. In the dashboard, open Models, then Routers, then New router. Give it a name and pick a classifier: Decision model, Semantic or LLM classifier.
  2. 02Pick a model for each tier. On the Models tab, set a provider and model for Simple, Medium and Complex. Add weights to split a tier across models, and fallbacks per target.
  3. 03Set the routing. Choose a scope and priority, and add a CEL condition if the router should only take some requests. An empty condition takes every request in scope.
  4. 04Test, then turn it on. New routers start off. Send sample requests to the classify endpoint to see the tier and model each would get, then switch the router on.
The three-tier example from the Routers docs: one decision-model router with a different provider for each tierconfig.json
{
  "model_routers": [
    {
      "id": "general",
      "name": "General",
      "classifier": "decision",
      "decision": { "provider": "typesafe", "model": "jev-latest" },
      "session": { "enabled": true },
      "keywords": {
        "simple_keywords": ["fix the grammar in this sentence."],
        "medium_keywords": ["apply a standard method to this technical question."],
        "complex_keywords": ["design a solution under several competing constraints."]
      },
      "targets": [
        { "tier": "SIMPLE", "provider": "groq", "model": "llama-3.1-8b-instant", "weight": 1 },
        { "tier": "MEDIUM", "provider": "openai", "model": "gpt-4o-mini", "weight": 1 },
        { "tier": "COMPLEX", "provider": "anthropic", "model": "claude-opus-4-5", "weight": 1 }
      ],
      "routing": { "enabled": true, "scope": "global", "priority": 0 }
    }
  ]
}

COVERAGE

Which Requests the Router Can Classify

The router classifies text requests. Anything it cannot classify keeps the model it asked for.

  • Classified. Chat Completions and messages-style requests with text-only user content. Text Completions with a prompt. Responses API requests with text-only input. Anthropic Messages, Bedrock Converse and Gemini requests with text-only user input.
  • Not classified. Image generation, embeddings, rerank, OCR, audio, video and count-tokens requests. User content that mixes text with image, file or audio blocks. Requests with only a system or developer message. Requests in large payload mode, which skip routers entirely.

Route Your Own Traffic by Complexity

Run Bifrost with `npx -y @maximhq/bifrost`, create a router, and test it on sample requests before it takes any traffic. [Get started free] [Book a demo]

Run the gateway locally
npx -y @maximhq/bifrost

Open Source & Enterprise

OSS Features

  • 01Model Catalog. Access 25+ providers and 10,000+ AI models through a unified interface. Also supports custom deployed models.
  • 02Budgeting. Set spending limits and track costs across teams, projects, and models.
  • 03Provider Fallback. Automatic failover between providers keeps your applications available when a provider fails.
  • 04MCP Gateway. Centralize all MCP tool connections, governance, security, and auth. Your AI can safely use MCP tools with centralized policy enforcement. [MCP Gateway resource]
  • 05Virtual Key Management. Create different virtual keys for different use cases with independent budgets and access control.
  • 06Unified Interface. One consistent API for all providers. Switch models without changing code.
  • 07Drop-in Replacement. Replace your existing SDK with just one line change. Compatible with OpenAI, Anthropic, LiteLLM, Google GenAI, LangChain, and more. [Drop-in replacement docs]
  • 08Built-in Observability. Out-of-the-box OpenTelemetry support. Built-in dashboard for quick visibility without complex setup.
  • 09Community Support. Active Discord community with responsive support and regular updates.

Enterprise Features

  • 01Governance. SAML support for SSO and role-based access control with policy enforcement for team collaboration. [Governance resource]
  • 02Adaptive Load Balancing. Automatically optimizes traffic distribution across provider keys and models based on real-time performance metrics.
  • 03Cluster Mode. High availability deployment with automatic failover and load balancing. Peer-to-peer clustering where every instance is equal.
  • 04Alerts. Real-time notifications for budget limits, failures, and performance issues on Email, Slack, PagerDuty, Teams, Webhook, and more.
  • 05Log Exports. Export and analyze request logs, traces, and telemetry data from Bifrost with enterprise-grade data export for compliance, monitoring, and analytics.
  • 06Audit Logs. Comprehensive logging and audit trails for compliance and debugging.
  • 07Vault Support. Secure API key management with HashiCorp Vault, AWS Secrets Manager, Google Secret Manager, and Azure Key Vault integration.
  • 08VPC Deployment. Deploy Bifrost within your private cloud infrastructure with VPC isolation, custom networking, and enhanced security controls. [Enterprise deployment resource]
  • 09Guardrails. Automatically detect and block unsafe model outputs with real-time policy enforcement and content moderation across all agents. [Guardrails resource]

FAQ

What is an LLM router?

An LLM router is a layer that decides which model should answer each request, instead of the application hard-coding one model. Bifrost's router classifies every request as Simple, Medium or Complex and sends it to the model you chose for that tier, so easy requests go to a fast, low-cost model and hard ones go to a stronger model. For a longer explainer, read [what an LLM router is and how model routing works](https://www.getmaxim.ai/articles/what-is-an-llm-router-how-model-routing-works/).

How does Bifrost decide how complex a request is?

You pick one of three classifiers per router. A decision model compares the request with a definition, signals and examples for each tier. The semantic classifier embeds the request and takes the tier of the nearest reference phrase. An LLM classifier asks a chat model to reply with a tier. All three judge the latest user request, and the decision model is instructed to judge the work rather than the wording, so length, format and tone do not count. Details are in the [Routers docs](https://docs.getbifrost.ai/features/routers#choosing-a-classifier).

Is there an open source LLM router?

Bifrost is an open-source AI gateway under Apache 2.0, and routers are documented as a core gateway feature that you configure in the dashboard, the API or config.json. The [Routers docs](https://docs.getbifrost.ai/features/routers) mark a few parts as Enterprise: the user routing scope in the dashboard, the Routers permission and data access control, and audit log events. The source is on [GitHub](https://github.com/maximhq/bifrost).

How much latency does LLM routing add?

The classifier call sits on the request path, so its latency is added to every classified request. The default decision model, Typesafe Jev, typically answers in 600 to 800 ms. The semantic classifier makes one embedding call plus a vector lookup and is usually much faster. An LLM classifier is the slowest of the three. Each has a timeout (1.5s for the decision model and semantic, 4s for the LLM classifier by default), and a request that times out keeps the model it asked for.

What is semantic routing?

Semantic routing picks a route by meaning instead of keywords, and a semantic router is the component that does it. In Bifrost that is the semantic classifier: it embeds the latest user message, compares it with reference phrases you keep for each tier, and uses the tier of the nearest phrase. It ships with 150 phrases, 50 per tier, and accepts up to 750. When no phrase matches above your similarity floor, a decision model or an LLM can answer as a fallback.

What happens when a request cannot be classified?

The request keeps the model it asked for and is served normally. That happens when no router matches, the classifier fails, times out or returns an answer below your confidence threshold, or the tier has no model. The request log records the reason, with complexity_mechanism set to skipped.

Do I need to change my application to use the router?

No. A router that is on classifies matching requests and sends each one to its tier's model with no application changes. Applications keep calling Bifrost through the same OpenAI-compatible API, and the [LLM gateway](/llm-gateway) handles keys, fallbacks and load balancing after the router has chosen a model.