Overview
The Complexity Router analyzes each incoming request and assigns it one of four tiers - Simple, Medium, Complex, or Reasoning - based on the content of the latest user message, conversation history, and system prompt. The result is exposed as a flat string variable (complexity_tier) in Bifrost’s CEL routing engine, so you can write routing rules like:

How it works
Scoring dimensions
Every request produces a score between 0.0 and 1.0. The analyzer starts with a weighted score across five dimensions detected by scanning the last user message:| Dimension | Weight | What it measures |
|---|---|---|
| Code presence | 30% | Code, debugging, and programming artifacts |
| Reasoning markers | 25% | Analytical and multi-step reasoning language |
| Technical terms | 25% | Architecture, infra, and operational terminology |
| Token count | 10% | Prompt length (longer → higher score) |
| Simple indicators | −5% | Greetings, trivial queries (dampener, subtracted) |
System prompt contribution
The system prompt is scanned for code, technical, and simple signals, and its contribution is weighted at 25% of the user-message signal for those three dimensions. This provides soft lexical context — for example, a system prompt describing a coding assistant nudges code scores up — but it never drives the token count, reasoning markers, or tier override.Conversation context blending
For multi-turn conversations, the score blends the current message with history from up to the last 10 user turns (recency-weighted: earlier turns count less):- Default blend: 60% last message + 40% conversation history
- Referential follow-up blend: 35% last message + 65% conversation history
max(last_message_score, weighted_blend) — the current message always sets a floor.
Output complexity floor
Some requests are hard not because the reasoning is especially deep, but because the output being asked for is broad or exhaustive. Prompts like “list every AWS service and explain each one with examples” can receive a built-in score floor even when the normal weighted score is only moderate. The analyzer looks for internal markers such as exhaustive enumeration (“list every”, “all possible”), comprehensiveness cues (“comprehensive”, “in detail”), and elaboration asks (“explain each”, “with examples”). Limiting qualifiers like “briefly”, “top 5”, or “keep it short” reduce this boost. This output-complexity floor is built in — it is not currently exposed as a user-configurable keyword list.Reasoning override
When two or more reasoning keywords are detected in the last user message, the tier is forced to Reasoning regardless of the numeric score. The same override applies when one strong reasoning keyword appears alongside strong code or technical signals. This handles prompts like “step by step, explain why the authentication flow fails” that would score moderately on each individual dimension but clearly require deep reasoning.Tier classification
The final score maps to a tier using configurable boundaries (defaults shown):| Tier | Score range (defaults) | Typical requests |
|---|---|---|
| Simple | < 0.15 | Greetings, definitions, simple lookups |
| Medium | 0.15 – 0.35 | General questions, short explanations |
| Complex | 0.35 – 0.60 | Technical questions, code help, multi-step tasks |
| Reasoning | ≥ 0.60 (or override) | Analysis, architecture decisions, root-cause investigation |

Configuration
Tier boundaries
Adjust where the score thresholds fall to match your traffic and model lineup.- Web UI
- API
- config.json
Navigate to Complexity Router in the sidebar.The Complexity Spectrum bar updates live as you type boundary values, so you can see how your traffic would be distributed before saving.

- Enter a value between 0 and 1 for each boundary.
- Boundaries must be strictly increasing:
simple_medium<medium_complex<complex_reasoning. - Click Save changes to apply immediately (hot-reloaded, no restart required).
- Click Restore defaults to reset all boundaries and keyword lists to factory values.
Keyword lists
Each list controls a different part of the scoring signal. Understanding what they do helps you tune routing for your domain.The default keyword lists are tuned for common request patterns and are a good starting point for most deployments. For domain-specific traffic, add or remove keywords based on the prompts your users actually send so the tiers match your routing strategy.
- Web UI
- About each list

Routing with complexity_tier
Once the analyzer is configured, use complexity_tier as a variable in any CEL routing rule expression. Bifrost evaluates it as a plain string.
complexity_tier is not a special standalone rule type. In the Routing Rules builder, it behaves like any other field, so you can combine it with headers, request type, team/customer scope, budgets, and other predicates in the same rule or nested rule group.
Complexity Router only exposes
complexity_tier; it does not create rules automatically. Add rules for the tiers you want to route. For deterministic four-tier routing, create rules for Simple, Medium, Complex, and Reasoning.Available operators
| Operator | CEL syntax | Example |
|---|---|---|
| Equal | == | complexity_tier == "REASONING" |
| Not equal | != | complexity_tier != "SIMPLE" |
| In list | in | complexity_tier in ["COMPLEX", "REASONING"] |
| Not in list | !(x in [...]) | !(complexity_tier in ["SIMPLE", "MEDIUM"]) |
Combining with other rule conditions
You can mix complexity with any other routing condition the CEL builder supports:Setting up a complexity-based routing rule
The best first rollout is usually a single Reasoning rule. It is easy to validate, has the smallest blast radius, and leaves Simple, Medium, and Complex traffic on your existing routing path.- Go to Routing Rules in the sidebar.
- Create a new rule and open the CEL builder.
- Add a condition: field = Complexity Tier, operator = =, value = Reasoning.
- Set the target provider and model to your strongest reasoning model.
- Save and enable the rule.

Use case examples
Start with a Reasoning carve-out
Route only frontier-worthy requests to your strongest model and let everything else keep using your existing routing:Full four-tier ladder
Route every tier explicitly when you want deterministic model selection across the full spectrum:Roll out to one team first
Test complexity routing with a single team before enabling it globally:Observability
Complexity analysis is recorded in the routing log for every request where analysis ran. In the log detail view, look at the Routing Decision Logs section backed byrouting_engine_logs.

Complexity: tier=REASONING score=0.38 words=25. Logs use the emitted uppercase tier string, while the UI displays the same tier as normal-case text. This lets you audit how traffic is being distributed and spot mis-classifications to tune thresholds or keyword lists.
Troubleshooting
Rule not matching when complexity_tier is set
If the routing rule usescomplexity_tier and the request is not matching, make sure the request contains analyzable user text. A system prompt by itself is not enough — the analyzer needs a text-bearing user prompt to classify.
If analysis is unavailable (for example the body could not be parsed, or the user content is not text-only), complexity_tier is treated as unknown by the CEL evaluator. The rule does not match and evaluation falls through to the next rule. This is intentional: complexity rules silently degrade rather than blocking requests.
Which request types are supported
Complexity routing currently runs only for text-bearing request families. Supported inputs include:- Chat Completions and other messages-style requests with text-only user content
- Text Completions requests using
prompt - Responses API requests using text-only
input - Anthropic Messages, Bedrock Converse, and Gemini
contents/systemInstructionshapes when they carry text-only user input
- Image generation, embeddings, rerank, OCR, audio/speech/transcription, video, or count-tokens requests
- Chat or Responses requests where user content mixes text with image, file, or audio blocks
- Requests that contain only system or developer text and no user text
All traffic classified as Reasoning
The reasoning keywords list is the most common cause. Check if any broad single-word terms were added (e.g. “explain”, “analyze”). The override gate fires when two or more strong reasoning keywords match — a broad list will trigger it on most prompts. Replace single-word terms with specific multi-word phrases.Want to test threshold changes without affecting live traffic
Use the Discard changes button to revert unsaved edits, or Restore defaults to return to factory settings. Changes only take effect on save.Next Steps
Routing Rules
Full reference for CEL expressions, scope hierarchy, and rule chaining
Virtual Keys
Scope complexity routing rules to specific teams, customers, or virtual keys
Budget & Limits
Combine complexity routing with budget limits for cost-optimal routing
Provider Routing
Understand how complexity routing fits into the full request routing pipeline

