-
Notifications
You must be signed in to change notification settings - Fork 11.2k
feat: add claude-opus-4-6 #2863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2504818
ff71786
c9f5de7
729610b
8e6071f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,7 @@ package relay | |||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| import ( | ||||||||||||||||||||||||||||||||||||||
| "bytes" | ||||||||||||||||||||||||||||||||||||||
| "encoding/json" | ||||||||||||||||||||||||||||||||||||||
| "fmt" | ||||||||||||||||||||||||||||||||||||||
| "io" | ||||||||||||||||||||||||||||||||||||||
| "net/http" | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -14,6 +15,7 @@ import ( | |||||||||||||||||||||||||||||||||||||
| "github.com/QuantumNous/new-api/relay/helper" | ||||||||||||||||||||||||||||||||||||||
| "github.com/QuantumNous/new-api/service" | ||||||||||||||||||||||||||||||||||||||
| "github.com/QuantumNous/new-api/setting/model_setting" | ||||||||||||||||||||||||||||||||||||||
| "github.com/QuantumNous/new-api/setting/reasoning" | ||||||||||||||||||||||||||||||||||||||
| "github.com/QuantumNous/new-api/types" | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| "github.com/gin-gonic/gin" | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -49,7 +51,17 @@ func ClaudeHelper(c *gin.Context, info *relaycommon.RelayInfo) (newAPIError *typ | |||||||||||||||||||||||||||||||||||||
| request.MaxTokens = uint(model_setting.GetClaudeSettings().GetDefaultMaxTokens(request.Model)) | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| if model_setting.GetClaudeSettings().ThinkingAdapterEnabled && | ||||||||||||||||||||||||||||||||||||||
| if baseModel, effortLevel, ok := reasoning.TrimEffortSuffix(request.Model); ok && effortLevel != "" && | ||||||||||||||||||||||||||||||||||||||
| strings.HasPrefix(request.Model, "claude-opus-4-6") { | ||||||||||||||||||||||||||||||||||||||
| request.Model = baseModel | ||||||||||||||||||||||||||||||||||||||
| request.Thinking = &dto.Thinking{ | ||||||||||||||||||||||||||||||||||||||
| Type: "adaptive", | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| request.OutputConfig = json.RawMessage(fmt.Sprintf(`{"effort":"%s"}`, effortLevel)) | ||||||||||||||||||||||||||||||||||||||
| request.TopP = 0 | ||||||||||||||||||||||||||||||||||||||
| request.Temperature = common.GetPointer[float64](1.0) | ||||||||||||||||||||||||||||||||||||||
| info.UpstreamModelName = request.Model | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+54
to
+63
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Missing The parallel code in 🐛 Proposed fix if baseModel, effortLevel, ok := reasoning.TrimEffortSuffix(request.Model); ok && effortLevel != "" &&
strings.HasPrefix(request.Model, "claude-opus-4-6") {
request.Model = baseModel
request.Thinking = &dto.Thinking{
Type: "adaptive",
}
request.OutputConfig = json.RawMessage(fmt.Sprintf(`{"effort":"%s"}`, effortLevel))
+ request.TopP = 0
+ request.Temperature = common.GetPointer[float64](1.0)
info.UpstreamModelName = request.Model📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
| } else if model_setting.GetClaudeSettings().ThinkingAdapterEnabled && | ||||||||||||||||||||||||||||||||||||||
| strings.HasSuffix(request.Model, "-thinking") { | ||||||||||||||||||||||||||||||||||||||
| if request.Thinking == nil { | ||||||||||||||||||||||||||||||||||||||
| // 因为BudgetTokens 必须大于1024 | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ import ( | |
| "github.com/samber/lo" | ||
| ) | ||
|
|
||
| var EffortSuffixes = []string{"-high", "-medium", "-low", "-minimal"} | ||
| var EffortSuffixes = []string{"-max", "-high", "-medium", "-low", "-minimal"} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: rg -n --type=go 'TrimEffortSuffix' -B 5 -A 5Repository: QuantumNous/new-api Length of output: 5151 Add model-prefix guards to three additional callers of Adding
These unguarded sites will now strip 🤖 Prompt for AI Agents |
||
|
|
||
| // TrimEffortSuffix -> modelName level(low) exists | ||
| func TrimEffortSuffix(modelName string) (string, string, bool) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
AWS Bedrock claude-opus-4-6 model ID format anthropic💡 Result:
AWS Bedrock Anthropic Claude model IDs use this pattern:
anthropic.claude-opus-<major>-<minor>-<YYYYMMDD>-v1:0(e.g.,anthropic.claude-opus-4-1-20250805-v1:0,anthropic.claude-opus-4-5-20251101-v1:0) [2]global./us./eu./jp./apac.+ the base model ID (as shown in Anthropic’s Bedrock table) [2]For Claude Opus 4.6, AWS announced it became available in Bedrock on Feb 5, 2026, but the exact Bedrock model ID string (including the
<YYYYMMDD>snapshot) isn’t shown in the public tables I found yet [1][2]. The reliable way to get the exact ID in your region is to list models from Bedrock:AWS Bedrock model ID is malformed — missing both snapshot date and version suffix.
According to AWS Bedrock documentation, Anthropic Claude model IDs follow the pattern
anthropic.claude-opus-<major>-<minor>-<YYYYMMDD>-v1:0. The entry"anthropic.claude-opus-4-6-v1"is missing both the snapshot date (<YYYYMMDD>) and the:0version suffix. All other Claude models in this map include these components (e.g.,anthropic.claude-opus-4-1-20250805-v1:0). The malformed ID will fail API calls to AWS Bedrock. Update to the correct format with the appropriate snapshot date for Claude Opus 4.6.🤖 Prompt for AI Agents