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
- Define a model tier map: for each task type (simple, medium, hard), list acceptable models ordered cheap-to-expensive.
- Classify each incoming request by difficulty before sending: e.g. keyword/pattern heuristics, token count, or a cheap classifier call.
- Route: send easy requests to the cheap tier first; escalate to a stronger model only on failure or low confidence.
- Add a retry/fallback chain: if the chosen model errors or times out, try the next tier up.
- Log per-request cost and outcome so you can tune the thresholds.
- 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.