Price 1-hour cache writes at their 2× rate in savings estimates#118
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #117.
The dashboard priced every cache write at the 5-minute rate, 1.25× base input.
Anthropic charges 2× for 1-hour writes, on Fable that's $20/M, not $12.50/M, and the tracker already records the split from
usage.cache_creation.The savings math just never used it.
Example: a turn writing 100k tokens to a 1-hour cache on Fable really costs $2.00, but was priced at $1.25.
Same error on both the actual side and the text-counterfactual baseline, so the savings figure was off too.
Both sides now price each tier at its real rate.
Responses that don't report the split fall back to 1.25×, same as before, conservative rather than wrong.
1-hour writes are not rare: Claude Code asks for 1-hour caching, and in my logs ~88% of tier-reported cache-write tokens are 1-hour.
So expect the savings number to go up.
Savings is a difference: what the text version would have cost minus what pxpipe actually cost.
Both sides rise, but the text version writes more cache tokens, so it rises more, and the gap widens.
The 1-hour write part of the gap scales by 2/1.25 = 1.6×; 5-minute writes, plain input, and cache reads don't move.
Old events recorded before the split was captured keep the 1.25× fallback, so history moves less than new sessions will.
The dollar figure is still a best-effort estimate, not a bill.
And the proxy isn't free: it adds some latency, and a slow turn can fall out of the 5-minute cache window and pay a write where a direct call would have paid a read.
The estimate doesn't try to price that in.