LLM

Prompt Caching for Device System Prompts: When It Lowers the Bill

Identical warm-white voice devices fill a production tray with matching orange status lights.Illustration

Caching lowers the bill when the same long prefix is reused inside the cache lifetime. With Anthropic's published multipliers (1.25 times to write, 0.1 times to read, 5-minute default lifetime), the second request in a window already saves money. A prefix used only once pays the 1.25 times write rate for nothing.

Many AI devices send the same long system prompt with every request. Prompt caching lets the provider reuse that fixed prefix at a lower price. Whether it saves money depends on how often the same prefix arrives inside the cache lifetime. This guide gives you the published multipliers, a break-even formula and the measurements to take on your own traffic. It contains no Duobay price and no measured result.

What do the providers publish?

These are the Anthropic caching multipliers, read on October 31, 2026. They apply to the base input price of the model you call.

ItemPublished valueNoteSource
Cache write, 5-minute lifetime (default)1.25 times the base input priceThe page states: "Cache write tokens with a 5-minute TTL are 1.25 times the base input tokens price."Anthropic caching docs, as of October 31, 2026
Cache write, 1-hour lifetime (optional)2 times the base input priceExtra charge for the longer lifetime.Anthropic caching docs, as of October 31, 2026
Cache read (hit)0.1 times the base input priceSome models list a lower read multiplier on the same page. Check the row for your model.Anthropic caching docs, as of October 31, 2026
RefreshNo extra chargeThe page states: "The cache is refreshed for no additional cost each time the cached content is used."Anthropic caching docs, as of October 31, 2026

How the three providers differ

The mechanisms differ, and so does what each vendor tells you. Where a vendor has not published a number on its page, this article leaves it out.

ProviderHow caching startsMinimum prefixPublished price effectLifetimeSource
AnthropicYou mark the prefix with cache_control.512, 1,024, 2,048 or 4,096 tokens, depending on the model. A shorter prefix is processed without caching and no error is returned.1.25 times write (5 minutes), 2 times write (1 hour), 0.1 times read on the general rate.5 minutes by default, refreshed on each use. 1 hour is optional.Anthropic caching docs, as of October 31, 2026
OpenAIEnabled by default for supported models.1,024 tokens for GPT-5.6 and later.Cached input is discounted by up to 95 percent. The page does not give one multiplier for every model, so this article does not compute with it.Not captured for this article. Read the cache lifetime section before you plan. The page says caching "does not guarantee that every request reuses stored KV tensors or has lower latency".OpenAI prompt caching guide, as of October 31, 2026
Google GeminiImplicit caching is enabled by default for Gemini 2.5 and newer models.2,048 tokens for 2.5 Flash and Pro. 4,096 for newer models.The page states no discount percentage. Vendor has not published one there, so measure it on your invoice.The page states no lifetime. Measure it on your own traffic.Google caching docs, as of October 31, 2026

Minimum lengths and model lists change often. Re-read each page for your exact model before you decide. This article gives no dollar prices because base prices vary by model and date. Look yours up on the provider pricing page and record the date.

When does caching start to pay?

Let P be the tokens in the fixed prefix, p the base input price per token, and n the number of requests that reuse the prefix inside one lifetime. The first request writes the cache and the next n − 1 requests read it. Output tokens and the changing part of the prompt are billed at their normal rates.

no_cache_cost   = n × P × p
cached_cost     = (m_w + r × (n − 1)) × P × p
ratio(n)        = (m_w + r × (n − 1)) / n          prefix cost only

with changing tokens s per request (billed at p, uncached):
ratio_total(n)  = (m_w × P + r × P × (n − 1) + n × s) / (n × (P + s))

caching wins when:   m_w + r × (n − 1) < n
                     n > (m_w − r) / (1 − r)

Units: P and s are tokens. p is dollars per token. n is a count of requests. m_w and r are multipliers with no unit. With m_w = 1.25 and r = 0.1, the break-even is n > 1.15 / 0.9, which is about 1.28, so the first whole number that wins is n = 2. With the 1-hour write, m_w = 2, so n > 1.9 / 0.9, about 2.11, so you need n = 3 or more.

Requests in one lifetime (n)Prefix cost ratio, 5-minute writeResultNote
11.251.250Costs 25 percent more than no caching.
2(1.25 + 0.1) / 20.675First request count where caching wins.
3(1.25 + 0.2) / 30.483
5(1.25 + 0.4) / 50.330
10(1.25 + 0.9) / 100.215
20(1.25 + 1.9) / 200.158
Very large1.25 / n + 0.1 × (n − 1) / nApproaches 0.100The read multiplier is the floor.

Computed from the Anthropic multipliers 1.25 (write) and 0.1 (read), as of October 31, 2026, source Anthropic caching docs. A ratio of 1 means the same cost as no caching.

Worked example with assumed inputs

These inputs are illustrations you should replace. Assume P = 4,000 prefix tokens, s = 500 changing tokens per request, and n = 10 requests inside one lifetime, at the 5-minute write and the 0.1 read multiplier.

  • No caching: 10 × (4,000 + 500) = 45,000 input tokens billed at p.
  • With caching: 1.25 × 4,000 + 0.1 × 4,000 × 9 + 10 × 500 = 5,000 + 3,600 + 5,000 = 13,600 token equivalents at p.
  • Ratio: 13,600 / 45,000 is about 0.302. The prefix alone is 0.215. The changing tokens pull the total ratio up, so a long changing suffix shrinks the benefit.

Multiply the token equivalents by your own p to get dollars. Output tokens are not in this calculation.

How does a fleet set n?

Each use refreshes the lifetime at no extra charge, so what matters is the gap between consecutive uses of the prefix. A request is a read if the gap since the previous use is within the lifetime. A run of uses linked by such gaps is a chain, and n is the length of the chain: the uses between two gaps longer than the lifetime. If the identical prefix reaches the provider from many devices, their requests can keep one entry alive together. Confirm cache scope with the scope test below before you count shared hits.

Evaluate in this order.

  1. Decide whether the prefix is shared. If the identical prefix comes from F devices and the scope test passed, the stream is the pooled traffic of the fleet. Otherwise the stream is one device.
  2. Take the gap g of that stream. For one device, g is its own gap. For the pooled stream under evenly spaced arrivals, g is about I / F minutes. With real traffic, use the measured pooled 90th percentile of gaps.
  3. Apply the gap rule below to g and to the expected chain length n.
g <= 5 minutes       : 5-minute write. Every use after the first is a read,
                       so the ratio approaches r. Needs n >= 2, else skip caching.
5 < g <= 60 minutes  : 1-hour write. It wins once n >= 3,
                       because 2 + r × (n − 1) < n. With the 5-minute write
                       every use misses and costs 1.25 times.
g > 60 minutes       : no caching for this stream.

expected uses per 5-minute window, evenly spaced arrivals:
per-device:   5 / I          (meaningful only when I <= 5)
fleet-shared: F × 5 / I      (F = devices sending the identical prefix)

Every gap value falls into one branch: up to 5, above 5 up to 60, or above 60. Within a branch, the chain length decides between caching and not caching. The two window formulas are expected counts under evenly spaced arrivals. Random arrivals can give fewer, so use the measured gap percentile for the decision when you have it. If gaps are mixed, the rule is fed by the percentile you name in advance, for example the 90th.

Assume F = 60 devices and I = 30 minutes. One device alone has g = 30, so by the per-device branch it takes the 1-hour write if its chain reaches n = 3 or more. With a shared prefix and a passed scope test, the pooled gap is about 30 / 60 = 0.5 minutes, which is in the first branch, so the 5-minute write applies to the shared stream. Its expected count is 60 × 5 / 30 = 10 per 5-minute window, and the ratio from the table is 0.215. Steady fleet traffic keeps the entry alive across many windows, so the ratio approaches r. For stopping device retry storms with a circuit breaker, see Circuit Breaker Pattern for Device Fleets and Cloud Retries.

The 1-hour write also helps a single device with long gaps. Take 6 requests from one device at 10-minute spacing, all inside one hour. With the 5-minute write, every request misses: 6 × 1.25 = 7.5 against 6, a ratio of 1.25. With the 1-hour write, the cost is 2 + 5 × 0.1 = 2.5 against 6, a ratio of about 0.417. If the same device keeps this rhythm, each use refreshes the entry and the chain continues. This example is arithmetic on assumed spacing.

Inputs, and which are yours to replace

VariableMeaningStatusWhat to do
PTokens in the fixed prefix (system prompt, fixed tool text, shared examples)Your assumptionCount it with the provider tokenizer. Compare it with the minimum cacheable length of your model.
sTokens in the part that changes on every request (user input, device state, time)Your assumptionReplace with the average from prototype logs.
nRequests that reuse the same prefix inside one cache lifetimeYour assumptionSee the fleet formula below. Measure the gaps between requests in your own logs.
m_wWrite multiplierPublished1.25 for the 5-minute lifetime, 2 for the 1-hour lifetime (Anthropic page, as of October 31, 2026).
rRead multiplierPublished0.1 on the general rate (Anthropic page, as of October 31, 2026). Replace with the value listed for your model.
pBase input price per tokenLook up on the day you decideThis article does not quote it. Read your model on the provider pricing page and record the date.
F, IDevices sharing one prefix, and the average minutes between requests from one deviceYour assumptionReplace with fleet plan and prototype logs.

What are the common cost traps?

These follow from the published mechanics above. They come from engineering reasoning about how the numbers behave. None describes an incident at any company.

  • Per-device text inside the prefix. Cache hits require 100 percent identical segments up to the marked block. If a device ID, a timestamp or a user name sits before the marker, no two devices send the same prefix and nothing is ever read from cache. Put fixed text first and per-device text after it.
  • Sparse devices that share nothing. If one device talks every 20 minutes and its prefix is private to it, every request lands after the 5-minute lifetime has ended. Every request then pays the 1.25 times write rate on the prefix, which costs more than no caching. If the device keeps a steady rhythm under an hour, the 1-hour write is the candidate.
  • A prefix below the minimum length. Anthropic processes a short prefix without caching and returns no error. A prompt you trimmed during a firmware rewrite can quietly fall under the line, and the bill rises with no alert unless you log cached token counts.
  • Using the 1-hour write too early. The 1-hour write costs 2 times the base rate. It beats no caching only when the chain of uses it keeps alive has 3 or more uses: 2 + 0.1 × (n − 1) is below n once n is 3 or more. Refresh extends the chain, so count the uses between two gaps longer than an hour. For a chain of one or two uses, it loses.
  • Counting a guaranteed hit. OpenAI states that caching does not guarantee that every request reuses stored data or has lower latency. Model the hit rate as an assumption and run a low case.
  • A prompt update that resets the cache. Any edit to the text before the marker changes the prefix. After a prompt change rolled out to the fleet, each distinct prefix pays a new write. Roll prompt changes in waves and budget for the extra writes.
  • Applying one provider's numbers to another. Anthropic publishes write and read multipliers. OpenAI publishes a ceiling of 95 percent off cached input. Google publishes neither on its caching page. Do not copy the Anthropic formula to the other two.

What should you measure on your own board and backend?

The published pages do not tell you your request rhythm, your hit rate or your cache scope. We have not measured them, and no result appears in this article. Measure them on a prototype before you build the cost model into a price.

What to measureHowStatistic and pass line
Gap between requests, per device and for the fleetAt your gateway, log a timestamp and a device ID for every model call during a prototype run. Compute the gaps for each device and for all devices pooled.You set the sample count. A 90th percentile needs at least about 100 gaps, with at least 10 of them above the percentile. Collect more if the daily pattern varies. For the share of gaps longer than 5 minutes, report a Wilson 95 percent interval. Feed the rule with the percentile you named in advance. Write the 5-minute and 60-minute decision before you look at the data.
Prefix identityHash the exact prefix bytes at the gateway for each request. Count distinct hashes per hour.This needs a count and no sampling. You expect one hash per prompt version. Any extra hashes point to per-device text or formatting drift. Set the allowed count in advance.
Prefix length against the minimumCount prefix tokens with the provider tokenizer for every prompt version you ship.This is an exact count. Pass if it clears the minimum for your model with a margin you choose. Re-run after every prompt edit.
Real hit rateLog the cached token count the provider returns with each response, for example the cached_tokens field that OpenAI describes. Label a request a hit if cached tokens are above zero. Divide hits by requests.Run at least a full daily cycle and report the hit rate with a Wilson or Clopper-Pearson 95 percent interval. Compare the lower bound with the break-even hit rate h* = (m_w − 1) / (m_w − r), which comes from h × r + (1 − h) × m_w < 1 with your own m_w and r. Pass if the lower bound clears h* plus your margin. With zero misses in N requests, the upper bound of the miss rate is about 3 / N.
Billed cost against the formulaCompare the invoice line for the test window with the cost the formula predicts from your logged n, P and s.Set the acceptable gap before you read the invoice. A large gap means a hidden input, such as an uncached suffix or a model with different multipliers.
Latency with and without cachingSend the same prompt set with caching on and with the prefix varied so it cannot hit. Record time to first token.Compare the median and the 95th percentile. A 95th percentile needs at least about 200 observations per arm, with at least 5 above the percentile. Latency gains are not guaranteed by the vendor, so the pass line is yours.
Cache scope across devicesSend the identical prefix from two different devices through your backend within one lifetime, and repeat K times at different times of day. Count the second requests that report a cache read.One pair can miss for timing reasons, so a single trial decides nothing. Report reads out of K with a Clopper-Pearson 95 percent interval. With K reads out of K, the lower bound of the miss-free rate is about 1 − 3 / K, so choose K to match your margin. If reads are missing, read the provider documentation on how cache entries are scoped to your account before you count shared hits in n.

Fix every pass line before you run the test. A threshold chosen after you see the result tends to land just under the result.

What should you ask before you commit?

Take this list to your team, and to any supplier who proposes a cloud design for your device.

  • How many tokens are in our fixed prefix, and does it clear the minimum for the exact model we call?
  • What is the gap between requests for one device, and for the pooled fleet, at the percentile we named?
  • Which fields in the prompt change per device or per request, and are they all placed after the cache marker?
  • Does the plan use the 5-minute or the 1-hour write, and which request pattern justifies it?
  • What read multiplier does our model list on the provider page, and on what date did we read it?
  • What does the unit cost look like with a zero hit rate? Can the product margin absorb that case?
  • How do we roll out a new prompt version without every device writing a new cache at once?
  • Do we log cached token counts for every response, and who looks at them?
  • For OpenAI or Gemini, which numbers come from the invoice and which from the docs?
  • Who owns the prefix text, and who approves an edit that resets the cache?

Questions about prompt caching and device cost

Does prompt caching always lower the bill?

No. With the published Anthropic multipliers, a cache write costs 1.25 times the base input price. If the prefix is not read again inside the lifetime, the request costs more than it would without caching. The second use inside the window is where it starts to win (Anthropic caching docs, as of October 31, 2026).

Where should the per-device information go in the prompt?

After the cached block. A hit requires 100 percent identical segments up to and including the block marked for caching, so a device ID or timestamp earlier in the prompt prevents any hit.

Can I trust the OpenAI and Gemini discount?

Plan with the published statements only. OpenAI says cached input is discounted by up to 95 percent and does not guarantee that every request reuses stored data (OpenAI guide, as of October 31, 2026). The Gemini caching page states no discount percentage (Google docs, as of October 31, 2026). Read your own invoice to find the real saving.

What if my prompt is shorter than the minimum?

Anthropic processes it without caching and returns no error, so you pay the normal rate. Minimums listed on the page range from 512 to 4,096 tokens by model, OpenAI lists 1,024 for GPT-5.6 and later, and Google lists 2,048 or 4,096. Count your prefix with the provider tokenizer.

Can Duobay set up caching for my device backend?

We do not publish prices. Gate 0 Feasibility delivers a system architecture document and a costed BOM with landed DDP estimate. By default we test the device and SDK against your backend, and building the backend in your own cloud account is optional. Tell us about your device and we will explain how it works.

If you want to plan the cloud side of your device with a system architecture and a costed BOM, tell us about your device. You can also read how our engineering gates work.

Sources

All pages accessed October 31, 2026. Multipliers, minimum lengths and model lists change, so re-read them before you decide.

Planning a device like this? Tell us what it needs to do. A Duobay engineer replies within 1 business day. Send a project brief →

Related reading

More engineering guides

Have a dev kit and a deadline?

Tell us what the device must do. An engineer replies within 1 business day with questions, not a sales deck.

Talk to an engineer