[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=1
and the EU Opus 4.7 inference profile
ANTHROPIC_DEFAULT_OPUS_MODEL=eu.anthropic.claude-opus-4-7`

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

  1. Configure Claude Code for Bedrock via the env vars above (EU regional inference profile).
  2. Run a session that exercises prompt caching heavily (any long-running agent turn does).
  3. Sum the message.usage values from the session transcript, deduping by message.id (the same logical API call appears 2–3 times as the

conversation linearizes through tool turns).

  1. Multiply by published Opus 4.7 rates.
  2. Compare to /cost output and cost.total_cost_usd from 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)

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗