Skip to content
Docs

Smart routing (model "auto")

Send model: "auto" and the router chooses a model per request: cheap and fast for easy prompts, larger for hard ones. The buyer pays the price of the model that actually answered. It is a port of AgentWatch’s complexity router.

Each prompt is classified into task · subject · complexity (1–5) · language by two tiers:

  1. Heuristics — fast text signals; always on, no cost.
  2. Classifier — AgentWatch’s fine-tuned DistilBERT-multilingual, run in-process on the CPU with pip install "lifeboatrouter[classifier]" and the model files in ~/.lifeboat_router/router-model/. Nothing about the prompt leaves the machine.

Coding-agent scaffolding (IDE state, file listings an agent wraps around what the user typed) is stripped before classifying, so “hello” inside a 60k-token wrapper is still treated as “hello”.

The admin’s map on the Routing page is consulted most-specific-first:

Key Example Meaning
task:complexity coding:5 hard coding
domain:complexity legal:4 hard legal-domain
task:* coding:* all coding, any complexity
domain:* medical:* all of a subject
complexity 3 a plain level

A level left unmapped picks from the live models, cheapest first, by complexity. A map value may list several models — a,b (equal) or a:3,b:1 (weighted) — chosen by the strategy: failover, round-robin, weighted or random. A model that is down or returns a 5xx before sending anything falls through to the next in the chain.

Long inputs. A context rule (min_input_tokens → model) wins over complexity so a large input always goes to a big-context model, and a model that reports its context window is never handed an input that does not fit.

  • Every routed response carries x-lifeboat-route: task/domain/cN/source/rule/strategy->model.
  • Test a prompt on the Routing page is a dry run — no inference, no charge — showing the model that would answer and why (POST /api/routing/preview).
  • The Routing page charts complexity, models and task types, and lists recent decisions. No prompt text is stored.

On the Routing page, turn smart routing on and (optionally) edit the map. auto then appears in /v1/models. Renaming the trigger from auto is supported.