Skip to content

feat(models): add Claude Opus 5 pricing - #223

Merged
mike1858 merged 1 commit into
Piebald-AI:mainfrom
NickAme03:add-opus-5-pricing
Jul 31, 2026
Merged

feat(models): add Claude Opus 5 pricing#223
mike1858 merged 1 commit into
Piebald-AI:mainfrom
NickAme03:add-opus-5-pricing

Conversation

@NickAme03

@NickAme03 NickAme03 commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Closes #221.

claude-opus-5 had no entry, so get_model_info returned None and every Opus 5 message priced to $0 after a warn_once. On the corpus in #221 that was $108.60 of usage reported as free.

Rates are $5 per million input and $25 per million output, the same as Claude Opus 4.8, which puts cache write at 6.25 and cache read at 0.5 under the multipliers this file uses throughout. The entry sits between claude-sonnet-5 and claude-opus-4-8, matching the existing ordering.

Aliases follow the shape already used for the other 5-generation models. One line is a judgement rather than a deduction: global.anthropic.claude-opus-5 matches what claude-sonnet-5 carries, while claude-fable-5 has no such alias, so the file is not consistent on that point today. Easy to drop if you would rather it were not there.

The test mirrors claude_opus_4_8_alias_maps_to_pricing.

Verification. 402 passed, 0 failed, including the new test. cargo clippy --locked --all-targets -- -D warnings and cargo fmt --check clean. Run: 30646415635, on the same tree as this branch plus a temporary workflow that is not part of the change, since checks.yml does not run cargo test.

Summary by CodeRabbit

  • New Features
    • Added support for the Claude Opus 5 model.
    • Added recognition for canonical, versioned, alternate-format, and Bedrock model names.
    • Added pricing for input, output, and cached usage.

claude-opus-5 had no entry, so get_model_info returned None and every Opus 5
message priced to $0 after a warn_once. Rates are $5 per million input and $25
per million output, the same as Claude Opus 4.8, which puts cache write at 6.25
and cache read at 0.5 under the multipliers used throughout this file.

Aliases follow the shape already used for the other 5-generation models. The
global.anthropic. form matches claude-sonnet-5; claude-fable-5 does not carry
one, so that part is a choice rather than a deduction and is easy to drop.

Closes Piebald-AI#221
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The model registry adds claude-opus-5 with Anthropic input, output, and caching rates. Aliases resolve supported Claude and Bedrock naming variants. A test verifies alias resolution and calculated costs.

Changes

Claude Opus 5 support

Layer / File(s) Summary
Pricing, aliases, and cost validation
src/models.rs
Registers Claude Opus 5 pricing and cache rates, maps naming variants to the canonical model, and tests calculated costs.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: jimyag

Poem

A rabbit hops through model rows,
Where Opus pricing now clearly shows.
Aliases guide each name in place,
Cache costs join the counting race.
Tests thump softly: all costs align.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: adding Claude Opus 5 pricing to the model registry.
Linked Issues check ✅ Passed The changes register Claude Opus 5 with the required rates, aliases, and alias-pricing coverage from issue #221.
Out of Scope Changes check ✅ Passed The changes are limited to the model registry and related tests, which directly support issue #221.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/models.rs (1)

2774-2787: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Expand the regression test to cover the full alias and cache contract.

The test covers only claude-5-opus. It does not exercise the other accepted names, including global.anthropic.claude-opus-5. get_model_info does not normalize the dotted provider prefix, so that alias requires direct coverage.

The test also checks only the combined cache total. Add separate assertions for cache-write cost 6.25, cache-read cost 0.5, and combined cost 6.75.

Suggested test expansion
-        let model_info = get_model_info("claude-5-opus").expect("model should exist");
-        assert!(!model_info.is_estimated);
-
-        let input_cost = calculate_input_cost("claude-5-opus", 1_000_000);
-        let output_cost = calculate_output_cost("claude-5-opus", 1_000_000);
-        let cache_cost = calculate_cache_cost("claude-5-opus", 1_000_000, 1_000_000);
-
-        approx_eq(input_cost, 5.0);
-        approx_eq(output_cost, 25.0);
-        approx_eq(cache_cost, 6.75);
+        for model in [
+            "claude-opus-5",
+            "claude-opus-5.0",
+            "claude-5-opus",
+            "claude-5.0-opus",
+            "global.anthropic.claude-opus-5",
+        ] {
+            let model_info = get_model_info(model).expect("model should exist");
+            assert!(!model_info.is_estimated);
+
+            approx_eq(calculate_input_cost(model, 1_000_000), 5.0);
+            approx_eq(calculate_output_cost(model, 1_000_000), 25.0);
+            approx_eq(calculate_cache_cost(model, 1_000_000, 0), 6.25);
+            approx_eq(calculate_cache_cost(model, 0, 1_000_000), 0.5);
+            approx_eq(calculate_cache_cost(model, 1_000_000, 1_000_000), 6.75);
+        }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/models.rs` around lines 2774 - 2787, Expand
claude_opus_5_alias_maps_to_pricing to iterate over every accepted Claude Opus 5
alias, including global.anthropic.claude-opus-5, and verify each resolves
through get_model_info with non-estimated pricing and the expected input/output
costs. Add separate cache-write and cache-read assertions for 6.25 and 0.5,
while retaining the combined cache-cost assertion of 6.75.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/models.rs`:
- Around line 2774-2787: Expand claude_opus_5_alias_maps_to_pricing to iterate
over every accepted Claude Opus 5 alias, including
global.anthropic.claude-opus-5, and verify each resolves through get_model_info
with non-estimated pricing and the expected input/output costs. Add separate
cache-write and cache-read assertions for 6.25 and 0.5, while retaining the
combined cache-cost assertion of 6.75.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8337412b-6d2d-40b1-a7e1-d005ac2c327f

📥 Commits

Reviewing files that changed from the base of the PR and between fd59fa9 and aabb980.

📒 Files selected for processing (1)
  • src/models.rs

@mike1858
mike1858 enabled auto-merge (squash) July 31, 2026 16:45
@mike1858
mike1858 merged commit 2ace23b into Piebald-AI:main Jul 31, 2026
6 checks passed
@NickAme03
NickAme03 deleted the add-opus-5-pricing branch July 31, 2026 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Claude Opus 5 is missing from the model registry: all Opus 5 usage is priced at $0

2 participants