Codex

Cached input tokens in Codex: what they save

Cached input tokens are the part of Codex context served from the prompt cache. Learn how to raise the cached share and what it does to your bill.

Quick answer

Cached input tokens are context the provider already processed and can reuse at a lower rate. Codex gets a high cached share when the beginning of the prompt stays identical between turns. Editing the system prompt, AGENTS.md, or the start of the conversation resets the cache and makes the next turn more expensive.

What makes a prefix cacheable

The cache works on a stable prefix. Everything before the first changed token can be reused; everything after must be processed again. That is why a long conversation with a stable system prompt caches well, while a session that edits its instructions every turn does not.

ChangeEffect on cache
New user message at the endPrefix preserved
Edited AGENTS.mdCache reset from that point
New sessionNo cache until the first repeat
Switched modelCache does not carry over

Raise the cached share

  • Keep instructions stable for the life of a session.
  • Put long, unchanging context first.
  • Put the changing request last.
  • Avoid restarting the session for every small follow-up.
  • Do not edit config or instruction files mid-task.

These habits reduce cost without reducing context. The context is still there; it is just cheaper on repeat.

Verify the saving

Compare cached input with total input across two sessions doing similar work. A healthy long session often shows a cached share above half. In UsageAtlas, the token detail view shows both fields side by side.

Make caching work for you

Caching rewards a stable prefix. If your instructions, file list, and early turns stay the same between requests, the provider can reuse them at a lower rate. If every request starts with a different summary, there is nothing to reuse.

  1. Put durable instructions first and keep them byte-identical.
  2. Avoid timestamps and random IDs in the system prompt.
  3. Continue a thread for related work rather than restarting with a new summary.
  4. Start a new thread when the task genuinely changes.

The savings show up as a lower effective input rate, not as fewer tokens, so read cache read tokens before comparing totals across tools.

Questions, answered

Are cached input tokens free?

No. They are discounted, not free. The exact rate depends on the provider and model.

Why did my cached share drop to zero?

Something early in the prompt changed, or you started a new session or model. The cache only reuses an identical prefix.

Does caching change the answer quality?

No. It changes how the provider processes repeated context, not what the model sees.

Browse by topic