A pi extension that automatically routes prompts to the right model.
You type a prompt. Haiku classifies it (~300ms, fractions of a cent). The request goes to Sonnet or Opus. Simple tasks stay cheap. Complex tasks get the power they need. You never think about model selection.
flowchart LR
A[You type a prompt] --> B[Haiku classifies]
B -->|simple / moderate| C[Sonnet 4.6]
B -->|complex / deep reasoning| D[Opus 4.6]
C --> E[Response]
D --> E
pi install npm:pi-auto-routerOr try it without installing:
pi -e npm:pi-auto-routerThe extension hooks into before_agent_start. Before each LLM call:
- Sends your prompt to Haiku with a classification instruction
- Haiku responds with one word:
sonnetoropus - Extension calls
pi.setModel()to switch - Status bar shows
→ sonnetor→ opus
Manual override: Switch models with Ctrl+P or Ctrl+L and the router respects your choice for that turn, then resumes auto-routing.
Haiku routes to Opus for:
- Complex architecture and system design
- Multi-file refactors with tricky interdependencies
- Subtle debugging (race conditions, memory leaks, flaky tests)
- Novel algorithm design
- Nuanced writing or deep analysis
- Long chains of reasoning
Everything else goes to Sonnet: file reads, lookups, commands, standard edits, straightforward questions, writing tests.
When in doubt, Haiku picks Sonnet. Opus is only for tasks that genuinely need deeper reasoning.
The Haiku classification call adds ~$0.0001 per prompt. Over a full day of coding, maybe $0.01-0.05 extra. The savings from not running Opus on simple tasks far outweigh this.
The extension uses these model IDs by default:
| Role | Model ID |
|---|---|
| Router (classifier) | claude-haiku-4-5 |
| Standard target | claude-sonnet-4-6 |
| Complex target | claude-opus-4-6 |
To change these, edit the constants at the top of extensions/model-tier-coach.ts.
MIT