[BUG] cost.total_cost_usd underreports ~66% on Bedrock — cache tokens seems to be not counted for Opus 4.7 via eu.anthropic.* inference profile
Resolved 💬 3 comments Opened May 4, 2026 by can-isik-elgato Closed May 8, 2026
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When routed through AWS Bedrock with CLAUDE_CODE_USE_BEDROCK=1ANTHROPIC_DEFAULT_OPUS_MODEL=eu.anthropic.claude-opus-4-7`
and the EU Opus 4.7 inference profile
cost.total_cost_usd underreports by ~3× because cache_read and cache_creation tokens appear to not be included in the cost calculation.
What Should Happen?
The output of cost._total_cost_usd accumulation should roughly match the AWS Bedrock bill
Error Messages/Logs
Steps to Reproduce
- Configure Claude Code for Bedrock via the env vars above (EU regional inference profile).
- Run a session that exercises prompt caching heavily (any long-running agent turn does).
- Sum the
message.usagevalues from the session transcript, deduping bymessage.id(the same logical API call appears 2–3 times as the
conversation linearizes through tool turns).
- Multiply by published Opus 4.7 rates.
- Compare to
/costoutput andcost.total_cost_usdfrom the statusline stdin payload.
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.126
Platform
AWS Bedrock
Operating System
Windows
Terminal/Shell
PowerShell
Additional Information
Related
- #28168 — similar root cause: hardcoded pricing map misses model IDs (closed, fixed for Sonnet 4.6)
- #51198 — inverse symptom: admin API reports 100× too high (open)
- #53371 — similar underreport on direct Anthropic Haiku (closed as dup of #51198)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗