---
title: "LLM Router: Route Requests by Complexity | Bifrost"
description: "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."
url: "https://www.getmaxim.ai/resources/llm-router"
markdown: "https://www.getmaxim.ai/resources/llm-router.md"
---

# 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.

## Important Links

- [View MCP Gateway](https://www.getmaxim.ai/resources/mcp-gateway.md)
- [Features](https://www.getmaxim.ai/bifrost/#features)
- [Enterprise](https://www.getmaxim.ai/enterprise)
- [Pricing](https://www.getmaxim.ai/pricing.md)
- [Docs](https://docs.getbifrost.ai)
- [GitHub](https://github.com/maximhq/bifrost)
- [Book a Demo](https://www.getmaxim.ai/book-a-demo)

## LLM Router: Send Every Request to the Right Model

_BIFROST ROUTERS_

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.

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

- [Get started free](https://github.com/maximhq/bifrost)
- [Read the docs](https://docs.getbifrost.ai/features/routers)

## LLM Router at a Glance

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

## What Is an LLM Router?

_DEFINITION_

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 Model Routing Works in Bifrost

_HOW IT WORKS_

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. **01 - Routing rules run first.** The router takes the request as your existing routing rules left it.

2. **02 - Routers 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. **03 - The first matching router takes the request.** Its condition must hold. Each router classifies a request at most once.

4. **04 - The request goes to the tier's model.** When a tier has several models, Bifrost makes a weighted pick between them.

5. **05 - Key allowlists and load balancing run last.** The virtual key's provider allowlist and load balancing still apply to the routed request.

> A request keeps the model it asked for when no router matches, the router cannot classify it, or the tier has no model.

## Three Classifiers: Decision Model, Semantic or LLM

_CLASSIFIERS_

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.

|  | Decision model | Semantic | LLM classifier |
| --- | --- | --- | --- |
| How it decides | A decision model picks the tier whose definition, signals and examples fit best | Embeds the request and takes the tier of the nearest reference phrase | A chat model reads the request with a classification prompt and replies with a tier |
| What you maintain | Nothing to start. Optionally a definition, signals and examples per tier | Reference phrases per tier: 150 shipped, up to 750 | Nothing to start. Optionally the prompt |
| Cost per request | One decision call. Typesafe Jev typically answers in 600 to 800 ms | One embedding call plus a vector lookup, usually much faster than a decision call | One chat completion, the slowest of the three |
| Warmup | None | Phrases are embedded in the background after each change | None |
| Best when | You want good tiers without curating data, or traffic is varied | Traffic is predictable, latency matters most, and you want exact control through examples | You want to describe tiers in your own words and can afford a chat call per request |

- [Choosing a classifier](https://docs.getbifrost.ai/features/routers#choosing-a-classifier)

## 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](https://docs.getbifrost.ai/features/routers#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](https://docs.getbifrost.ai/features/routers#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](https://docs.getbifrost.ai/features/routers#models-targets)
- [LLM gateway](https://www.getmaxim.ai/llm-gateway)
- [Adaptive Routing](https://www.getmaxim.ai/resources/adaptive-routing.md)

## 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](https://docs.getbifrost.ai/features/routers#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](https://docs.getbifrost.ai/features/routers#observability)
- [AI observability](https://www.getmaxim.ai/ai-observability)

## Set Up an LLM Router in Four Steps

_SETUP_

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

1. **01 - Create 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. **02 - Pick 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. **03 - Set 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. **04 - Test, 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 tier

_config.json_

```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 }
    }
  ]
}
```

- [Routers configuration docs](https://docs.getbifrost.ai/features/routers#configuration)

## Which Requests the Router Can Classify

_COVERAGE_

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.

## Related Bifrost Resources

_WHAT IS NEXT_

- **Enterprise - Adaptive Routing:** Send each request to the healthiest provider and key, and hold keys a provider refuses. [Adaptive Routing](https://www.getmaxim.ai/resources/adaptive-routing.md).
- **Guide - Buyer's Guide:** Compare gateway platforms on deployment, governance, MCP, and pricing. [Buyer's Guide](https://www.getmaxim.ai/resources/buyers-guide.md).
- **Free OSS - OSS for Startups:** Run the open-source gateway in production with failover and caching. [OSS for Startups](https://www.getmaxim.ai/resources/oss-for-startups.md).

## 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.

### Run the gateway locally

```bash
npx -y @maximhq/bifrost
```

- [Get started free](https://github.com/maximhq/bifrost)
- [Book a demo](https://www.getmaxim.ai/book-a-demo)

## Features

### OSS Features

- **01 - Model Catalog:** Access 25+ providers and 10,000+ AI models through a unified interface. Also supports custom deployed models.
- **02 - Budgeting:** Set spending limits and track costs across teams, projects, and models.
- **03 - Provider Fallback:** Automatic failover between providers keeps your applications available when a provider fails.
- **04 - MCP Gateway:** Centralize all MCP tool connections, governance, security, and auth. Your AI can safely use MCP tools with centralized policy enforcement. [MCP Gateway resource](https://www.getmaxim.ai/resources/mcp-gateway.md).
- **05 - Virtual Key Management:** Create different virtual keys for different use cases with independent budgets and access control.
- **06 - Unified Interface:** One consistent API for all providers. Switch models without changing code.
- **07 - Drop-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](https://docs.getbifrost.ai/features/drop-in-replacement).
- **08 - Built-in Observability:** Out-of-the-box OpenTelemetry support. Built-in dashboard for quick visibility without complex setup.
- **09 - Community Support:** Active Discord community with responsive support and regular updates.

### Enterprise Features

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

## 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.

## Related Resources

- [Source: LLM Router](https://www.getmaxim.ai/resources/llm-router.md)
- [Docs: Routers](https://docs.getbifrost.ai/features/routers)
- [Docs: Bifrost docs](https://docs.getbifrost.ai)
- [GitHub: maximhq/bifrost](https://github.com/maximhq/bifrost)
- [Pricing: Bifrost pricing](https://www.getmaxim.ai/pricing.md)
- [Enterprise: Bifrost enterprise](https://www.getmaxim.ai/enterprise)
- [Book a Demo: Bifrost demo](https://www.getmaxim.ai/book-a-demo)
- [Resources: Bifrost resources](https://www.getmaxim.ai/resources.md)

---

*This is a markdown version of [https://www.getmaxim.ai/resources/llm-router](https://www.getmaxim.ai/resources/llm-router) for AI/LLM consumption.*
