Prompt caching costs: choosing the cache lifetime — a Grodmir guide

Prompt caching lowers the price of a repeated prompt start, but writing to the cache costs extra and a longer lifetime costs more. The right lifetime depends on how soon your requests return to the same prefix.

Grodmir Optimize measures and cuts LLM API costs in the customer's infrastructure, from request metadata and token usage only.

What is prompt caching?

Providers store the start of a request that repeats across calls, the prefix: a system prompt, tool definitions or documents. Later requests that begin with the same prefix pay a reduced price for the cached part instead of the full input price.

Link to this answer

Why does the cache lifetime matter?

Writing to the cache costs more than normal input, and a longer lifetime costs more to write. If requests return after the cache has expired, you pay the write again. If they return quickly, a long lifetime only adds the higher write price.

Link to this answer

What lifetimes do Anthropic and OpenAI offer?

Anthropic: 5 minutes, with cache writes at 1.25× the input price, or 1 hour at 2×. OpenAI Responses API: 30 minutes by default, with writes at 1.25×, or 12 hours at 2.5×. Ratios from the provider price lists read in November 2026.

Link to this answer

What about Google Gemini?

Gemini 4 models use implicit caching: cached input is billed at the lower read price, with no write charge and no lifetime setting. There is no lifetime to choose there.

Link to this answer

How does Grodmir Optimize choose the lifetime?

It measures, per route and prefix hash, how long requests take to return to the same prefix and proposes the lifetime with the lower total cost. After your approval the proxy sets it on each request; the request content stays the same. On OpenAI this needs the Responses API; Chat Completions routes get an instruction instead.

Link to this answer

What must stay stable for caching to work?

The prefix must be identical byte for byte. A timestamp, a request id or reordered tools at the start of a prompt break the cache. Grodmir Optimize never changes the prefix; it reports the likely cause and you fix it in code.

Link to this answer

Content updated:

Amounts before a change goes live are estimates; only savings measured in the Savings Ledger are billed. How to start with Grodmir Optimize · Grodmir Optimize Terms

Categories: AI gateway · Prompt DLP · MCP proxy · AI usage governance

Organisation portal