Diagram of a request passing a cache, then a small model, escalating to a large model only when a check fails
Back to Work & InsightsComprehensive Guide

Model Cascade Routing & Semantic Caching

Sending every request to the largest model pays premium prices for questions a small model answers just as well. Route by difficulty, and don't answer the same question twice.

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.
Cost & performance · Typical API wrapper

Call the top-tier model for every request

Cost & performance · FDE architecture

Model cascade routing plus a semantic cache

01 · Definition

Four parts of a cost-aware model layer

Router
faq → small · contract review → large

Picks a model per request, from rules or a cheap classifier trained on your traffic.

Escalation check
schema fails · low confidence · refusal

A checkable reason to retry on a stronger model. Without it, a cascade just returns cheap wrong answers.

Semantic cache
similarity ≥ 0.95 → cached answer

Reuses answers for requests that mean the same thing, even when worded differently.

Cache scope & TTL
per tenant · 24h · invalidate on update

Who may share an answer and for how long. Gets this wrong and the cache leaks data or serves stale facts.

02 · Worked example

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)
Top model, every time
Same answer, full price, every call
  1. 01Retrieve the policy documents
  2. 02Send everything to the largest model
  3. 03Wait several seconds for the answer
  4. 04Repeat for the next tenant asking the same thing
Cache + cascade
Pay for hard questions only
  1. 01Semantic cache hit (scoped to this property) → answer immediately
  2. 02Miss → classifier says “policy FAQ” → small model
  3. 03Answer passes citation check → return and cache
  4. 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)
}
A cascade is a loop over models with a check between them.
03 · Failure modes

Where routing and caching go wrong

Near-miss cache hits

“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.

Cross-tenant leaks

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.

Stale answers

Policy changed on Monday; the cache serves last week's answer all month.

Set TTLs and invalidate entries when the source documents change.

Silent downgrade

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.

Escalation tax

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.

04 · Decision

Is routing and caching worth building?

Your score: 0 / 6

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.

05 · Trade-off

What it costs

Quality risk
Every request sent to a smaller model is a bet. Evals turn the bet into a measured trade-off.
Extra infrastructure
A vector store for the cache, a router, and monitoring per tier. More to run and secure.
Cache correctness
Scoping, entity-aware keys, TTLs, and invalidation are where the real engineering effort goes.
Moving target
Model prices and capabilities change every few months. Routing rules need periodic re-evaluation.

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.

06 · Playbook

How to roll it out

  1. 01Log a few weeks of real requests with cost, latency, and task type.
  2. 02Measure how many requests are near-repeats and how many are easy.
  3. 03Run your eval set on two or three model tiers and record quality per task type.
  4. 04Route the clearly easy task types to the cheaper tier; add escalation checks.
  5. 05Add a semantic cache only for shared, non-personal answers, scoped and with TTLs.
  6. 06Track cost, latency, and eval score per tier on a dashboard; re-evaluate when models change.

Tooling options

Open source gateway
LiteLLM

One API across providers, with routing, fallbacks, budgets, and caching.

Hosted gateway
OpenRouter

Many models behind one endpoint; easy to compare tiers.

Semantic cache store
Redis / Postgres pgvector

Vector similarity lookups next to data you already run.

Learned routing
RouteLLM

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