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.
Open source (MIT) · never stores prompts · Claude, OpenAI, Gemini, vLLM, SGLangprefixwise demo: a scripted agent breaks its cache three ways, then runs again with the fixes on.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.
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
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.
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.
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.
| See | Every call paid twice, its one named cause and its cost, in plain words. |
| Fix | Tool order and cache markers corrected before a request is sent, stepping aside if anything goes wrong. Each fix predicts its saving, then measures it. |
| Protect | A check in CI that fails the build when a change would break reuse. |
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%.
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
report --session latestone conversation, turn by turnreport --compare A Btwo tasks or prompt versions side by sideexport --format csvevery row, for your own spreadsheetOn 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.
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.