/route — Smart LLM Task Router
Route any task to the optimal LLM automatically.
Usage
/route <task description>
Auto-Classification
Most prompts are classified automatically by the UserPromptSubmit hook — no /route needed. The hook uses a multi-layer classification chain:
Heuristic scoring (instant, free) — Three signal layers accumulate evidence:
- Intent patterns (+3) — action verbs and task markers
- Topic patterns (+2) — domain-specific nouns
- Format patterns (+1) — structural and temporal cues
- High-confidence match (score >= 4) routes immediately
Ollama local LLM (~1s, free) — When heuristics are uncertain, qwen3.5 classifies locally via the chat API with thinking disabled
Cheap API model (~$0.0001) — If Ollama is unavailable, Gemini Flash or GPT-4o-mini classifies
Weak heuristic / auto fallback — Last resort: low-confidence heuristic match or llm_route (full LLM classifier)
Task Categories
The consolidated llm(prompt=..., task=..., tier=...) tool is the front door for all of
these — task= picks the specialization, tier= (fast/balanced/best) picks the cost tier:
| Category |
Call |
Signals |
| Research |
llm(task="research") |
Current events, news, funding, trends, market data, rankings |
| Generate |
llm(task="generate") |
Writing, drafting, brainstorming, emails, articles, translations |
| Analyze |
llm(task="analyze") |
Evaluation, debugging, comparison, trade-offs, code review |
| Code |
llm(task="code") |
Implementation, refactoring, building, bug fixes |
| Query |
llm(task="query") (or task="auto") |
Simple questions, definitions, explanations |
| Image |
llm_image |
Visual generation, design, artwork |
Complexity & Profiles
| Complexity |
Profile |
Model Tier |
| Simple |
budget |
Gemini Flash, GPT-4o-mini |
| Moderate |
balanced |
GPT-4o, Gemini 2.5 Pro |
| Complex |
premium |
o3, Gemini 2.5 Pro |
Savings Awareness
Every 5th routed task, the system shows estimated savings: Claude API costs avoided and rate limit capacity preserved. Run llm_router_status(view="usage") for a detailed breakdown.
Examples
What are the top 3 AI startups that raised funding?
→ research (heuristic, score=8) → llm(task="research") → Perplexity Sonar
Write me a blog post about productivity tips
→ generate (heuristic, score=5) → llm(task="generate", tier="balanced") → Gemini 2.5 Pro
Compare React vs Vue for our new project
→ analyze (ollama, qwen3.5) → llm(task="analyze", tier="balanced") → GPT-4o
Implement a rate limiter in Python using sliding window
→ code (heuristic, score=4) → llm(task="code", tier="balanced") → GPT-4o
What is a monad?
→ query (ollama, qwen3.5) → llm(task="query", tier="fast") → Gemini Flash
Configuration
Environment variables:
LLM_ROUTER_OLLAMA_MODEL — Ollama model (default: qwen3.5:latest)
LLM_ROUTER_OLLAMA_URL — Ollama server (default: http://localhost:11434)
LLM_ROUTER_OLLAMA_TIMEOUT — Timeout in seconds (default: 5)
LLM_ROUTER_CONFIDENCE_THRESHOLD — Heuristic score cutoff (default: 4)
1---2name: route3description: Route a task to the best LLM based on task type and complexity4---56# /route — Smart LLM Task Router78Route any task to the optimal LLM automatically.910## Usage1112```13/route <task description>14```1516## Auto-Classification1718Most prompts are classified automatically by the `UserPromptSubmit` hook — no `/route` needed. The hook uses a **multi-layer classification chain**:19201. **Heuristic scoring** (instant, free) — Three signal layers accumulate evidence:21 - Intent patterns (+3) — action verbs and task markers22 - Topic patterns (+2) — domain-specific nouns23 - Format patterns (+1) — structural and temporal cues24 - High-confidence match (score >= 4) routes immediately25262. **Ollama local LLM** (~1s, free) — When heuristics are uncertain, qwen3.5 classifies locally via the chat API with thinking disabled27283. **Cheap API model** (~$0.0001) — If Ollama is unavailable, Gemini Flash or GPT-4o-mini classifies29304. **Weak heuristic / auto fallback** — Last resort: low-confidence heuristic match or `llm_route` (full LLM classifier)3132## Task Categories3334The consolidated `llm(prompt=..., task=..., tier=...)` tool is the front door for all of35these — `task=` picks the specialization, `tier=` (fast/balanced/best) picks the cost tier:3637| Category | Call | Signals |38|----------|------|---------|39| Research | `llm(task="research")` | Current events, news, funding, trends, market data, rankings |40| Generate | `llm(task="generate")` | Writing, drafting, brainstorming, emails, articles, translations |41| Analyze | `llm(task="analyze")` | Evaluation, debugging, comparison, trade-offs, code review |42| Code | `llm(task="code")` | Implementation, refactoring, building, bug fixes |43| Query | `llm(task="query")` (or `task="auto"`) | Simple questions, definitions, explanations |44| Image | `llm_image` | Visual generation, design, artwork |4546## Complexity & Profiles4748| Complexity | Profile | Model Tier |49|------------|---------|------------|50| Simple | `budget` | Gemini Flash, GPT-4o-mini |51| Moderate | `balanced` | GPT-4o, Gemini 2.5 Pro |52| Complex | `premium` | o3, Gemini 2.5 Pro |5354## Savings Awareness5556Every 5th routed task, the system shows estimated savings: Claude API costs avoided and rate limit capacity preserved. Run `llm_router_status(view="usage")` for a detailed breakdown.5758## Examples5960```61What are the top 3 AI startups that raised funding?62→ research (heuristic, score=8) → llm(task="research") → Perplexity Sonar6364Write me a blog post about productivity tips65→ generate (heuristic, score=5) → llm(task="generate", tier="balanced") → Gemini 2.5 Pro6667Compare React vs Vue for our new project68→ analyze (ollama, qwen3.5) → llm(task="analyze", tier="balanced") → GPT-4o6970Implement a rate limiter in Python using sliding window71→ code (heuristic, score=4) → llm(task="code", tier="balanced") → GPT-4o7273What is a monad?74→ query (ollama, qwen3.5) → llm(task="query", tier="fast") → Gemini Flash75```7677## Configuration7879Environment variables:80- `LLM_ROUTER_OLLAMA_MODEL` — Ollama model (default: `qwen3.5:latest`)81- `LLM_ROUTER_OLLAMA_URL` — Ollama server (default: `http://localhost:11434`)82- `LLM_ROUTER_OLLAMA_TIMEOUT` — Timeout in seconds (default: `5`)83- `LLM_ROUTER_CONFIDENCE_THRESHOLD` — Heuristic score cutoff (default: `4`)