Quality router
The quality router is for teams that want cheaper routing they can explain. It reuses the complexity router's classification to decide how hard a request is, maps that complexity to a quality tier through a table you control, and sends the request to the candidate deployment that declares that tier. Unlike the adaptive router it learns nothing, so the same prompt always goes to the same model and an auditor can follow every decision. It is configured as a model_list entry whose model is auto_router/quality_router and is part of the free gateway, within the one router per capability limit of an unlicensed gateway.
A real-world scenario
A legal team wants translation and summarisation requests on claude-haiku-5-5 and everything that needs judgement on claude-sonnet-5-5, and it must be able to say afterwards why a request went where. The admin declares quality_tier: 1 on the Haiku deployment with the keywords summarize and translate, quality_tier: 3 on the Sonnet deployment, and creates a quality router tiered that maps simple and medium requests to tier 1 and complex and reasoning requests to tier 3. A request containing "translate" goes straight to Haiku without classification, a long contract question lands in tier 3 on Sonnet, and the spend log records router_type: quality with the tier for each.
Step by step
In the Admin UI
- Open
/ui/models-and-endpointsas a proxy admin. For each candidate deployment open its detail view from the Deployed Models table and, under Model Info, addspanway_routing_preferenceswithquality_tierand optionallykeywordsandorder, then save. - Add the router itself in
config.yamlas shown below and restart the gateway, because the Add Auto Router dialog only builds complexity routers. After the restart the router appears on the Auto-Routers tab with TypeQualityand its model pool under Routes to. - Give the keys or teams that should use it access to the model
tiered. - Open
/ui/cost-optimization, pick Auto-Router, and watchtieredappear in Router usage and savings once traffic flows.
With curl
model_list:
- model_name: claude-haiku-5-5
spanway_params:
model: anthropic/claude-haiku-5-5
api_key: os.environ/ANTHROPIC_API_KEY
model_info:
input_cost_per_token: 0.0000008
spanway_routing_preferences:
quality_tier: 1
keywords: ["summarize", "translate"]
- model_name: claude-sonnet-5-5
spanway_params:
model: anthropic/claude-sonnet-5-5
api_key: os.environ/ANTHROPIC_API_KEY
model_info:
input_cost_per_token: 0.000003
spanway_routing_preferences:
quality_tier: 3
order: 1
- model_name: tiered
spanway_params:
model: auto_router/quality_router
quality_router_default_model: claude-haiku-5-5
quality_router_config:
available_models: ["claude-haiku-5-5", "claude-sonnet-5-5"]
complexity_to_quality:
SIMPLE: 1
MEDIUM: 1
COMPLEX: 3
REASONING: 3
curl -i -X POST http://localhost:4000/v1/chat/completions \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "tiered", "messages": [{"role": "user", "content": "Translate this clause into German: ..."}]}'
Expected result
The response comes from claude-haiku-5-5 because the keyword translate matched. The headers say why: x-spanway-quality-router-model names the model, x-spanway-quality-router-tier the tier, x-spanway-quality-router-via whether a keyword or the classifier decided, x-spanway-quality-router-keyword the keyword that matched and x-spanway-quality-router-complexity the complexity tier, see routing decision headers. A request with no keyword is classified, mapped to a quality tier and sent to the highest ranked deployment that declares that tier. When no deployment declares that tier, the router rounds up to the next higher tier that has one, then down to the closest lower tier. quality_router_default_model is used only when no candidate declares any tier or the request has no user message. The spend log row carries router_type: quality, the tier and the model, costed at that model's price, and the cost optimisation page lists the router next to the others.
Settings
| Setting | Meaning |
|---|---|
quality_router_config.available_models | Candidate model groups. Each must declare quality_tier in model_info.spanway_routing_preferences. |
quality_router_config.complexity_to_quality | Map from complexity tier name to quality tier. The default is SIMPLE: 1, MEDIUM: 2, COMPLEX: 3, REASONING: 4. |
quality_router_default_model, or quality_router_config.default_model | Optional. Used when no candidate declares any tier or the request has no user message. Without it those requests fail. |
spanway_routing_preferences.quality_tier | The tier a deployment satisfies. |
spanway_routing_preferences.keywords | Case insensitive substrings that, when present in the user message, route to this deployment and skip classification. |
spanway_routing_preferences.order | Tie breaker between deployments at the same tier. Lower wins. |
When several deployments qualify, the order is highest quality tier first, then explicit order, then lowest input_cost_per_token, then model name.
Errors
| What you see | Why | Fix |
|---|---|---|
The first request through the router fails with QualityRouter: the following available_models are not present in the router's model_list (or are missing routing preferences): [...] | The candidates are checked on the first request, not at startup, and a model in available_models is missing or has no spanway_routing_preferences. | Add the model or its quality_tier. |
QualityRouter: no model available for quality tier 3 and no default_model configured | No candidate declares any tier and no default model is set. | Declare quality_tier on the candidates, or set quality_router_default_model. |
| Requests land one tier higher than expected | No deployment declares the mapped tier, so the router rounded up. | Declare a deployment at that tier or change complexity_to_quality. |
| A request lands on the wrong deployment | A keyword matched before classification ran, or two deployments share a tier without order. | Narrow the keywords, or set order. |
400 Invalid model name passed in model=tiered | The key or team may not call the router. | Add tiered to its models. |
| A second quality router fails at start up | Without a license one router per capability is allowed. | Remove one, or add a license with the auto_router feature. |
Related
- Auto routing explains the complexity classification this router reuses.
- Adaptive router is the learning alternative.
- Cost optimisation reports the router's usage and savings.
- Models + Endpoints page lists the routers. A router defined in
config.yamlcannot be deleted there or through/model/delete, remove it from the file and restart the gateway.