How to Build an LLM Router That Routes by Complexity
- Authors

- Name
- Nino
- Occupation
- Senior Tech Editor
An LLM router sits between your application and model providers, evaluating incoming requests dynamically to select the most appropriate model. Instead of binding every call to a single frontier model, a complexity-based router sends routine extraction or short factual tasks to cost-effective models while reserving high-end reasoning systems for complex tasks. This tutorial demonstrates how to configure and deploy a complexity router using Bifrost, an open-source LLM gateway built in Go, ensuring seamless integration without modifying your core application code.
Understanding LLM Routing Strategies
Most engineering teams start by hardcoding a single model per call site. While simple, this approach fails when a single endpoint—such as a developer chat assistant—receives both trivial greeting messages and highly intricate debugging requests. Over-provisioning leads to inflated API bills, while under-provisioning degrades response quality.
Modern API gateways solve this dilemma through dynamic routing. The table below compares common routing paradigms:
| Approach | How the Model is Chosen | Best Suited For | Key Limitation |
|---|---|---|---|
| Hardcoded | Developer selects one model in code | Uniform endpoints | Overpays for easy requests, underserves hard ones |
| Header/Metadata | CEL rule on headers, team, or request type | Routing by tenant, region, or environment | Blind to actual task difficulty |
| Complexity Router | Classifier assigns a tier; CEL rules map tiers to models | Chat, assistants, and agents with mixed difficulty | Adds one classification call per routed request |
Configuring the Decision Model Classifier
Bifrost v2.3.0 introduces native complexity routing, supporting two primary classifiers: a decision model and a semantic classifier. The decision model uses a dedicated lightweight LLM (such as Typesafe Jev by default) to evaluate the request against specific tier definitions.
To configure the decision model, update your gateway configuration file:
\{
"governance": \{
"complexity_analyzer_config": \{
"classifier": "decision