feat: add support for claude-opus-4-1 model and update ratios - #1511
Conversation
WalkthroughNew model identifiers for "claude-opus-4-1-20250805" and its "thinking" variant were added across several configuration maps and model lists in the AWS, Claude, Vertex, and settings packages. These updates include model mappings, cache ratios, and model ratios, enabling support and configuration for these new models in the codebase. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant API
participant ModelRegistry
participant CacheSettings
Client->>API: Request with model "claude-opus-4-1-20250805"
API->>ModelRegistry: Lookup model mapping (AWS/Claude/Vertex)
ModelRegistry-->>API: Return mapped model string
API->>CacheSettings: Retrieve cache/model ratios for model
CacheSettings-->>API: Return ratio values
API-->>Client: Processed response using new model configuration
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. ✨ Finishing Touches
🧪 Generate 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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🔭 Outside diff range comments (1)
relay/channel/vertex/adaptor.go (1)
68-76: Thinking-variant not normalised for Claude requestsUnlike the Gemini block above, the Claude path never trims
-thinking/-budget suffixes before mapping.
Vertex will therefore receive an unknown model name such asclaude-opus-4-1-20250805-thinking, which is not present inclaudeModelMapnor the Vertex catalogue.if strings.HasPrefix(info.UpstreamModelName, "claude") { a.RequestMode = RequestModeClaude + // Normalise possible thinking/budget suffixes, mirroring Gemini handling + if strings.Contains(info.UpstreamModelName, "-thinking-") { + info.UpstreamModelName = strings.Split(info.UpstreamModelName, "-thinking-")[0] + } else if strings.HasSuffix(info.UpstreamModelName, "-thinking") { + info.UpstreamModelName = strings.TrimSuffix(info.UpstreamModelName, "-thinking") + } } else if strings.HasPrefix(info.UpstreamModelName, "gemini") {Alternatively, add a direct entry in
claudeModelMapfor the thinking variant.
🧹 Nitpick comments (1)
setting/ratio_setting/cache_ratio.go (1)
58-62: Consider alphabetical insertion for long-term diff hygieneKeeping the maps alphabetically ordered makes future merges easier and keeps the signal/noise ratio of diffs low.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
relay/channel/aws/constants.go(2 hunks)relay/channel/claude/constants.go(1 hunks)relay/channel/vertex/adaptor.go(1 hunks)setting/ratio_setting/cache_ratio.go(2 hunks)setting/ratio_setting/model_ratio.go(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: in relay/channel/gemini/relay-gemini.go, the thinking budget calculation logic (including the maxout...
Learnt from: 9Ninety
PR: QuantumNous/new-api#1273
File: relay/channel/gemini/relay-gemini.go:97-116
Timestamp: 2025-06-21T03:37:41.726Z
Learning: In relay/channel/gemini/relay-gemini.go, the thinking budget calculation logic (including the MaxOutputTokens multiplication) was introduced in PR #1247. PR #1273 focused specifically on decoupling the thoughts summary feature from thinking budget settings and did not modify the existing thinking budget behavior.
Applied to files:
setting/ratio_setting/cache_ratio.gorelay/channel/claude/constants.go
🔇 Additional comments (3)
setting/ratio_setting/cache_ratio.go (1)
41-45: LGTM – cache ratios added consistentlyBoth default and create-cache maps now cover the new Opus 4-1 model and its thinking variant with values aligned to earlier Opus entries.
relay/channel/claude/constants.go (1)
20-22: Model list update looks correctNew Opus 4-1 identifiers are exposed to downstream consumers; matches other maps.
relay/channel/aws/constants.go (1)
16-17: AWS model ID mapping added – verify cross-region strategyEntry is consistent with existing naming, but only the “us” region is enabled.
Please confirm no EU/APAC availability is required; otherwise extendawsModelCanCrossRegionMapaccordingly.
feat: add support for claude-opus-4-1 model and update ratios
Summary by CodeRabbit