Prompt caching and marketplace pricing: where the discount really lands

2026-11-28来源 dev.toEnglish

Prompt caching and marketplace pricing: where the discount really lands

Published 2026-11-28 · LONG AI Engineering Notes

The most common budgeting mistake I see with prompt caching is treating it as a second discount stacked on top of a marketplace discount. People reason: "I get 50% off official price here, and caching saves me 90% of input tokens, so my input cost is 5% of official." That arithmetic never holds, and the reason is not greed — it is that the two discounts multiply different things.

Caching discounts the cacheable portion of input. A marketplace discount discounts the unit price of the whole request. Apply them in the wrong order, or apply them to the wrong token count, and the number you put in your budget is fiction.

1. What a cache actually reduces

A prompt cache is a prefix cache. An upstream keeps the key/value state for an exact token prefix, and if the next request starts with that same prefix, it skips recomputing it. Three constraints follow immediately:

  • Only the prefix. Nothing after the first divergence is cached. A system prompt plus tool schema is cacheable; the user message never is.

  • Only input. Output tokens are generated fresh every time. Roughly 30–50% of a chat-shaped request is output in practice, and caching touches none of it.

  • Only if identical. One whitespace change, one timestamp inserted at the top, one reordered JSON field in the tool schema, and the cache misses entirely.

So before any arithmetic, write down two numbers for your workload: the cacheable prefix length as a share of total input, and the output share of total tokens. Without both, "caching saves 90%" is a number someone quoted from a blog post.

2. A 20-step agent loop, priced three ways

Take a concrete shape, because abstractions hide the point. A 20-step agent task on a text model, each step sending:

Component Tokens per step Cacheable?
System prompt + tool schema 2,000 Yes (prefix)
Retrieved context (changes per step) 1,500 No
Conversation history (grows) 1,000 → 4,000 Partially, if append-only
Output 400 Never

With a conservative single-price model at ¥0.402 per million input tokens and ¥1.610 per million output (the median and a typical 4× output multiplier from the current snapshot), the uncached bill for 20 steps is roughly ¥0.0225. Applying a 90% input cache hit on the 2,000-token prefix saves about ¥0.0014 — 6% of the total, not 90% of anything.

Now put the same task on a marketplace model selling at 0.5 of official price. The unit price drops by half, so the absolute cache saving drops by half too: about ¥0.0007. The discount and the cache both landed, but on different multipliers, and the combined effect on the invoice is a rounding error compared to what the "50% off plus 90% cache" mental model predicted.

3. Why deep discounts leave little room for stacking

On a marketplace where sellers compete on price, the deep discounts are already at the floor. In the November 2026 snapshot of 122 listed models from 63 vendors, the median discount was 0.5 — official price times 5% — and 70 of 122 models sat in the 0.1–0.5 range (the full per-model figures are on the live price table). The mean was 1.43, dragged down by that cluster, which is exactly why the median is the honest number for budgeting.

Once you are paying 5% of list, the remaining recoverable cost is small in absolute terms. Caching still helps, but it helps on a base that has already been cut by 95%. That is the structural reason cache savings look underwhelming on a heavily discounted gateway and look dramatic on a list-price direct account: same cache behaviour, very different denominator.

There is a second, less obvious effect: cache hit rates are usually worse through a gateway, because the same logical prefix may land on a different upstream seller between steps. Failover that reroutes a request mid-conversation resets the cache. If your agent loop depends on a warm prefix and your gateway is balancing across several sellers, measure the real hit rate through the gateway rather than assuming the single-upstream number.

4. Three checks before you budget around caching

  • Does the upstream bill cached tokens at a lower rate, or not bill them at all? Both exist. A provider that "supports caching" but bills full price for the cached portion gives you latency relief, not cost relief.

  • Is cache control exposed through the gateway? If the gateway strips cache_control markers or rewrites the system prompt per request, caching silently stops working and nothing in the response tells you. The API docs list which fields pass through unchanged.

  • Does a model switch reset the cache? Changing model mid-task invalidates the prefix on most upstreams. An A/B test that flips models every step pays full input price every step.

All three are answerable per model, and the answers differ by model even within one vendor. The per-model reference pages are the place to check them, not the marketing page.

5. What to do instead of estimating

Measure the effective cost of one task, not the unit price. Run the same 20-step loop twice — once cold, once warm — and read the usage records for input tokens and any cache-discount field. Divide by steps. That number, not a stacked-percentage, belongs in the budget.

# sanity check: is caching actually applied to this model? curl https://api.example.com/v1/chat/completions \ -H "Authorization: Bearer $KEY" \ -H "Content-Type: application/json" \ -d '{"model":"MODEL_ID","messages":[ {"role":"system","content":"...long fixed prefix..."}, {"role":"user","content":"same question"}]}' # run twice; compare usage.prompt_tokens and any cached_tokens field 

If the second call reports the same prompt_tokens and no cached-token field, caching is not landing, and no amount of discount math will fix it.

6. Where the discount really lands

Short version: the marketplace discount lands on every token, including output, including uncacheable input. The cache discount lands only on a slice of input, and that slice is already cheap. So the discount you should budget around is the marketplace one; the cache is a latency feature that occasionally saves a few percent of cost. Treat it in that order and your numbers stop lying to you.

— Written from the November 2026 price snapshot (122 models, 63 vendors, data as of 2026-11-25 17:46). Live prices move with seller quotes; check the price table before you commit a number to a budget.

原文:https://www.a8q9.cn/en/article/prompt-caching-and-marketplace-pricing-where-the-discount-really-lands-10a1f3.html

相关文章