Opus quality.
Haiku price.
Type any query. Watch a Bayesian cost router classify it, filter the lane pool, sample posteriors, and pick the cheapest model that can actually handle it. The same router that runs inside QADIR OS — verbatim heuristics, real published prices, ported to JavaScript so you can run it in your browser without trusting our backend.
01Type a query
Anything. Real questions, code requests, medical edge-cases, multi-step analyses. The classifier runs locally on each keystroke (debounced).
02Difficulty classification
Same heuristic battery as core/routing/query_difficulty.py — length, sentence count, vocab diversity, multi-step markers, reasoning markers, lookup downweight, code-synthesis detection, and premium-domain safety overrides.
03Lane pool · Bayesian sampling
Lanes below the difficulty floor get filtered out (dimmed). The remaining lanes compete on cost-adjusted utility = Thompson-sampled quality / effective $/1k tokens. Gold tick = this turn's posterior sample.
04Decision · cost vs. always-Opus baseline
If you defaulted every query to Claude Opus (the safe expensive choice), you'd spend the baseline. The router picks the cheapest qualifying lane. Difference is the savings — per query, then cumulatively across this session.
How the real router works
Three filters stacked. Each one is independently buildable. Together: "cheapest model that can handle this specific query" — with cost-aware exploration and provable safety overrides.
Query-difficulty tier floor
The classifier reads the query — length, sentence count, vocab diversity, multi-step / reasoning / lookup / code-synthesis markers — and emits a tier floor. Easy queries can route to free local models; hard queries are structurally prevented from reaching free-tier lanes. Premium-domain markers (medical, legal, security) force tier-2 regardless of other signals.
Thompson sampling on per-lane posteriors
Each lane has a Beta posterior over its success rate, updated from production calls. On every routing decision, the router draws a sample from each posterior. Lanes with strong track records get exploited; new or uncertain lanes get explored — the literal Bayesian bandit move. Posterior bars on the cards above visualize this live.
Cost-adjusted utility ranking
Final ranking: utility = sample / effective_cost for balanced mode. Cheap mode squares the cost penalty. Quality mode ignores cost. Speed mode boosts low-latency providers (Cerebras, Groq, Haiku). The cascade always carries 2–3 fallback lanes for retry without loss of quality.
This is the brain that ships inside QADIR OS.
Same heuristics. Same posteriors. Same cost math. Wrapped in a local-first desktop OS built for engineers who got tired of paying Opus prices for Haiku-class queries. QADIR OS is in early access — request it, it is not a public download yet.
Want this in your stack, not just your browser?
A stranger-installable version of this router that drops into your codebase is in active development. When it ships, you'll be able to wire it to your providers, seed posteriors from your traffic, and get an observability endpoint. Submit a request below and we'll let you know the day it's ready.
core/routing/query_difficulty.py · Lane prices verbatim from config/brain_connections.yaml (2026-05-14 snapshot) · No telemetry · Runs entirely in your browser