Prompt caching: how cache reads and writes are billed in Zukko
What the bill is made of when prompt caching works: fresh input, cache reads, cache writes and output. The formula and two examples at current prices.
7 min · · экономия · development
If you run an agent over a large project or keep a bot with a long system prompt, most of the bill is input: the same thousands of tokens go to the model with every request. Prompt caching lowers the cost of that input, but it is billed by its own rules. Below is how Zukko charges for cache reads and writes, the formula, and two worked examples at prices as of 6 October 2026.
What prompt caching is and what the bill is made of
The model reads a request from the beginning. If the start of the request (the prefix) — system prompt, tool definitions, the early part of the conversation — matches a recent request, the provider does not process it again but takes it from the cache. So input tokens on the bill fall into three groups:
- fresh input — tokens after the cached prefix, at the normal input price;
- cache write — a prefix stored for the first time; for Claude, a write costs more than normal input;
- cache read — a prefix taken from the cache; for Claude, roughly a tenth of the input price.
Output is billed as usual. In Zukko every model has its own cache read price, while a cache write is charged separately only for Claude in the Anthropic format — see the table below and the Models page in your dashboard.
The formula: prompt caching cost
cost = (fresh input × input price
+ cache read × read price
+ cache write × write price
+ output × output price) / 1,000,000
Prices are in dollars per 1M tokens. Current values for the models most often used with caching:
| Model | Input | Cache read | Cache write | Output |
|---|---|---|---|---|
claude-sonnet-5 | 0.2 | 0.025 | 0.25 | 1.013 |
claude-opus-5-5 | 0.4 | 0.038 | 0.425 | 2 |
gpt-6.1-sol | 0.27 | 0.013 | — | 1.32 |
gemini-3.8-flash | 0.025 | 0.013 | — | 0.088 |
deepseek-v4.1-flash | 0.013 | 0.013 | — | 0.038 |
For GPT, Gemini and DeepSeek a cache write is not charged separately: the first request is billed in full at the input price. The table shows the key point. For Claude the gap between input and cache read is large, so caching changes the bill a lot. For DeepSeek V4.1 Flash input and cache read cost the same, so caching does not affect cost. For Gemini 3.8 Flash a read costs $0.013 versus $0.025 for input — if the provider reports the cache read in its response. Models and prices change: the current list is at GET https://api.zukko.pro/v1/models or on the Models page in the dashboard.
Example 1: an agent session on Claude Sonnet 5
Take the final counters of an agent session: 200,000 tokens read from cache, 5,000 tokens of fresh input, 10,000 tokens written to cache, 3,000 output tokens.
- cache read: 200,000 × 0.025 / 1,000,000 = $0.005
- fresh input: 5,000 × 0.2 / 1,000,000 = $0.001
- cache write: 10,000 × 0.25 / 1,000,000 = $0.0025
- output: 3,000 × 1.013 / 1,000,000 = $0.003039
Total: $0.011539, about 1.2 cents.
Without caching, the same 215,000 input tokens are billed at the input price: 215,000 × 0.2 / 1,000,000 = $0.043, plus $0.003039 of output — $0.046039 in total.
The same volume on claude-opus-5-5: 200,000 × 0.038 + 5,000 × 0.4 + 10,000 × 0.425 + 3,000 × 2 = 7,600 + 2,000 + 4,250 + 6,000 = 19,850, divided by a million — $0.01985. Without caching: (215,000 × 0.4 + 3,000 × 2) / 1,000,000 = $0.092.
Example 2: a bot with long instructions
A 20,000-token system prompt, 100 requests in a row, each adding a 500-token question and getting a 300-token answer. The first request writes the instructions to the cache, the other 99 read them.
- write: 20,000 × 0.25 / 1,000,000 = $0.005
- read: 99 × 20,000 = 1,980,000 × 0.025 / 1,000,000 = $0.0495
- fresh input: 100 × 500 = 50,000 × 0.2 / 1,000,000 = $0.01
- output: 100 × 300 = 30,000 × 1.013 / 1,000,000 = $0.03039
Total: $0.09489. Without caching: 100 × 20,500 = 2,050,000 × 0.2 / 1,000,000 = $0.41, plus $0.03039 of output — $0.44039.
There is one condition: requests must come often enough. According to Anthropic's documentation, the cache lives for 5 minutes by default, and every read extends that. If the bot gets one question an hour, the cache expires each time and the instructions get written again.
When a cache write does not pay off
On Claude Sonnet 5 a write costs $0.25 versus $0.2 for normal input. A prefix that was written and never read costs $0.05 per million tokens more than no caching. A single read saves 0.2 − 0.025 = $0.175 per million, so the write pays off on the very first hit.
With the 20,000-token instructions: one request with a write is $0.005 versus $0.004 without caching; two requests are 0.005 + 0.0005 = $0.0055 versus $0.008.
Two more limits from Anthropic's documentation:
- the minimum cacheable prefix is 1,024 tokens for Claude Sonnet 5 and 512 tokens for Claude Opus 5.5; a shorter prompt goes uncached;
- the cache only hits on an exactly matching prefix. Change a word in the system prompt, the tool set, or the order of early messages, and you get a new write instead of a read.
Hence the practical rule: put everything stable (instructions, tools, reference documents) at the start of the request and everything that changes at the end.
Where caching is counted and where it is not
- Claude — the cache discount comes with the Anthropic format:
POST /v1/messages, Claude Code, the Anthropic SDK. There the gateway sees how much of the input came from cache. In the OpenAI format (/v1/chat/completions) all Claude input is billed at the input price. More on choosing — in the docs on provider format. - GPT — caching is visible in both formats; in the OpenAI format it is in
usage.prompt_tokens_details.cached_tokens. The gateway sees only reads: a write is not charged separately, and the first request is billed in full at the input price. According to OpenAI's documentation, for GPT-5.6 and later models caching turns on by itself when the prefix is at least 1,024 tokens. - DeepSeek, Gemini, Qwen, GLM — cache reads are counted if the provider reports them in the response; there are no writes.
How the same Claude request is billed in the two formats — in the article on caching in Messages and Chat Completions.
Claude Code places cache markers itself, there is nothing to configure — just connect it following the Claude Code guide. In your own Anthropic SDK code you set the marker manually with cache_control:
import anthropic
PRICES = {"input": 0.2, "cache_read": 0.025, "cache_write": 0.25, "output": 1.013} # claude-sonnet-5
client = anthropic.Anthropic(base_url="https://api.zukko.pro", api_key="fetch_your_key")
long_instructions = open("instructions.md", encoding="utf-8").read()
resp = client.messages.create(
model="claude-sonnet-5",
max_tokens=1024,
system=[{
"type": "text",
"text": long_instructions,In the Anthropic format, input_tokens is only the fresh input after the last cache marker; total input = input_tokens + cache_read_input_tokens + cache_creation_input_tokens. Note that the base URL here has no /v1 — the SDK adds the path itself.
How to check it in practice
- Send the same long request twice, less than five minutes apart. The first response should show a cache write, the second a cache read.
- A regular (non-streaming) Zukko response carries the
X-Zukko-Cost-Microsheader — the request cost in micro-dollars (1,000,000 = $1). Compare it with your formula. - See totals by day and model in the dashboard, under Usage.
Do not confuse prompt caching with the identical-response cache controlled by the X-Zukko-Cache header: that is a separate Zukko mechanism that returns a repeat of an exactly identical request for free. How it works — in the article about X-Zukko-Cache.
To check the numbers on your own requests, create a key on the API keys page and run a couple of tests from the example above.
FAQ
Do I need to enable caching in Claude Code?
No. Claude Code marks the stable part of the context itself. It only needs to be connected in the Anthropic format: ANTHROPIC_BASE_URL=https://api.zukko.pro and the key in ANTHROPIC_AUTH_TOKEN.
Why is there no cache discount for Claude in Cursor?
Cursor connects to Zukko through the OpenAI format, and in /v1/chat/completions all Claude input is billed at the input price. If caching matters, use Claude models through tools that speak the Anthropic format.
Does caching affect the price of DeepSeek V4.1 Flash?
No. In Zukko this model's input and cache read cost the same — $0.013 per million tokens, and a write is not charged separately.
Can I know in advance how many tokens will be cached?
Not exactly — the provider decides. You can count the prefix length with POST /v1/messages/count_tokens and make sure it is above the model's minimum.
zukko
Pay 25×
less
for Claude Code & ChatGPT
One fetch_* key and base URL api.zukko.pro — for Cursor, Claude Code, Codex, and any SDK.
Related articles
- Chatbot memory: how to store conversation history without paying twiceThe model does not remember earlier messages: you send the history with every request. We look at how dialogue cost grows and what keeps it in check.
- LangChain text splitters: how to cut text into chunks correctlyHow to choose chunk size and overlap in RecursiveCharacterTextSplitter, why you should count in tokens and how to check the count against an exact token number.
- LangChain RAG: a working example with a model via a gatewayWe build a simple RAG with LangChain: documents, chunks, vector search and a model answer via a gateway. We count what a question costs and trim wasted tokens.
- opencode agents: setting up roles, models and toolsA custom agent in opencode is a role, a model and a set of permissions. A working config where a cheap model handles routine work and a stronger one edits code.