Open source, MIT Zero dependencies Your own SDK client

Stop paying full price for the same tokens.

Anthropic, OpenAI and Gemini bill a repeated prompt prefix at a fraction of the input price, but only when the bytes really repeat. cachemaxxing measures your hit rate, finds the byte where your prompts stop repeating, and lays them out so they do.

Get started
$pip install cachemaxxing
76–88%

lower input cost than an app with common prompt bugs, for chat and RAG on every model we benchmarked

98–99%

of the input read from cache from the second turn of a chat, on OpenAI and Anthropic

0

runtime dependencies. You keep your own Anthropic, OpenAI, Azure, Gemini or LiteLLM client

// measure → diagnose → fix

A cache miss never raises an error. The bill is just higher.

The only ground truth is the usage the provider sends back. cachemaxxing starts there.

Measure

usage() turns any provider's response into the same numbers: input, cache read and write, output, hit rate, $ spent and $ saved.

$ cachemaxxing report calls.jsonl --min-hit-rate 0.6
call site     calls  hit rate  est $   saved $
rag.answer    5      71.7%     0.0034  0.0024
support.chat  6      82.8%     0.0017  0.0028

Diagnose

Pass each request to Stats and it tells you as soon as the cache breaks: the first byte that changed, the likely cause (a timestamp, an id, tool order or JSON key order) and the fix.

stats.add("support.answer", usage(resp), request=kw)
WARNING cachemaxxing: support.answer: the cached prefix broke:
diverges at messages[0].content[0].text char 31 (timestamp)
  a: 'Current time: 2026-10-31T21:57:27.105469+00:00'
  b: 'Current time: 2026-10-31T21:57:32.635435+00:00'
  fix: A time changes on every call. Move it into .retrieved().

Fix

Prompt puts the stable parts first and places each provider's cache markers: on the system prompt, and on the conversation so far.

p = Prompt("rag.answer")
p.system(SYSTEM).history(chat)
p.retrieved(chunks).user(question)
kw = p.anthropic("claude-haiku-5-5")
// cachemaxxing report --html

Every call site at a glance

One self-contained page from your call log: hit rate per call, spend and savings per call site, and the exact byte that changed, with the fix. It makes no network requests, so your prompts stay on your machine.

cachemaxxing report calls.jsonl --html report.html Open the demo full screen Langfuse, LangSmith and OpenTelemetry
// benchmarks, real API calls

Measured, including where it matters less

Same content in three layouts: an app with common prompt bugs, a clean prompt with the provider's own automatic caching, and cachemaxxing.

Cached input tokens per conversation for naive, clean with provider auto-caching, and cachemaxxing, on Anthropic, OpenAI and Gemini, for chat and RAG
  • Against an app with those bugs: 76–88% cheaper

    Input cost for chat and RAG, on every model. The usual culprits are a timestamp in the system prompt, shuffled tools and re-rendered history.

  • Anthropic: 82–89% cheaper than automatic caching

    Automatic caching puts its one cache entry after the per-turn context, so every call pays the write premium and reads nothing back.

  • Gemini: 62–67% cheaper

    Implicit caching is best-effort. An explicit cache, created only when it pays, read 88–97% of the input.

  • OpenAI: 6–19% cheaper

    OpenAI's implicit caching already finds a stable prefix. The win there is fixing the habits, plus the measurements.

Find out what your prompts really cost.

Log a day of calls, run the report, and fix the call site at the top of the list.

$pip install cachemaxxing
Read the quickstart