TL;DR
- Most production traffic is easy. If every call goes to the top model, you pay top price and top latency for work a small model could do.
- Cascade: try a smaller, faster model first and escalate to a larger one only when a check fails. Or route up front by task type with a cheap classifier.
- Semantic cache: embed each request and return a stored answer when a close enough request was answered before. Great for FAQ-like traffic, dangerous for personal or time-sensitive answers.
- Your evals decide which model is good enough for which task. Routing without evals is guessing about quality to save money.
Call the top-tier model for every request
Model cascade routing plus a semantic cache
Four parts of a cost-aware model layer
faq → small · contract review → largePicks a model per request, from rules or a cheap classifier trained on your traffic.
schema fails · low confidence · refusalA checkable reason to retry on a stronger model. Without it, a cascade just returns cheap wrong answers.
similarity ≥ 0.95 → cached answerReuses answers for requests that mean the same thing, even when worded differently.
per tenant · 24h · invalidate on updateWho may share an answer and for how long. Gets this wrong and the cache leaks data or serves stale facts.
A customer-support assistant, two ways
A property-management company's assistant answers tenant questions. Many repeat: rent due dates, parking, maintenance requests.
“When is rent due, and can I pay by card?” (asked many times a week, worded differently each time)
- 01Retrieve the policy documents
- 02Send everything to the largest model
- 03Wait several seconds for the answer
- 04Repeat for the next tenant asking the same thing
- 01Semantic cache hit (scoped to this property) → answer immediately
- 02Miss → classifier says “policy FAQ” → small model
- 03Answer passes citation check → return and cache
- 04Lease dispute → classifier sends straight to the large model
How much this saves depends entirely on your traffic mix. Measure the share of repeatable and easy requests before promising a number.
const tiers = [models.small, models.medium, models.large]
async function answer(req: Request): Promise<Answer> {
const key = cacheKey(req.tenantId, req.text) // scope by tenant
const hit = await cache.nearest(key, { minSimilarity: 0.95 })
if (hit && !isPersonal(req)) return hit.answer
for (const model of startTier(req, tiers)) { // classifier may skip tiers
const out = await model.generate(req)
if (passesChecks(out, req)) { // schema, citations, confidence
if (isCacheable(req)) await cache.put(key, out, { ttl: "24h" })
return out
}
}
return escalateToHuman(req)
}Where routing and caching go wrong
“Refund status for order 1234” matches the cached answer for order 5678; the embeddings are almost identical.
Extract entities (IDs, dates, names) into the cache key, and never cache answers built on personal records.
One shared cache serves tenant A's answer to tenant B.
Scope cache entries by tenant and permission level. Treat the cache as data storage, with the same access rules.
Policy changed on Monday; the cache serves last week's answer all month.
Set TTLs and invalidate entries when the source documents change.
The small model answers wrong with confidence, and nothing checks it.
Escalate on checkable failures, and compare tiers on your eval set before routing traffic.
Hard requests go small → medium → large, paying three times and waiting three times.
Route clearly hard requests straight to the right tier; cascade only the ambiguous middle.
Is routing and caching worth building?
One good model is fine
At low volume, routing adds complexity for little saving. Use provider prompt caching for long, repeated system prompts and move on.
What it costs
Provider prompt caching is a different thing: it reuses the processed prefix of identical prompts (long system prompts, shared documents) at a discount. It's low-risk and complements a semantic cache rather than replacing it.
How to roll it out
- 01Log a few weeks of real requests with cost, latency, and task type.
- 02Measure how many requests are near-repeats and how many are easy.
- 03Run your eval set on two or three model tiers and record quality per task type.
- 04Route the clearly easy task types to the cheaper tier; add escalation checks.
- 05Add a semantic cache only for shared, non-personal answers, scoped and with TTLs.
- 06Track cost, latency, and eval score per tier on a dashboard; re-evaluate when models change.
Tooling options
One API across providers, with routing, fallbacks, budgets, and caching.
Many models behind one endpoint; easy to compare tiers.
Vector similarity lookups next to data you already run.
Open-source framework for training routers that choose between a strong and a weak model.
More guides
Want this built into your workflow?
I help small and mid-size teams decide what to build, then build it, from the first eval set to production guardrails.
Talk through your use case