fix(ccusage): add flat pricing for Opus 4.6 / Sonnet 4.6 to fix inflated costs#898
fix(ccusage): add flat pricing for Opus 4.6 / Sonnet 4.6 to fix inflated costs#898MumuTW wants to merge 1 commit intoryoppippi:mainfrom
Conversation
…ted costs Claude Opus 4.6 and Sonnet 4.6 use flat pricing across the full 1M context window — there is no premium for requests exceeding 200k input tokens. However, LiteLLM's dataset only contains Bedrock entries (e.g. `anthropic.claude-opus-4-6-v1`) which include `*_above_200k_tokens` fields for Bedrock-specific tiered pricing. When ccusage looks up pricing for `claude-opus-4-6`, the direct lookup finds no match and the substring fallback picks up the Bedrock entry, incorrectly applying tiered pricing and inflating costs. Fix by injecting entries keyed by the exact Anthropic API model names (`claude-opus-4-6`, `claude-sonnet-4-6`) with correct flat pricing. Direct lookup now succeeds before the substring fallback fires. Fixes ryoppippi#891
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughIntroduces flat pricing mappings for direct Anthropic API models (claude-opus-4-6 and claude-sonnet-4-6) and updates the prefetch logic to prioritize these direct API pricing lookups before falling back to Bedrock substring-based pricing resolution. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip Migrating from UI to YAML configuration.Use the |
Summary
anthropic.claude-opus-4-6-v1) which include*_above_200k_tokenstiered pricing fields; when ccusage falls back to substring matching it picks up the Bedrock entry and incorrectly applies tiered pricingclaude-opus-4-6,claude-sonnet-4-6) with correct flat pricing so direct lookup succeeds before the substring fallback firesTest plan
Fixes #891
Summary by CodeRabbit