# Token Cost Router

> Use when you need to cut LLM API spend by routing each request to the cheapest model that can handle it.

- Skill: `harishkotra/token-cost-router` (Agent Skill)
- Install (CLI): `npx skillmds@latest add harishkotra/token-cost-router`
- Raw SKILL.md: https://api.skillmd.com/api/skills/harishkotra/token-cost-router/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: harishkotra (https://skillmd.com/u/harishkotra)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/harishkotra/token-cost-router

---


# Token Cost Router
Route every LLM request to the cheapest model that can still do the job well, cutting spend 50-70%+.

## When to use
- You have multiple OpenAI-compatible models available (cheap + expensive tiers) and want to cut spend without hurting quality.
- You want an automatic fallback chain when a model is down or rate-limited.

## Procedure
1. Define a model tier map: for each task type (simple, medium, hard), list acceptable models ordered cheap-to-expensive.
2. Classify each incoming request by difficulty before sending: e.g. keyword/pattern heuristics, token count, or a cheap classifier call.
3. Route: send easy requests to the cheap tier first; escalate to a stronger model only on failure or low confidence.
4. Add a retry/fallback chain: if the chosen model errors or times out, try the next tier up.
5. Log per-request cost and outcome so you can tune the thresholds.
6. Verify: run a sample set through both the naive (always-expensive) and routed path and confirm quality holds while spend drops.

## Pitfalls
- Over-routing to cheap models on tasks that need reasoning will quietly degrade quality. Always hold back a quality check.
- Reclassify per request, don't cache a model choice across sessions unless the task is identical.

## Verification
- Report actual spend before vs after on a real workload, and show a sample of outputs passed quality review.

