Support for cache write tokens in returned response usage
Open
Nobody has claimed this yet.
ai/provider
provider/anthropic
provider/gateway
support
task-identify-issue-type-done
- Dominant language
- TypeScript
- Stars
- 26.9k
- Forks
- 5.2k
- Avg merge
- 17h 48m
- Merged PRs (30d)
- 516
Description
Description
Some providers like anthropic also charge for cache writes
https://www.anthropic.com/pricing#api
It would be great for generateText, streamText ( LanguageModelV2Usage) to include cache write tokens as well so we can accurately compute cost correctly for all models
AI SDK Version
v5
Code of Conduct
- I agree to follow this project's Code of Conduct
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the generateText and streamText entry points and the LanguageModelV2Usage type to see how returned usage is assembled. Check the provider usage mapping, especially for cache writes, and add coverage showing that cache write tokens are returned so callers can calculate costs accurately.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 56/100