Repository navigation
pricing: price Claude's 1-hour cache writes at 2x input, not 1.25x - #192
Merged
Aaron Li (aaron-jx-li) merged 2 commits intoNov 10, 2026
Merged
Aaron Li (aaron-jx-li) merged 2 commits into
Aaron Li (aaron-jx-li) merged 2 commits into
Conversation
Anthropic bills a cache write by its lifetime: 1.25x input for the 5-minute cache and 2x for the 1-hour one. Every Claude cache-write token was priced at 1.25x, so a session whose writes go to the 1-hour cache (Claude Code on a subscription) was understated. A message's usage splits its cache writes in cache_creation.ephemeral_1h_input_tokens. The Claude session reader now sums that share as cache_creation_1h_input_tokens, and effective_tokens prices it at the table's cache_write_1h (2.0 on the Claude curve). A row without the field, or a weight table without the entry, is priced exactly as before.
Contributor
Author
|
@microsoft-github-policy-service agree |
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 #191.
Anthropic bills 5-minute cache writes at 1.25x input and 1-hour cache writes at 2x. Every Claude cache-write token was priced at 1.25x, which understates sessions whose writes go to the 1-hour cache.
trace/claude.py:claude_session_usagealso returnscache_creation_1h_input_tokens, the sum of each message'scache_creation.ephemeral_1h_input_tokens, capped per message at itscache_creation_input_tokens.pricing.py:effective_tokensprices that share at the table'scache_write_1h(2.0 for Claude). New helpercache_write_1h_tokensreads the flat field or an Anthropicusageobject.plugin/accounting.py,plugin/fold.py: carry the share into the priced record and the session ledger, so Claude side calls are priced the same way.Unchanged: rows without the field, non-Claude models, and the fallback curve.
Tests:
tests/test_cache_write_1h.py(12 cases). I ran it withtests/test_ledger.py,tests/test_live_core.pyandtests/test_trace.py; all pass. I have not run the full suite orexperiments/tests.Note for the experiments: Claude rows produced after this change that go through
claude_session_usagewill price 1-hour writes at 2x, so they are not directly comparable to rows recorded before it.