Auto-Switch (complexity routing)
Auto-Switch is the routing engine — the reason Coco Router exists.
How a request flows
app request (model: anything)
│
├─ non-chat endpoint (audio/embeddings)? → pass through unchanged
├─ auto key, or model is auto/smart-ai/default?
│ │ no → pass through unchanged
│ ▼ yes
│ classifier (gpt-4o-mini) reads the prompt → SIMPLE | MEDIUM | COMPLEX | REASONING
│ ▼
│ tier's model pool: try model #1 → on error/429 fall back to #2 → #3 …
│ ▼
└─ response, with ai_router: {tier, model} injected in the body
and x-ai-router-tier / x-ai-router-model response headers
The tiers and current defaults
| Tier | Fires for | Default model pool (first = primary) |
|---|---|---|
SIMPLE | greetings, basic facts, trivial Q&A | llama-3.3-70b-instruct:free → llama-3.1-8b-instruct → gemini-2.5-flash-lite |
MEDIUM | everyday writing, summaries, simple code | gemini-2.5-flash → deepseek-chat |
COMPLEX | non-trivial coding, SQL, system design | claude-sonnet-4 → gpt-4o |
REASONING | math/proofs, multi-step logic, planning | deepseek-r1 → o3-mini |
(All via OpenRouter model ids; the pools are fully editable in the Control Panel.)
Multi-model fallback
Each tier holds a priority list. The router requests the first model; if it fails or rate-limits (free models frequently 429), it fails fast — no retries on the same model — and falls to the next in the list. A typical fallback completes in ~3 seconds. This is what makes "free model first, cheap paid model as backup" a safe production pattern.
The classifier
- Default judge:
gpt-4o-mini(configurable in the Control Panel). - Cost ≈ $0.00002 per classification; latency ≈ 200–400 ms.
- The judge sees only the latest user message (truncated to 4,000 chars).
- If classification fails for any reason, the request defaults to the
MEDIUMtier — requests never fail because of the judge.
Reading routing decisions
Every routed response carries the decision in two places:
- Response body — an
ai_routerobject:{"tier": "COMPLEX", "model": "openrouter/anthropic/claude-sonnet-4"}. The body'smodelfield is also rewritten to the real backend model. - Response headers —
x-ai-router-tierandx-ai-router-model(server-to-server; browsers cannot read custom headers cross-origin, hence the body field).
Cost impact
Routing means a trivial question costs fractions of a cent on Llama-8B (~$0.000002/request) instead of frontier-model prices, while hard tasks still get Claude-class quality. Typical blended savings versus sending everything to a frontier model: 40–80%, depending on traffic mix.