-
Notifications
You must be signed in to change notification settings - Fork 132
feat: bill anthropic cache write #2171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
steebchen
merged 13 commits into
theopenco:main
from
RATCHAW:feat/anthropic-cache-write-costs
May 7, 2026
Merged
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
2838ac1
feat: track cache write costs
RATCHAW 96fb83b
feat: add cacheWriteInputPrice1h for improved pricing accuracy
RATCHAW 535c3a7
test: enhance pricing tests for Anthropic models
RATCHAW 141bc76
fix(gateway): extract cache-write tokens from cached streaming replays
RATCHAW d27744a
fix(gateway): preserve cache_control ttl on inbound requests
RATCHAW 9fc65d4
feat(gateway): surface 5m/1h cache_creation breakdown
RATCHAW 9b940b3
fix(admin): expose cache-write tokens and cost in metrics
RATCHAW c3e7654
fix(gateway): emit cache_write_tokens in streaming chunks
RATCHAW b6e7722
chore: regenerate api types for cache-write fields
RATCHAW 5b0b2a4
fix(gateway): forward 1h cache-write tokens on cached replay
RATCHAW 7c81bfa
chore(db): consolidate cache-write migrations into one
RATCHAW 44da5ea
Merge branch 'main' into feat/anthropic-cache-write-costs
smakosh ba9fe24
Merge branch 'main' of https://github.com/theopenco/llmgateway into f…
RATCHAW File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preserve zero cache-write tokens in log responses.
This truthy check turns
0intonull, so clients cannot distinguish “no cache writes” from “field missing”. Check fornull/undefinedexplicitly instead.🩹 Suggested fix
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cacheWriteTokensis a Drizzledecimal()columndecimal()defaults tomode: "string"The string "0" is truthy in javascript
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RATCHAW, you're absolutely right — thank you for the correction. Sincedecimal()in Drizzle defaults tomode: "string", the value arrives as"0"(a string) rather than the number0, and"0"is truthy in JavaScript. The existing truthy check is therefore safe and consistent with all the other token columns (cachedTokens,reasoningTokens, etc.) in this same response builder. My concern was invalid.🧠 Learnings used