LLMCostBot

Guide · prices verified 2026-12-02

Prompt caching: when it pays off, with the math

Prompt caching discounts the part of the input that repeats across calls. The saving is a weighted average: hit rate × cached price plus the rest × standard input price. On the customer support bot template, raising the hit rate from 0% to 90% changes the monthly total from $1.95 to $1.75 on GLM 5.3 Flash.

The blended input rate

If a fraction h of input tokens hits the cache, the effective input price is h × cached price + (1 − h) × standard input price. Output price is unchanged, because caching applies to the prompt, not the completion. The monthly bill is input tokens × blended rate + output tokens × output price, multiplied by calls.

The formula needs both prices. 27 of 30 records in this catalog include a cached-input price. For the rest, this site writes Not collected and applies the standard input price, with cacheApplied=false, rather than inventing a discount.

Worked example: a support bot

The template assumes 20,000 replies per month, 2,000 input and 300 output tokens per call, and a 2% retry rate. The table recomputes the same workload at five hit rates on GLM 5.3 Flash, whose recorded prices are $0.0356 input, $0.03 cached input and $0.0815 output per 1M tokens.

Monthly cost by cache hit rate on GLM 5.3 Flash
Cache hit rateCached price appliedMonthly total
0%No$1.95
25%Yes$1.89
50%Yes$1.84
75%Yes$1.78
90%Yes$1.75

Same tokens, volume and retry rate in every row; only the cache hit rate changes.

When caching pays off

Caching pays when the same prefix is large, repeated often, and mostly stable. A 10,000-token policy block sent 50,000 times is the ideal case. A 200-token system prompt sent 100 times is not worth engineering around, even at a 90% hit rate.

The break-even hit rate depends on the ratio between cached and standard input prices. If cached input is half price, each cached token saves the same amount, and the saving scales linearly with the hit rate and the prefix share of input. The sensitivity table on each workload page shows which assumption moves the total most.

Measure your real hit rate

A cache hit rate is a property of traffic, not of a model. The provider's usage report usually exposes cached input tokens next to total input tokens; divide one by the other over a full week before you put a number in a budget. A single quiet afternoon can overstate the rate, and a launch can understate it.

If the measured rate is far below the assumption, do not start by changing models. Check whether the prefix is actually identical across calls: a timestamp, a request id, a randomised tool order or a per-user greeting at the top of the prompt breaks the shared prefix and turns every call into a miss. Removing one unstable line often does more than any pricing change.

Cache math for output-heavy work

Caching only discounts input tokens. On an output-heavy workload, the input share is small, so even a large cache discount moves the total by little. The percentage saving is the cache discount multiplied by the input share of the bill, not by the whole bill.

On the customer support bot template the input line is $1.32 of $1.81, so caching can move most of the bill. On a translation workload where input and output tokens are equal, the same hit rate moves a much smaller share. The workload pages show both lines precisely so this comparison does not depend on intuition.

A migration checklist

Caching takes one request flag to enable and one wrong assumption to misconfigure. A short sequence keeps the estimate and the invoice aligned.

  • Shorten and stabilise the repeated prefix before enabling cache pricing.
  • Confirm the chosen model actually publishes a cached-input price.
  • Run for a week, then compute cached tokens divided by total input tokens.
  • Compare the invoice with a recomputed estimate at the measured rate.
  • Record the measured rate and the date, and re-check after prompt changes.

Cache and batch are different levers

Batch pricing changes when work runs; caching changes what is charged for repeated input. A batch job can also use caching if the vendor supports both, but this catalog does not stack the two discounts and does not infer a combined rate. Treat each as a separate scenario until the vendor's terms say otherwise.

That separation matters for planning. Batch is usually a flat 50% on work that can wait, while caching depends on a stable prefix and a measurable hit rate. If a workload is both batchable and repeat-heavy, price them one at a time, then confirm the combination on the vendor page rather than multiplying two assumptions together.

How to read the calculator output

The calculator shows four numbers: the total without cache, the total with cache at the chosen hit rate, the monthly saving and the break-even hit rate. Read them in that order. The first is the standard-price baseline, the second applies the measured or assumed rate, and the difference is the only number that the cache decision changes.

If the chosen model has no published cached-input price, the second number stays equal to the first and the page says so. That is not a bug and not a zero saving; it is a missing field. The correct response is to choose a model with a recorded price or to accept the standard input price as the estimate.

Cache pricing is not a quality signal

A cached-input field says something about a billing schedule, not about how well a model answers. The presence of a cache price does not make a model better, and its absence does not make a model worse. Ranking models by whether they publish a cache price would repeat the mistake this site avoids elsewhere: treating a recorded field as a quality score.

Use the field only for what it is: a second input price that applies to repeated tokens. If a workload has no repeated prefix, the field is irrelevant. If it does, the field changes the bill and belongs in the estimate.

What to put in the assumption log

A cache estimate is only reproducible if its assumptions travel with it. Keep the prefix token count, the measured or assumed hit rate, the monthly call count and the verification date next to the result. When the prefix changes, the saved estimate tells you exactly which input to re-measure.

The calculators keep the inputs in the URL so a result can be reopened and checked. That is the minimum bar for a cost decision: someone else should be able to reproduce the number without asking which assumptions were used.

A short example of a bad prefix

Consider a prompt that starts with a greeting that names the customer, followed by a long policy block. Even if the policy block is identical for every request, the changing greeting sits before it, so the provider sees a different prefix and the cache misses. Moving the policy block to the front and the greeting to the end is usually enough to make the stable part cacheable.

The same problem appears with generated identifiers, timestamps and tool definitions whose order changes between deploys. These are engineering details, but they decide whether the cache math on this page applies. Inspect the first few hundred tokens of a request before you trust a hit-rate assumption.

What this site does not model

Cache writes, storage duration, minimum cacheable prefix lengths and per-provider expiry rules are not in this catalog. A provider may charge more for the first write or require a minimum prefix; those fields read Not collected here. The estimate is a discount on repeated input, not a full replication of any vendor's cache billing.

  • Only the hit rate you choose is applied; it is an assumption, not measured traffic.
  • A model without a recorded cached price keeps its standard input price.
  • Cache and batch discounts are separate; this model does not stack them.

Takeaways

  • Blended input rate = hit rate × cached price + the rest × standard price.
  • Caching only moves the input side of the bill.
  • It pays when the repeated prefix is large relative to total input.
  • Missing cache pricing is Not collected, never estimated.

FAQ

What cache hit rate should I assume?
Use your own logs. If the prefix is a fixed policy or instruction block, a high hit rate is plausible; if every request carries different retrieved text, it is not. The workload templates use example rates and label them as assumptions.
Does caching change the output price?
No. Cached-input pricing applies to the prompt tokens. Output is billed at the standard output price, so an output-heavy workload sees a smaller percentage saving from caching.
Do cache writes appear in this estimate?
No. Cache-write premiums, storage duration and minimum cacheable lengths are not published in the records, so they read Not collected. The estimate applies the cached-input price only to the share of tokens that hit.
Does a longer prefix always save more?
Only if it repeats. A long prefix that changes on every call creates no cache hits and adds input tokens. The saving depends on the repeated share of input and the measured hit rate, not on prefix length alone.
Can I combine cache and batch discounts?
Some providers offer both, but this catalog does not stack them and does not infer a combined rate. Check the vendor's own terms; the batch and cache fields on vendor pages show what was transcribed.

Related

Cite this page

LLMCostBot. "Prompt caching: when it pays off, with the math". Prices and limits verified 2026-12-02. https://llmcostbot.com/en/guides/prompt-caching-math (CC BY 4.0).

Data is licensed under CC BY 4.0. Keep the link and the verification date when you reuse it.