Summary
internal/usage/pricing.go has a single opus-4 rate entry at pre-4.5 prices and matches model IDs by case-insensitive substring. So claude-opus-4-5 / 4-6 / 4-7 / 4-8 all match opus-4 and get billed at the old rate — but Anthropic cut Opus prices sharply starting with Opus 4.5 (Nov 2025).
Evidence
- aflock table:
opus-4 = $15 in / $75 out / $1.50 cache-read / $18.75 cache-write per Mtok; matched by substring (~pricing.go:84).
- Actual Opus 4.5+ rates: $5 / $25 / $0.50 / $6.25 per Mtok (Opus 4 / 4.1 / 3 stay at $15 / $75 / $1.50 / $18.75).
- Cross-checked against Datadog lapdog's table (
DataDog/dd-apm-test-agent → ddapm_test_agent/claude_cost_tracker.py), which sources from pi-ai models.generated.js — the same data Claude Code's own /usage uses.
Impact (real Opus 4.8 session)
tokens: 3.9k in · 3.5k out · 214.3k cache-read · 12.3k cache-write
- aflock (old rates): ≈ $0.87
- correct (4.5+ rates): ≈ $0.29 ← matches Claude Code
/usage ($0.2908)
→ ~3× overcount. Under API key this feeds maxSpendUSD enforcement, so a session can be falsely aborted/denied well under its real budget.
Fix
- Split the Opus family: legacy keys (
opus-4, opus-4-1, opus-3) keep old rates; add opus-4-5 / 4-6 / 4-7 / 4-8 at $5 / $25 / $0.50 / $6.25.
- Make matching prefer the longest/most-specific prefix, not the first substring hit, so
opus-4-8 doesn't fall into opus-4.
- (Optional) add Anthropic's >200K-token long-context premium tier — lapdog models this via volume-tiered
_PriceTier bounds.
Independent of the broader accounting redesign — shippable on its own.
Summary
internal/usage/pricing.gohas a singleopus-4rate entry at pre-4.5 prices and matches model IDs by case-insensitive substring. Soclaude-opus-4-5 / 4-6 / 4-7 / 4-8all matchopus-4and get billed at the old rate — but Anthropic cut Opus prices sharply starting with Opus 4.5 (Nov 2025).Evidence
opus-4= $15 in / $75 out / $1.50 cache-read / $18.75 cache-write per Mtok; matched by substring (~pricing.go:84).DataDog/dd-apm-test-agent→ddapm_test_agent/claude_cost_tracker.py), which sources frompi-ai models.generated.js— the same data Claude Code's own/usageuses.Impact (real Opus 4.8 session)
tokens: 3.9k in · 3.5k out · 214.3k cache-read · 12.3k cache-write
/usage($0.2908)→ ~3× overcount. Under API key this feeds
maxSpendUSDenforcement, so a session can be falsely aborted/denied well under its real budget.Fix
opus-4,opus-4-1,opus-3) keep old rates; addopus-4-5 / 4-6 / 4-7 / 4-8at $5 / $25 / $0.50 / $6.25.opus-4-8doesn't fall intoopus-4._PriceTierbounds.Independent of the broader accounting redesign — shippable on its own.