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.
Incoming request
Find the cause of a difficult, previously unexplained failure
Router
Or use an LLM classifier
[ 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.
Assigns each request a tier: Simple, Medium or Complex. Choose a decision model, semantic matching, or an LLM classifier.
The model each tier sends to. A tier can split traffic across several weighted models, each with its own API key and fallbacks.
Which requests the router takes: a scope, a priority, an optional CEL condition, and an on/off switch.
[ 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.
The router takes the request as your existing routing rules left it.
Virtual key, user, team, customer, then global. Within a scope, the lower priority goes first, and only routers that are on are tried.
Its condition must hold. Each router classifies a request at most once.
When a tier has several models, Bifrost makes a weighted pick between them.
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.
[ 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 |
The decision model reads a definition, signals and examples for every tier on every request, and you can rewrite any of them.
Simple
Direct work answerable from the request itself or common knowledge in one straightforward step.
e.g. Extract a value stated in a passage
Medium
Focused work that needs subject-specific knowledge, or an established method applied across a few steps.
e.g. Solve a routine multi-step word problem
Complex
Advanced expertise combined with substantial reasoning, derivation, design, or synthesis.
e.g. Design an efficient solution where tradeoffs matter
[ Definition, signals and examples per tier ]
The semantic classifier embeds the latest user message and uses the tier of the nearest reference phrase.
[ 150 reference phrases shipped, 50 per tier ]
Pick the model for each tier, or split a tier across several.
[ One or more weighted models per tier ]
Keep a conversation on a model strong enough for its hardest turn.
[ A session keeps the highest tier it reached ]
See which router took a request, the tier it got, and how that tier was decided.
[ Logged with every routed request ]
[ SETUP ]
Use the dashboard, the /api/routing/model-routers API, or a model_routers entry in config.json.
In the dashboard, open Models, then Routers, then New router. Give it a name and pick a classifier: Decision model, Semantic or LLM classifier.
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.
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.
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.
{
"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 }
}
]
}The three-tier example from the Routers docs: one decision-model router with a different provider for each tier.
[ COVERAGE ]
The router classifies text requests. Anything it cannot classify keeps the model it asked for.
Run Bifrost with npx -y @maximhq/bifrost, create a router, and test it on sample requests before it takes any traffic. Read more on how model routing cuts token costs.
[ WHAT'S NEXT ]
Continue with governance, guardrails, MCP, and the rest of the resource library.
[ BIFROST FEATURES ]
Everything you need to run AI in production, from free open source to enterprise-grade features.
SAML support for SSO and Role-based access control and policy enforcement for team collaboration.
Automatically optimizes traffic distribution across provider keys and models based on real-time performance metrics.
High availability deployment with automatic failover and load balancing. Peer-to-peer clustering where every instance is equal.
Real-time notifications for budget limits, failures, and performance issues on Email, Slack, PagerDuty, Teams, Webhook and more.
Export and analyze request logs, traces, and telemetry data from Bifrost with enterprise-grade data export capabilities for compliance, monitoring, and analytics.
Comprehensive logging and audit trails for compliance and debugging.
Secure API key management with HashiCorp Vault, AWS Secrets Manager, Google Secret Manager, and Azure Key Vault integration.
Deploy Bifrost within your private cloud infrastructure with VPC isolation, custom networking, and enhanced security controls.
Automatically detect and block unsafe model outputs with real-time policy enforcement and content moderation across all agents.
[ SHIP RELIABLE AI ]
Change just one line of code. Works with OpenAI, Anthropic, Vercel AI SDK, LangChain, and more.
[ FAQ ]
Common questions about routing LLM requests by complexity.
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.
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.
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 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.
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.
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.
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.
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 handles keys, fallbacks and load balancing after the router has chosen a model.