Gradient LabSign up free

Trending › Model launch

GPT-6.2 and prompt caching: why repeated input costs 95% less

OpenAI’s GPT-6.2 Astra charges $8 per million input tokens but only $0.40 when the input is cached, 95% less. Prompt caching reuses work the model already did on a repeated prefix, and for agents that re-send long context every turn it changes the bill completely.

Watch it move. This is an animated lesson on Gradient Lab.

Start the animated lesson

Step by step

Concept

Agents re-send the same context

Chat and agent apps send the model its whole context on every turn: the system rules, tool descriptions, files and conversation so far, plus one new message. Most of that long prompt is identical to the previous turn.

Each row is one turn. Grey: the repeated prefix. Yellow: the new part.

Key idea

Reuse the work on the prefix

Reading a prompt means computing keys and values for every token in every layer, the KV cache. If the start of the prompt is byte-for-byte the same as before, the provider can reuse the saved keys and values for that prefix and only process the new tokens. That is prompt caching.

The saved prefix (teal) is reused; only the yellow tail is computed.

Insight

The GPT-6.2 prices

OpenAI lists GPT-6.2 Astra at $8 per million input tokens, $0.40 for cached input and $40 for output. GPT-6.2 Sol is $2, $0.10 cached and $10. In both cases cached input is 95% cheaper than fresh input, and Astra’s cached price is 60% lower than GPT-6 Astra’s.

Bar heights to scale: Astra price per million input tokens.

Practice

Work it out: 20 turns

Say an agent keeps 100,000 tokens of context and runs 20 turns on Astra. Without caching: 20 × 100,000 tokens × $8 per million = $16. With caching: the first turn pays $0.80, and the next 19 pay $0.04 each ($0.76), so about $1.56 for the input, roughly a tenth. (New tokens and output cost extra in both cases.)

Left: cost without caching. Right: with caching.

Practice

How to get cache hits

Caching only works on an exact prefix. Put things that never change first (rules, tool definitions, long documents) and things that change last (the new message). Adding a timestamp or reordering tools at the top breaks the match and you pay full price again.

Stable parts first, changing parts last.

Quick check: You add the current time at the very start of your system prompt. What happens to caching?

Pseudocode

# every agent turn re-sends the same long prefix
prompt = system_rules + tool_docs + files + history + new_message

# provider side: the prefix was processed last turn
if prefix_hash in cache:
    reuse saved keys/values for the prefix   # cheap
    process only the new tokens              # full price
else:
    process everything and save the prefix

# GPT-6.2 Astra (per million tokens): input $8, cached $0.40, output $40

Go deeper

Sources

  1. OpenAI: Introducing GPT-6.2 Astra and Sol
  2. gHacks: OpenAI releases GPT-6.2 Astra and Sol with lower API prices
  3. Technobezz: GPT-6.2 Astra cuts API token prices by 20%