All glossary terms

Serving

Caching layers

The stack of caches above a model - reply, prompt prefix, and gateway - where a hit at a higher layer costs less of the bill than any hit at the GPU layer.

A model-serving stack caches at several heights at once, and each height prices a hit differently. A reply cache stores whole answers keyed by the question family and serves a hit at near-zero marginal cost, billing the provider nothing. A prefix cache keeps request preambles resident near the model and serves a hit by removing most of the prefill - big savings in both wait and the prompt side of the bill. The GPU-level KV cache keeps per-request state within one generating request. None of them overlap; each is the cheapest answer at a different granularity.

The layering is an ordering of trust. A replayed answer is cheapest and riskiest, because a question family can drift while its cached answers stay frozen - which is why reply caches carry freshness budgets and why semantic matching at this layer is a measured trade, not a default. Prefix hits are the workhorse: the preamble is usually stable by construction, so the risk is negligible and the savings show up on every request of the family.

Metering the layers separately is what turns this from folklore into a dashboard. Hit share per layer, and the bill each layer saved, are the two lines that answer the question when a bill surprises you: a cache that went cold on the prompt side, or a reply cache serving stale answers, looks identical to a traffic change unless each layer is watching its own ledger.

A worked example

A request with a 1,500-token prompt on a rate card of $3 per million fresh tokens and $0.30 per million for a cached prefix. The reply cache hits whole answers, the prefix cache hits preambles, and a miss falls through to the full card.

  1. Reply cache hit: $0 billed and answered in about 50 ms - the cheapest tier, bounded by freshness risk.
  2. Prefix cache hit: 1,500 x $0.30 / 1,000,000 = about $0.0005 of prompt billing, and most of the prefill wait is gone.
  3. Cold path: 1,500 x $3.00 / 1,000,000 = $0.0045 of prompt billing plus the full prefill - about 10x the bill of the prefix hit.

A hit one layer higher is a different price: $0, then about $0.0005, then $0.0045 for the same request - the stack saves the bill from the top down.

Where this shows up

Test yourself

Related terms