DEV Community

Cover image for The 12-Hour Cache Only Pays After Two Rewrites
Andre Burgstahler
Andre Burgstahler

Posted on Originally published at Medium

The 12-Hour Cache Only Pays After Two Rewrites

OpenAI's 12-hour cache opt-in costs twice as much to write as the 30-minute default. Here's the break-even at GPT-6.2 list prices, when it still loses, and how to check your own usage.

This article was first published on Medium. The canonical URL is https://medium.com/@r3dtuxedo/the-12-hour-cache-only-pays-after-two-rewrites-d7e3007e47e6.

Abstract illustration: on a dark navy background, a long glowing teal arc holds three off-white session blocks across a day, while below it three short amber arcs fade out in the gaps between those sessions
A longer lifetime costs more to start. It only wins if the short cache would have gone cold more than once.

TL;DR

  • On GPT-5.6 and later, the Responses API default is a 30-minute minimum cache lifetime at 1.25× the uncached input price. Setting prompt_cache_options.ttl to "12h" raises the write rate to 2.5×. Reads are the same either way: 0.05× on GPT-6.2 Astra, GPT-6.2 Sol, GPT-6.1 Sol and GPT-6.1 Terra, and 0.1× on most other GPT-5.6+ models.
  • At Standard short-context list prices, a 12-hour write on gpt-6.2-astra is $20 per million tokens, against $10 for 30 minutes. The longer option starts to win once a stable prefix would otherwise expire and be rewritten twice: a third session start after gaps longer than 30 minutes.
  • Two session starts are a slight loss for 12 hours. So is any prefix that changes often, any workload that already reuses context inside 30 minutes, and any upgrade of a still-valid 30-minute entry to 12 hours (that upgrade is billed as a new 12-hour write, with no credit).
  • This is a minimum lifetime for cache-read pricing, not a data-retention setting, and not a guarantee that every later request will hit. Measure cached_tokens, ttl_30m_tokens and ttl_12h_tokens per step before you flip the default.

The 12-hour cache looks like an easy win. After GPT-6.2 Astra and Sol arrived, OpenAI's prompt-caching guide made the control explicit: in the Responses API, you can keep a prompt prefix eligible for cheap cache reads for a 12-hour minimum instead of the default 30 minutes. A long agent session with a lunch break, or a shared instruction prefix reused all afternoon, no longer has to pay a fresh write just because the short cache expired.

The catch is the write price. A 12-hour write costs twice as much as a 30-minute write. On GPT-6.2 Astra, that is $20 per million tokens against $10, at Standard short-context list prices. The longer option only starts to win once a stable prefix would otherwise expire and be rewritten twice.

The figures below are arithmetic from those list prices, under stated assumptions. They are not measurements from production traffic, and they are not a claim about what any one session will do. The rest of this article is the break-even, a worked example, the cases where 12 hours still loses, and the usage fields that tell you whether your prefix is actually being cached at all.

A 12-hour write costs twice as much as a 30-minute write. It only starts to win after two rewrites.

What you are actually buying

Prompt caching, in OpenAI's docs, stores key-value tensors for an unchanged prefix at the start of the prompt, not the tokens themselves. A later request can reuse that work if the rendered prefix matches. The billing consequence is simple: a token is charged at the uncached input rate, the cached-input rate, or the cache-write rate, not at more than one of those at once.

For GPT-5.6 and later, the caching guide sets two minimum lifetimes in the Responses API, via prompt_cache_options.ttl:

  • "30m" is the default. The write rate is 1.25× the uncached input-token rate. The docs describe this as the setting for conversations and agent steps that reuse context frequently.
  • "12h" is opt-in. The write rate is 2.5× ordinary input. The docs describe this as the setting for stable instructions or reference material reused across longer gaps.

Those write rates are totals, not a surcharge stacked on top of ordinary input. Cache-read rates do not change with the lifetime you pick. On GPT-6.2 Astra, GPT-6.2 Sol, GPT-6.1 Sol and GPT-6.1 Terra, reads are 0.05× uncached input. On most other GPT-5.6+ models they are 0.1×.

The model IDs and Standard short-context list prices, from OpenAI's pricing page and the GPT-6.2 Astra and GPT-6.2 Sol model pages, all fetched on 18 November 2026, are:

Model Input 30-minute write 12-hour write Cached read Output
gpt-6.2-astra $8 $10 $20 $0.40 $40
gpt-6.2-sol $2 $2.50 $5 $0.10 $10

All figures are US dollars per million tokens, Standard tier, short context (272,000 input tokens or fewer). Prices move. Re-check the pricing page before you rely on a specific dollar amount.

The Astra and Sol model pages describe the listed cache-write price as being "for 30 minutes of retention," and then quote the 12-hour write in dollars. The caching guide is more careful, and that is the wording this article follows: these values are a minimum lifetime that governs eligibility for cache-read pricing. They are not a deletion deadline, and they do not change OpenAI's maximum data-retention policy. More on that distinction later.

Two other limits matter before you do any maths. A prefix has to reach the model's minimum cacheable length before it can be cached at all: 1,024 tokens for GPT-5.6 and later, not counting hidden system content. And if a request goes over 272,000 input tokens, input and cache rates double for the whole request, and output is billed at 1.5× the short-context rate. The examples below stay under that threshold.

The 12-hour option is documented for the Responses API. The Astra model page lists Chat Completions as a supported endpoint, but that is not the same as saying prompt_cache_options.ttl works there. This article does not assume that it does.

The break-even, with the assumptions in the open

Take a stable prefix of T tokens: tools, developer instructions, reference material, whatever you expect to send unchanged. Ignore new tokens after that prefix, and ignore output. Those costs are the same under both lifetimes if the model does the same work.

Now suppose you start S sessions far enough apart that a 30-minute cache would have expired each time, so each start is a fresh write under the default. Under a 12-hour minimum, the first start is a 12-hour write and the later starts are cache reads, if the prefix still matches and a cache entry is actually found.

Let P be the uncached input price per million tokens, and r the read multiplier (0.05 or 0.10). Then, for that prefix only:

  • 30-minute default: 1.25 P × S
  • 12-hour opt-in: 2.5 P + r P × (S − 1)

Set them equal and you get S = (2.5 − r) / (1.25 − r). That is about 2.04 at the 0.05× read rate, and about 2.09 at 0.10×.

In plain language: the 12-hour option starts to win at the third session start, which is two rewrites after the first write. Two session starts — one rewrite — is a slight loss for 12 hours, because you have paid the double write and only avoided one 30-minute rewrite, while the second start is still a cheap but not free read.

The assumptions behind that sentence, all of which have to hold at once:

  • Standard, short-context list prices, not Batch, Fast, Ultrafast, or a regional or FedRAMP endpoint.
  • Gaps between session starts longer than 30 minutes, and all of those starts inside one 12-hour window.
  • The prefix is unchanged, at or above the 1,024-token minimum, and every later start is a cache hit under the 12-hour option. The docs do not promise that. A minimum lifetime makes a hit eligible to be billed as a read. It does not guarantee that the tensors are still there, or that latency will be lower.
  • You are not upgrading a still-valid 30-minute entry to 12 hours in the middle (that path has its own, worse, billing).
  • Within-session follow-ups that would be cache reads under both policies are left out, because they cancel.

If those are too tidy for your traffic, use the usage fields in the last section and plug your own counts into the same formula. Do not treat the worked example as a benchmark.

A worked example at Astra list prices

Take GPT-6.2 Astra and a hypothetical 20,000-token stable prefix: tools, a developer message, maybe a short reference file. That is a size I picked to make the arithmetic easy, not a size measured from anyone's logs. At the Standard short-context rates:

  • a 30-minute write is $0.20
  • a 12-hour write is $0.40
  • a cache read is $0.008

Three session starts with gaps longer than 30 minutes — morning, after lunch, and early evening — then cost $0.60 under the 30-minute default, and $0.416 with a 12-hour write plus two reads. The 12-hour option saves $0.184 on that prefix, about 31 percent, in this hypothetical.

Two session starts go the other way: $0.40 against $0.408. You have paid the extra write and only avoided one expiry, and the second start still costs a read. It is close to a wash, and it is a wash in the wrong direction.

The same multipliers apply to gpt-6.2-sol, at a quarter of the dollar amounts: a 20,000-token prefix is $0.05 to write for 30 minutes, $0.10 to write for 12 hours, and $0.002 to read. Three session starts are $0.15 versus $0.104. Scale the prefix to 80,000 tokens on Astra and everything quadruples: $2.40 versus $1.664 for three starts.

Line chart comparing prefix cost in US dollars against the number of session starts for a hypothetical 20,000-token prefix on gpt-6.2-astra at Standard short-context list prices. The 30-minute default rises in a straight line from 0.20 dollars at one start to 1.20 dollars at six starts. The 12-hour option starts at 0.40 dollars and is nearly flat, crossing below the default just after two starts and reaching 0.44 dollars at six starts. A marker highlights the third start, where 12 hours becomes cheaper.
Hypothetical prefix cost only, at 18 Nov 2026 Standard short-context list prices. Gaps between starts are assumed to be longer than 30 minutes, with a 100 percent cache hit under the 12-hour option after the first write. Not a measured bill.

The chart is deliberately boring after the third start. Once you have paid the 12-hour write, each extra qualifying start adds only a read. Under the default, each extra start adds another 30-minute write. That is why 12 hours is a bet on gaps, not on how hard the model works inside a session.

What a day of gaps looks like

The same 20,000-token Astra example, laid out on a clock, makes the bet easier to see. Three coding sessions, each more than 30 minutes from the last, all inside twelve hours. Under the default, each session start is a write. Under 12 hours, only the first one is.

A 12-hour timeline from 09:00 to 21:00 with three sessions, at 09:00, 13:30 and 17:00. The 30-minute-default row shows an amber write at the start of each session and a fade in the gaps. The 12-hour row shows one larger teal write at 09:00 and teal reads at 13:30 and 17:00. A footer states the hypothetical totals: 0.60 dollars versus 0.416 dollars for a 20,000-token gpt-6.2-astra prefix.
Same hypothetical 20,000-token gpt-6.2-astra prefix as the chart. Session times are illustrative. The 12-hour line stays cheap only if the prefix does not change and the later starts actually hit the cache.

That pattern — long sessions with breaks, or a shared prefix reused by several jobs through the day — is exactly what the docs recommend 12 hours for. The complementary pattern is also in the docs: keep the stable material at the front of the prompt, give that breakpoint a "12h" lifetime, and leave session-specific context on "30m".

Here is the official Responses API shape for that mix, from the caching guide, with the placeholder text left in place. The example uses gpt-6.2-sol. Explicit-only mode means the current question, sitting after the last breakpoint, is billed as ordinary input and does not incur a cache-write charge:

{
  "model": "gpt-6.2-sol",
  "prompt_cache_options": { "mode": "explicit", "ttl": "30m" },
  "input": [
    {
      "role": "developer",
      "content": [
        {
          "type": "input_text",
          "text": "Shared instructions and reference material reused throughout the day...",
          "prompt_cache_breakpoint": { "mode": "explicit", "ttl": "12h" }
        }
      ]
    },
    {
      "role": "user",
      "content": [
        {
          "type": "input_text",
          "text": "Session context reused over the next few minutes...",
          "prompt_cache_breakpoint": { "mode": "explicit" }
        },
        {
          "type": "input_text",
          "text": "The current question, which does not need a cache write..."
        }
      ]
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

The request-level ttl applies to the implicit breakpoint and to any explicit breakpoint that does not set its own. prompt_cache_breakpoint.ttl overrides one breakpoint. Omit both and you get "30m". An unsupported value returns 400 invalid_request_error. Each prefix you want to cache still has to meet the minimum cacheable length. And a later 12-hour write in the same request covers earlier selected breakpoints in that prefix as well, billed at the longer lifetime.

When 12 hours still loses

The maths is only half the decision. These are the cases where paying 2.5× is the expensive choice, even if the feature is on and working.

You only come back once. Two session starts after a gap, in this Astra example, cost $0.408 with 12 hours and $0.40 with the default. If your day is one morning block and one afternoon block, stay on 30 minutes unless the prefix is large enough that you care about a fraction of a cent, or you already know a third start is coming.

You already reuse the prefix inside 30 minutes. Tight agent loops, evaluation jobs, and anything that keeps stepping without a long pause are what the default is for. You still pay 1.25× once, then 0.05× or 0.1× to read. Paying 2.5× to write the same prefix does not buy you anything if it would not have expired.

The prefix is not stable. Cache reuse needs the entire rendered prefix to match. A timestamp, a changing tool list, a model switch, a verbosity or effort change that rewrites instructions, or compaction that replaces earlier context can all force a new write. If that happens often, a 12-hour write is just a more expensive miss. I went through the "edit in the middle and everything after it is billed again" version of this in Trimming Context Can Make Your Agent More Expensive. The 12-hour option does not change that rule. It only changes how long a matching prefix stays eligible.

You upgrade a live 30-minute entry to 12 hours. The caching guide is blunt: upgrading valid 30-minute coverage to 12 hours charges a new 12-hour write for those tokens, with no credit for the earlier write. If you already paid 1.25×, and then decide you wanted 12 hours after all, you pay 2.5× on top. Any portion that already has valid 12-hour coverage stays a cache read.

A later 30-minute read does not restart the 12-hour clock. If a request billed as a 30-minute read happens to use an entry that still has 12-hour coverage, the docs say it keeps the later of the existing expiry and 30 minutes after the read. It does not extend the 12-hour window, and it does not charge another write. Plan the lifetime on the write, not on incidental reads.

The prefix was never cached in the first place. A 12-hour ttl cannot help a block that never entered the cache: a prefix under 1,024 tokens, or a system prompt stuffed into a field that is not part of the reusable prefix. OpenCode's v2.3.2 notes are a useful caution here: GPT-6.2 was not caching a system prompt sent in the Responses instructions field, so every step re-billed it as uncached input. The docs also say that top-level instructions cannot contain an explicit breakpoint; reusable developer instructions belong in an input_text block inside a developer message. If cached_tokens stays at zero after the second step, fix that before you buy a longer lifetime.

You are on a different price list. Batch is half of Standard. Fast is twice Standard. For Astra and Sol, Ultrafast is 3× Standard through 28 February 2027 and 6× from 1 March 2027, Pacific time. Regional processing and FedRAMP endpoints add a 10% uplift on models released on or after 5 March 2026. Over 272,000 input tokens, input and cache rates double for the whole request. The break-even ratio is the same whenever the 1.25× / 2.5× / 0.05× (or 0.10×) multipliers still hold, but the dollars are not the ones in the chart. Re-price it.

Measure it, then flip the default

Do not turn on "12h" globally and look at the monthly bill. The Responses API already splits the write lifetimes in usage. The caching guide's checklist is enough:

  • After turn two of a run that should have been a hit, look at usage.input_tokens_details.cached_tokens. That field counts billed reads. It excludes tokens charged as writes, including upgrades from 30-minute to 12-hour coverage. If it is still zero, the lifetime is not your problem yet.
  • Look at input_tokens_details.cache_write_tokens_details.ttl_30m_tokens and ttl_12h_tokens. They do not overlap, they sum to cache_write_tokens, and both are returned even when one is zero.
  • Ordinary input on a request is input_tokens minus cached_tokens minus cache_write_tokens. Input cost is ordinary input at the input price, cached_tokens at the cached-input price, ttl_30m_tokens at 1.25× the input price, and ttl_12h_tokens at 2.5×, then divide by 1,000,000. Do not add cache_write_tokens again after counting its two parts.
  • Compare those four counts per step, not just per day. A good daily hit rate can hide a prefix that is rewritten at the start of every session.
  • Confirm the reusable prefix is at or above 1,024 tokens and that it does not change between the sessions you hope to bridge.
  • If you mix lifetimes, keep the 12-hour breakpoint on the stable front of the prompt and leave the changing suffix on 30 minutes, or uncached.

The docs also note that cached tokens still count toward rate limits, that you cannot clear the cache yourself, and that keeping a session open does not guarantee a hit. If you want a fuller picture of how waiting and repeated resends show up in a bill, Stop Paying Your Agent to Wait is the companion piece on the Anthropic side of this problem.

A minimum lifetime is not a retention policy

This is the distinction worth keeping, especially if you work in an environment that already has a Zero Data Retention rule.

The caching guide says, word for word, that OpenAI may retain entries longer than the requested minimum, and that "12h" "does not set a deletion deadline or change the maximum data-retention policy." The prompt cache stores key-value tensors, not the original prompt text. Those tensors may be stored as encrypted application state in GPU-local storage, with a maximum retention period of 24 hours. All prompt-caching features are described as compatible with Zero Data Retention. Caches are not shared across organizations and cannot be reused across regional processing boundaries.

Separately, the same guide says the minimum lifetime governs eligibility for cache-read pricing. It does not guarantee that every later request reuses stored tensors, or that you will see lower latency. So "12h" is a pricing choice: you are willing to pay 2.5× on the write, in exchange for read eligibility that can survive a gap of hours. It is not a promise that the entry will be there, and it is not a change to how long OpenAI keeps data under its retention terms.

If that trade is real for your traffic — a stable prefix, gaps longer than 30 minutes, and at least three qualifying starts in the window — 12 hours is worth turning on, preferably on the breakpoint that actually stays still. If you only have two starts, or the prefix keeps moving, the default is the cheaper write.

Sources

Top comments (0)