[BUG] claude-sonnet-5 cost billed incorrectly via Vertex AI — /cost and "Usage by model" don't match published Sonnet 5 pricing

Open 💬 0 comments Opened Jul 13, 2026 by sameemqureshi

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?

claude-sonnet-5 sessions are being billed using rates that don't match published Sonnet 5 pricing ($2/$10 per MTok intro, stepping to $3/$15 after Aug 31, 2026). Instead, the reported cost lines up almost exactly with Opus-tier rates ($5/$25 per MTok, with matching 10%/1.25x cache multipliers).

I have two examples, and they're inconsistent with each other too — suggesting the bug isn't just "wrong rate everywhere," but that different views (/cost per-session vs. the "Usage by model" summary) may be pulling from different rate tables.

What Should Happen?

The cost reported by Claude Code (both the per-session /cost line and the aggregate "Usage by model" summary) must match the published per-token rate for the model actually being used, applied to the token counts Claude Code itself reports in that same line.

Concretely: cost = (input_tokens × input_rate) + (output_tokens × output_rate) + (cache_read_tokens × cache_read_rate) + (cache_write_tokens × cache_write_rate), using the correct rate card for claude-sonnet-5 on the access path being billed (Vertex AI in this case). Right now the displayed token counts and the displayed cost don't reconcile under any published Sonnet 5 rate — the cost only matches if a different model's (Opus-tier) rate is silently substituted in. The two views (/cost vs. "Usage by model") should also agree with each other on which rate they're using, since they're describing the same underlying usage.

Suggested fix

Verify the local rate table used by /cost and the "Usage by model" summary both correctly map claude-sonnet-5 to its actual published rate ($2/$10 input/output through Aug 31, 2026; $3/$15 standard thereafter; 10% cache-read / 1.25x 5-min cache-write multipliers), and confirm both code paths read from the same source of truth.

Error Messages/Logs

Steps to Reproduce

Task performed: a simple codebase lookup + code suggestion. No web search, no server-side tools, no Managed Agents, well under any long-context threshold.

Example 1 — single session line

model=claude-sonnet-5 in=4295 out=3397 cache_read=541576 cache_write=123452 cost=$1.1488

Expected cost at Sonnet 5 intro pricing ($2/$10, cache read $0.20/M, cache write 5m $2.50/M):

input: 4,295 × $2/M = $0.00859
output: 3,397 × $10/M = $0.03397
cache_read: 541,576 × $0.20/M= $0.10832
cache_write:123,452 × $2.50/M= $0.30863
--------------------------------------
total = $0.4595

Expected cost at Sonnet 5 standard pricing ($3/$15, cache read $0.30/M, cache write $3.75/M):

total = $0.6893

Actual reported cost: $1.1488

This matches Opus-tier pricing ($5/$25/M, cache read $0.50/M, cache write $6.25/M) almost exactly:

input: 4,295 × $5/M = $0.021475
output: 3,397 × $25/M = $0.084925
cache_read: 541,576 × $0.50/M = $0.270788
cache_write:123,452 × $6.25/M = $0.771575
--------------------------------------------
total = $1.148763

Example 2 — aggregate "Usage by model" line (same session series)

claude-sonnet-5: 5.6k input, 8.2k output, 1.2m cache read, 105.6k cache write ($0.91)

This one lands closest to standard Sonnet pricing ($3/$15) → ≈$0.896, a ~1.6% gap consistent with display rounding of the "5.6k / 1.2m" figures. It does not match Opus-tier rates (~$1.49) or intro Sonnet pricing (~$0.60).

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.207 (Claude Code)

Platform

Google Vertex AI

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

<img width="1453" height="442" alt="Image" src="https://github.com/user-attachments/assets/2e7d9a83-6d49-4606-80a4-b4276800abe3" />
Am I missing any other type of cost in this calculation — For context, this specific task was a plain codebase lookup + code suggestion with no web search or other tool use involved, so I wouldn't expect any of those to apply — but wanted to confirm there isn't some other billed component I'm not accounting for before concluding this is purely a rate-table bug.

View original on GitHub ↗