CodexHowSupport Us

Prompt Caching, Fully Specified

Prompt caching — published mechanics

Minimum cacheable prefix (GPT-5.6+)1,024 visible input tokens — varies by request settings on earlier models
Read price (GPT-5.6+)0.1× the uncached input rate; 0.05× on GPT-6.1 Sol; 0.05× on GPT-6.1 Terra — the same whichever lifetime wrote the entry
Write price (GPT-5.6+), default lifetime1.25× the uncached input rate for the 30-minute lifetime, instead of it — never on top of it
Write price (GPT-5.6+), 12-hour lifetime2.5× the uncached input rate, also instead of it (Responses API, since 2026-10-20)
Write price (earlier models)No additional charge — a written token bills as ordinary input
Cache writes per requestUp to 4; an implicit breakpoint uses one slot
Breakpoints checked for reads (GPT-5.6+)The first 2 and latest 50 explicit breakpoints
Lifetime (GPT-5.6+)prompt_cache_options.ttl: "30m" (default) keeps an entry eligible for at least 30 minutes after its latest write or reuse; "12h" for at least 12 hours. A per-breakpoint ttl overrides the request's
Mixing lifetimesEach token is billed once, at the longest lifetime among the writes covering it. Upgrading an entry already cached for 30 minutes to 12 hours charges a new write, with no credit for the first
Lifetime (earlier models, in_memory)Typically 5–10 minutes of inactivity, up to 60 minutes
Lifetime (earlier models, 24h)Up to 24 hours
prompt_cache_keyGPT-5.6+: routing is automatic; a key only separates cache accounting. Earlier models: keep about 15 requests/minute per key
Routing-hash lengthNot published ("varies by model")
Maximum discount on reused tokensUp to 95%

Per-model cache economics (Standard, short context) — break-even computed from each model's own cells

GPT-6 Astraread $1.00 vs input $10.00 · write $12.50 ($25.00 for 12 hours) · break-even 0.278 reads (1.667 for 12 hours)
GPT-6.1 Solread $0.10 vs input $2.00 · write $2.50 ($5.00 for 12 hours) · break-even 0.263 reads (1.579 for 12 hours)
GPT-6.1 Terraread $0.05 vs input $1.00 · write $1.25 ($2.50 for 12 hours) · break-even 0.263 reads (1.579 for 12 hours)
GPT-6 Solread $0.20 vs input $2.00 · write $2.50 ($5.00 for 12 hours) · break-even 0.278 reads (1.667 for 12 hours)
GPT-6 Lunaread $0.01 vs input $0.10 · write $0.125 ($0.25 for 12 hours) · break-even 0.278 reads (1.667 for 12 hours)
GPT-5.6 Solread $0.40 vs input $4.00 · write $5.00 ($10.00 for 12 hours) · break-even 0.278 reads (1.667 for 12 hours)
GPT-5.6 Terraread $0.20 vs input $2.00 · write $2.50 ($5.00 for 12 hours) · break-even 0.278 reads (1.667 for 12 hours)
GPT-5.6 Lunaread $0.02 vs input $0.20 · write $0.25 ($0.50 for 12 hours) · break-even 0.278 reads (1.667 for 12 hours)
GPT-5.5read $0.50 vs input $5.00 · no write surcharge · break-even 0.000 reads
GPT-5.4read $0.25 vs input $2.50 · no write surcharge · break-even 0.000 reads
GPT-5.4 Miniread $0.075 vs input $0.75 · no write surcharge · break-even 0.000 reads
GPT-5.4 Nanoread $0.02 vs input $0.20 · no write surcharge · break-even 0.000 reads
GPT-5.3 Codexread $0.175 vs input $1.75 · no write surcharge · break-even 0.000 reads

What silently invalidates a cache match

A timestamp or the current date/time interpolated into the system promptThe prefix differs on every request, so there is never a prior entry to match against.
A request id, session id or UUID early in the contentSame failure as a timestamp — every request becomes byte-unique from that point onward.
Serializing a dict/object without a stable key order, or iterating a setNon-deterministic serialization changes the exact bytes run to run, which is a different prefix to the cache.
Building the tool list per user, per mode, or behind a feature flagTools render early in the request. Any change there invalidates everything that follows, system prompt included.
Switching model mid-sessionCaches are model-scoped by construction. The new model starts cold, full price, every time.
Changing the top-level reasoning.effort between turns on a GPT-6 modelOpenAI warns this can rewrite the hidden system instructions. Append a configuration_update input item instead, which keeps the cached prefix intact.
Summarising, compacting or truncating earlier turnsThe rewritten history no longer matches the cached prefix from the first changed token onward.
A prefix under 1,024 tokens before the marked breakpoint (GPT-5.6 and later)Below the minimum, nothing caches and no error is raised — it is silent.
Expecting more than 4 cache writes from one requestEach request can create up to four cache writes, and an implicit breakpoint uses one of the four slots.
Traffic above roughly 15 requests/minute on one cached prefixCached states live on individual machines; above that rate, overflow routing can send requests to a machine without the entry.
Reusing a prefix across gaps longer than the default 30-minute lifetime (GPT-5.6 and later)The entry is only eligible for cache-read pricing for its minimum lifetime. For material reused hours apart, the Responses API offers a 12-hour lifetime at 2.5x input per write instead of 1.25x; reads cost the same either way.
Upgrading a prefix already cached for 30 minutes to the 12-hour lifetimeOpenAI charges a fresh 12-hour write for those tokens, with no credit for the earlier write. Choose the lifetime on the first write.

Prompt caching is the richest cost mechanic OpenAI publishes, and the easiest to get wrong quietly: a mistake doesn't raise an error, it just produces a smaller discount than you expected.

How it bills

Every input token is billed at exactly one of three rates — uncached input, cached input, or cache write. A write is not a fee added on top. On GPT-5.6 and later, a written token costs 1.25x the uncached rate instead of that rate — or 2.5x if you ask for the 12-hour lifetime — and later reads cost 0.1x whichever lifetime wrote the entry, except on GPT-6.1 Sol and GPT-6.1 Terra, where reads cost 0.05x. On earlier models there is no write surcharge at all: a written token bills as ordinary input, which is cheap but never free.

Why the write price changes the math

Because writes cost more on GPT-5.6 and later, caching there pays off only once a prefix is read back. With the default lifetime, the published rates put that break-even below a single read on every model — 0.28 reads at the general read rate, a little lower on GPT-6.1 Sol and Terra. The 12-hour lifetime moves it out to 1.67 reads at the general rate: worth paying for a prefix you will read back over hours, not one a conversation reuses every minute anyway. OpenAI's own worked example checks the default case: at the general read rate, one write and one full reuse cost 1.35 times the prefix's ordinary input cost, against paying full input for both requests without caching. The per-model table above computes both break-evens from each model's own price cells.

What changed in how caching works

On GPT-5.6 and later, OpenAI routes cache traffic automatically: prompt_cache_key no longer improves hit rates and only separates cache accounting between your users. On earlier models a stable key still matters for routing. Lifetime changed shape too. Newer models keep an entry for at least 30 minutes after its last write or read by default, or — since October 20, 2026, in the Responses API — for at least 12 hours, chosen per request or per breakpoint with prompt_cache_options.ttl. Older models use in_memory or extended 24h retention instead. Two billing rules come with the longer lifetime: a token covered by several writes is billed once, at the longest lifetime among them, and upgrading an entry already cached for 30 minutes to 12 hours charges a fresh write with no credit for the first. GPT-5.6 and later also offer explicit breakpoints, a prewarm option that fills the cache without generating output, and Prompt Cache Diagnostics, which explains individual misses.

What invalidates a cache

A prefix that isn't byte-identical doesn't match. A timestamp, a request id, unstable key ordering, a per-user tool list, compaction of earlier turns — or on GPT-6, changing top-level reasoning effort mid-conversation instead of appending a configuration_update item — each makes requests unique from that point on.

Verified 2026-10-28 against https://developers.openai.com/api/docs/guides/prompt-caching.

Could not confirm: The routing-hash length: the guide says only that "the number of tokens hashed varies by model", so none is shown. The 12-hour write rate is printed on the pricing page as its own column, computed by the page as the input rate times the multiplier above; this site checks those cells against the multiplier rather than storing a second price per model.

Checked: https://developers.openai.com/api/docs/guides/prompt-caching · https://developers.openai.com/api/docs/pricing · https://developers.openai.com/api/docs/changelog · https://developers.openai.com/api/docs/models/gpt-6.1-terra