docs / concepts / smart-routing

Smart routing

Every prompt gets classified into a task category in under five milliseconds, then routed to the model that scores best for that category under your constraints. Deterministic, transparent and override-able.

The routing pipeline

  1. Classify the prompt into a TaskType using lexical signals and a tiny prompt classifier. Result: one of coding, reasoning, general, embedding, pilot.
  2. Pull constraints from the request: model='auto' lets the router pick; an explicit model pins it. Constraints can include local-only, a cost ceiling, a latency budget and a preferred provider.
  3. Look up the capability map for the target category. Filter to models that meet the constraints.
  4. Pick the highest scorer with valid hardware availability. RAM-aware loading prevents Soriku from picking a model that won't fit alongside what's already loaded.
  5. Execute the prompt on the chosen model and record the decision for auditability in data/routing_log.jsonl.

Determinism

Given the same capability map, the same constraints and the same prompt, the router always picks the same model. No randomness in the decision step. If you can't reproduce a routing decision, you can't audit it.

Constraints you can set

ConstraintTypeEffect
prefer_localboolOnly consider locally hosted models
max_cost_per_1kfloatReject models whose cost exceeds this cap
max_latency_msintReject models whose recent p95 latency exceeds this
provider_allowlistlistRestrict to specific providers (ollama, anthropic, openai, etc.)
pinned_modelstringBypass routing entirely and use this exact model

Task types

The classifier maps a prompt to one of five task types. The mapping is rule-based and fast.

Task typeTriggerRoutes to
codingCode-generation, debugging, refactoring intentsModels with high code_generation or code_review scores
reasoningMulti-step analysis, math, planning, formal reasoningModels with high reasoning scores
generalConversational, summary, translation, creative writingModels with high category-matching general scores
embeddingRequests to /api/v1/embeddingsEmbedding-capable model, defaults to nomic-embed-text
pilotTool-using prompts (file ops, shell, web fetch) detected via verb regexPilot-mode worker, see Pilot mode

Overriding the router

Three levels of override, from most general to most specific.

Even with an override, the routing decision is logged with routed_by: pin so audits show the override was deliberate.

Next: agent personas →