claude-code - 💡(How to fix) Fix [BUG] AWS Cloudwatch Output token count is too high for Claude 4.5 Sonnet [2 comments, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#52857Fetched 2026-04-25 06:19:02
View on GitHub
Comments
2
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
commented ×2labeled ×2

Error Message

Error Messages/Logs

Root Cause

Can you please refer this case to a human subject matter expert. Hi Siamack, Thanks for the detailed write-up, Siamack. What you're seeing can happen because token counts are not a 1:1 reflection of the visible text or file size you measure. [1] A few key reasons output token counts can look much higher than expected: • The API transforms requests into an internal format, and the model output goes through a parsing stage before becoming the API response, so output_tokens will not match the exact visible content. • Token counts are estimates and can differ by a small amount; they may also include tokens added automatically for system optimizations (you are not billed for system-added tokens). [2] • If you are using tools, tool use adds system prompt overhead and additional token consumption (for example, computer use adds 466 to 499 tokens to the system prompt, plus additional costs for tool definitions and returned results). [3] [4] • In some server-side tool scenarios, token usage can be miscalculated because cache_read_input_tokens can accumulate across multiple internal calls, making totals look inflated. [5] Please let me know if this helps or if you have any further questions.

Code Example

NA
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

I have opened a case with AWS with regards to Claude 4.5 Sonnet output token counts reported in CloudWatch are much higher (factor of x5) than expected and measured output files sizes. CASE 177695638006582] Bedrock Claude 4.5 Sonnet output token count is greater than what it should be by factor of 5.

I was referred to support which asked me to report this as a bug.

Regards, Siamack

Hi AI

The output token count reported in AWS CloudWatch is five times what it should be. I have no problem with the input token count. So, your references [1], [2], [5] are not relevant.

The 4 reasons you give below do not explain why the output token count is five times higher than it should be. I address them one at a time:

  1. Output tokens may not match the exact visible content, but the difference cannot be five times. A factor of five can not be explained by this.
  2. As you say, “differ by small amount”, not five times. What is added is also to do with input tokens.
  3. I am not using tools, so your references [3] [4] are not relevant.
  4. Again, you are talking about input token count. I am talking about output token count which is five times more expensive and dominates the cost.

Can you please refer this case to a human subject matter expert. Hi Siamack, Thanks for the detailed write-up, Siamack. What you're seeing can happen because token counts are not a 1:1 reflection of the visible text or file size you measure. [1] A few key reasons output token counts can look much higher than expected: • The API transforms requests into an internal format, and the model output goes through a parsing stage before becoming the API response, so output_tokens will not match the exact visible content. • Token counts are estimates and can differ by a small amount; they may also include tokens added automatically for system optimizations (you are not billed for system-added tokens). [2] • If you are using tools, tool use adds system prompt overhead and additional token consumption (for example, computer use adds 466 to 499 tokens to the system prompt, plus additional costs for tool definitions and returned results). [3] [4] • In some server-side tool scenarios, token usage can be miscalculated because cache_read_input_tokens can accumulate across multiple internal calls, making totals look inflated. [5] Please let me know if this helps or if you have any further questions.

What Should Happen?

The AWS CloudWatch Output Token count should be lower by a factor of 5 and is likely being multiplied by a factor of 5 in anticipation of charging 5 times more for an output token vs. an input token.

Error Messages/Logs

NA

Steps to Reproduce

I have screenshots of the AWS CloudWatch which I can share. Don't know if it was uploaded.

AWS-Billing-Ticket-20260423.docx

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

4.5

Platform

AWS Bedrock

Operating System

Windows

Terminal/Shell

Other

Additional Information

I am using AWS Bedrock API model invoke in Gov cloud region.

extent analysis

TL;DR

The issue can be resolved by investigating the token counting mechanism in the Claude Code version 4.5 and verifying if the output token count is being multiplied by a factor of 5 due to a billing discrepancy.

Guidance

  • Investigate the Claude Code documentation on token counting to understand how output tokens are calculated and billed.
  • Verify if the issue is specific to the Sonnet model or if it occurs with other models as well.
  • Check the AWS CloudWatch logs and metrics to see if there are any discrepancies in the output token count.
  • Review the billing documentation to understand how output tokens are charged and if there are any multipliers applied.

Example

No code snippet is provided as the issue seems to be related to the billing and token counting mechanism rather than a code-specific problem.

Notes

The issue seems to be specific to the Claude Code version 4.5 and the Sonnet model, but more investigation is needed to determine the root cause. The user has already opened a case with AWS and has been referred to report this as a bug.

Recommendation

Apply a workaround by manually verifying the output token count and adjusting the billing accordingly, until the root cause of the issue is determined and a fix is applied. This is because the issue seems to be related to a billing discrepancy rather than a code-specific problem.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] AWS Cloudwatch Output token count is too high for Claude 4.5 Sonnet [2 comments, 1 participants]