PREFIXWISE
Try it free
OPEN SOURCE · MIT

The AI spend your gateway doesn't see.

Coding agents, direct API calls and your own GPUs. Prefixwise shows what every AI call cost, why part of it was paid twice, and fixes what it can, with the savings measured.

See what you paid twice Request a free audit
Open source (MIT) · never stores prompts · Claude, OpenAI, Gemini, vLLM, SGLang
~/agentprefixwise demo
$ prefixwise demo
  turn  3   2,000 of 2,000 from cache  100.0%  none
  turn  4       0 of 2,000 from cache    0.0%  tool_reserialize
  turn  7       0 of 2,000 from cache    0.0%  volatile_system
  turn  9       0 of 2,000 from cache    0.0%  history_edit

before and after          before     after
  served from cache        33.3%     88.9%
  avoidable tokens        10,000         0
Real output from prefixwise demo: a scripted agent breaks its cache three ways, then runs again with the fixes on.
THE PROBLEM

The same text, paid for twice.

Agents resend their instructions and history on every step. When that text is unchanged, the provider or GPU reuses the work it already did, at about a tenth of the price.

A break longer than the cache lasts, a timestamp in the instructions, tools in a new order, a busy GPU or a model swapped behind the scenes breaks that reuse. The step pays full price again, and no bill says why.

step 1
instructions · 9:00
tools
conversation so far
new
step 2
instructions · 9:01
tools
conversation so far
new
One minute changes at the top, so everything after it is paid in full again. reused, about 1/10 the pricepaid in full again
TRY IT ON YOUR OWN LOGS

Your own number, from logs you already have.

Claude Code and Codex keep their logs on your machine. One command reads them and prices every call. Nothing is sent anywhere, and no gateway is needed.

$ pip install prefixwise
$ prefixwise import claude-code
$ prefixwise report
OUR OWN 20 DAYS OF CLAUDE CODE

10,517 calls. 98.2% of the prompt read from cache, and still about a quarter of the bill paid again, mostly after breaks of more than an hour.

WHAT IT SEES

Where your gateway can't look.

A gateway sees the calls routed through it. Much of the spend never is: coding agents call providers directly, services call SDKs, cloud accounts bill on their own, and a GPU's cache is invisible from outside. Prefixwise reads all of it and works alongside the gateway you already use.

Coding agentsClaude Code and Codex, read from their own logs.prefixwise import claude-code
Direct API callsAnthropic, OpenAI, Gemini, Bedrock, Vertex and Azure, through one line of code or a local proxy.prefixwise.wrap(client) · prefixwise serve
Your gatewayLiteLLM, Portkey, Bifrost, Envoy or Plano. We add to it, never replace it.gateway → prefixwise serve
Your GPUsvLLM and SGLang, confirmed from the engine's own cache events.prefixwise serve --upstream <engine>
All integrations, with setup →
EVERY CAUSE IT NAMES

19 causes. One per miss.

Each miss gets the first thing, in prompt order, that broke reuse. Waste is yours to fix; legitimate misses cost money but aren't mistakes. When the evidence isn't there, the answer is unknown, never a guess.

Waste6
A mistake in how the call was built. Fixable, and priced as avoidable.
A date, time or id changed in the instructionsvolatile_system
The same tools, sent in a different ordertool_reserialize
Earlier messages were rewrittenhistory_edit
An earlier tool result was re-renderedtool_result_mutation
The same request retried within a minuteretry_replay
Cache markers missing or in the wrong placebreakpoint_misplaced
Depends4
Sometimes deliberate, sometimes a sign to change settings or add memory.
The instructions were rewordedsystem_edit
Tool choice, reasoning or format settings changedparam_rendered
The prompt was too short to cachebelow_min_prefix
The GPU dropped the cache to make roomevicted
Not waste8
Costs money, but nothing was done wrong. Shown so the bill makes sense.
The cache expired during a breakttl_expired
A different model, with its own cachemodel_switch
The history was compactedcompaction_rewrite
A tool was added or removedtool_catalog_change
Sent to a server that never saw the conversationrouting_miss
First call: nothing to reuse yetfirst_write
First turn of a forked conversationfork_boundary
Reused as expectednone
Full table with fixes →
WHAT IT DOES

Find it, fix it, keep it fixed.

SeeEvery call paid twice, its one named cause and its cost, in plain words.
FixTool order and cache markers corrected before a request is sent, stepping aside if anything goes wrong. Each fix predicts its saving, then measures it.
ProtectA check in CI that fails the build when a change would break reuse.
THE REPORT

One you can act on. One you can paste.

Where the bill went, what was avoidable, and the fixes ranked by what they'd save. A short version fits in a pull request, a Slack thread or an email to finance.

$ prefixwise report
9 requests, 18,000 prompt tokens, 33% served from cache.
Where the bill went: cache re-reads 4%, cache writes 96%.
Avoidable: 10,000 tokens, 55.6% of prompt tokens.
Fix these, biggest first:
  1. The same tools were sent in a different order
     (2 requests, 4,000 tokens)
     prefixwise serve --fix canonical_tools (proven)
  2. The system prompt changed only in a date or time
     (2 requests, 4,000 tokens)
  3. Earlier messages were rewritten (1 request)
Fixing these would take the share served from cache
from 33.3% to 88.8%.
From prefixwise demo on the built-in stand-in, shortened.
$ prefixwise report --share
prefixwise
13 requests, 836,551 prompt tokens, 96% from cache, $0.0179
bill: 45% cache re-reads, <1% new input, 21% cache writes, 34% output
no avoidable waste: every miss had a legitimate cause
Real: Claude Code fixing a pytest bug from SWE-bench Verified, run on Jetty.
report --session latestone conversation, turn by turn
report --compare A Btwo tasks or prompt versions side by side
export --format csvevery row, for your own spreadsheet
YOUR OWN GPUS

Confirmed by the engine, not guessed.

On your own servers, Prefixwise listens to the engine itself. When a conversation loses its cache, you learn whether the GPU ran out of room, a router sent it to the wrong server, or the cache came back from CPU memory.

vLLMEvictions and wrong-server routes, confirmed.5/5 evictions · 5/5 routing misses, live
SGLangEvictions confirmed; HiCache restores counted as hits.run live, HiCache included
LMCacheA prefix restored from CPU memory counts as a hit, and says so.5/5 restores named, live
Setup for each engine →
PROOF

Measured, published, checkable.

The open-source engine and its test records →
0false alarms across 71,346 calls from real agent conversations, on hosted APIs and open datasets
1,772changes injected into real traces on vLLM and SGLang: every one seen, none misnamed
252,549appends read correctly on a public two-week trace of real provider traffic, without one miss
97.5–99.9%of the predicted saving delivered when a fix was turned on, on a hosted API and on vLLM
~1/4of a real 20-day coding-agent bill paid again, every call checked by an independent audit
THE PAPERWhy Did the Prompt Cache Miss? Per-Request Cause Attribution for Agent WorkloadsTejaswi Chavali · Zenodo, 2026 · the method, the evidence behind each cause, and the evaluation
Read the paperdoi:10.5281/zenodo.24331594
WHO IT'S FOR
Engineers on coding agentsClaude Code and Codex usually skip the company gateway. See what your team's agents paid twice, and why.
Teams shipping agentsKnow what every task costs, through any gateway or none, and stop paying for work your AI already did.
Teams running their own GPUsFewer recomputed prompts means more requests per GPU, and a clear answer on when to buy more.
HOW WE WORK
NeutralWe sell no models, GPUs or gateway, so we measure them all the same way.
PrivateRuns on your machines and keeps only counts and fingerprints.
OpenThe engine is open source under MIT, and every number here links back to a published test record.

Start with your own number.

Run it yourself on your coding agents' logs today, or ask for a free audit: one day of your traffic, one number for what was paid twice, and the three fixes worth doing first. No code changes, no prompts shared.

Request a free audit Read the setup guide