Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
96f9ff19
authored
Feb 06, 2026
by
Calcium-Ion
Committed by
GitHub
Feb 06, 2026
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2863 from prnake/feat/claude-opus-4-6
feat: add claude-opus-4-6
parents
1113181a
a872a1ed
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
60 additions
and
4 deletions
+60
-4
relay/channel/aws/constants.go
+7
-1
relay/channel/aws/dto.go
+1
-0
relay/channel/claude/constants.go
+5
-0
relay/channel/claude/relay-claude.go
+11
-1
relay/channel/vertex/adaptor.go
+1
-0
relay/channel/vertex/dto.go
+4
-0
relay/claude_handler.go
+13
-1
setting/ratio_setting/cache_ratio.go
+12
-0
setting/ratio_setting/model_ratio.go
+5
-0
setting/reasoning/suffix.go
+1
-1
No files found.
relay/channel/aws/constants.go
View file @
96f9ff19
...
@@ -3,7 +3,7 @@ package aws
...
@@ -3,7 +3,7 @@ package aws
import
"strings"
import
"strings"
var
awsModelIDMap
=
map
[
string
]
string
{
var
awsModelIDMap
=
map
[
string
]
string
{
"claude-3-sonnet-20240229"
:
"anthropic.claude-3-sonnet-20240229-v1:0"
,
"claude-3-sonnet-20240229"
:
"anthropic.claude-3-sonnet-20240229-v1:0"
,
"claude-3-opus-20240229"
:
"anthropic.claude-3-opus-20240229-v1:0"
,
"claude-3-opus-20240229"
:
"anthropic.claude-3-opus-20240229-v1:0"
,
"claude-3-haiku-20240307"
:
"anthropic.claude-3-haiku-20240307-v1:0"
,
"claude-3-haiku-20240307"
:
"anthropic.claude-3-haiku-20240307-v1:0"
,
"claude-3-5-sonnet-20240620"
:
"anthropic.claude-3-5-sonnet-20240620-v1:0"
,
"claude-3-5-sonnet-20240620"
:
"anthropic.claude-3-5-sonnet-20240620-v1:0"
,
...
@@ -16,6 +16,7 @@ var awsModelIDMap = map[string]string{
...
@@ -16,6 +16,7 @@ var awsModelIDMap = map[string]string{
"claude-sonnet-4-5-20250929"
:
"anthropic.claude-sonnet-4-5-20250929-v1:0"
,
"claude-sonnet-4-5-20250929"
:
"anthropic.claude-sonnet-4-5-20250929-v1:0"
,
"claude-haiku-4-5-20251001"
:
"anthropic.claude-haiku-4-5-20251001-v1:0"
,
"claude-haiku-4-5-20251001"
:
"anthropic.claude-haiku-4-5-20251001-v1:0"
,
"claude-opus-4-5-20251101"
:
"anthropic.claude-opus-4-5-20251101-v1:0"
,
"claude-opus-4-5-20251101"
:
"anthropic.claude-opus-4-5-20251101-v1:0"
,
"claude-opus-4-6"
:
"anthropic.claude-opus-4-6-v1"
,
// Nova models
// Nova models
"nova-micro-v1:0"
:
"amazon.nova-micro-v1:0"
,
"nova-micro-v1:0"
:
"amazon.nova-micro-v1:0"
,
"nova-lite-v1:0"
:
"amazon.nova-lite-v1:0"
,
"nova-lite-v1:0"
:
"amazon.nova-lite-v1:0"
,
...
@@ -79,6 +80,11 @@ var awsModelCanCrossRegionMap = map[string]map[string]bool{
...
@@ -79,6 +80,11 @@ var awsModelCanCrossRegionMap = map[string]map[string]bool{
"ap"
:
true
,
"ap"
:
true
,
"eu"
:
true
,
"eu"
:
true
,
},
},
"anthropic.claude-opus-4-6-v1"
:
{
"us"
:
true
,
"ap"
:
true
,
"eu"
:
true
,
},
"anthropic.claude-haiku-4-5-20251001-v1:0"
:
{
"anthropic.claude-haiku-4-5-20251001-v1:0"
:
{
"us"
:
true
,
"us"
:
true
,
"ap"
:
true
,
"ap"
:
true
,
...
...
relay/channel/aws/dto.go
View file @
96f9ff19
...
@@ -26,6 +26,7 @@ type AwsClaudeRequest struct {
...
@@ -26,6 +26,7 @@ type AwsClaudeRequest struct {
Tools
any
`json:"tools,omitempty"`
Tools
any
`json:"tools,omitempty"`
ToolChoice
any
`json:"tool_choice,omitempty"`
ToolChoice
any
`json:"tool_choice,omitempty"`
Thinking
*
dto
.
Thinking
`json:"thinking,omitempty"`
Thinking
*
dto
.
Thinking
`json:"thinking,omitempty"`
OutputConfig
json
.
RawMessage
`json:"output_config,omitempty"`
}
}
func
formatRequest
(
requestBody
io
.
Reader
,
requestHeader
http
.
Header
)
(
*
AwsClaudeRequest
,
error
)
{
func
formatRequest
(
requestBody
io
.
Reader
,
requestHeader
http
.
Header
)
(
*
AwsClaudeRequest
,
error
)
{
...
...
relay/channel/claude/constants.go
View file @
96f9ff19
...
@@ -20,6 +20,11 @@ var ModelList = []string{
...
@@ -20,6 +20,11 @@ var ModelList = []string{
"claude-sonnet-4-5-20250929-thinking"
,
"claude-sonnet-4-5-20250929-thinking"
,
"claude-opus-4-5-20251101"
,
"claude-opus-4-5-20251101"
,
"claude-opus-4-5-20251101-thinking"
,
"claude-opus-4-5-20251101-thinking"
,
"claude-opus-4-6"
,
"claude-opus-4-6-max"
,
"claude-opus-4-6-high"
,
"claude-opus-4-6-medium"
,
"claude-opus-4-6-low"
,
}
}
var
ChannelName
=
"claude"
var
ChannelName
=
"claude"
relay/channel/claude/relay-claude.go
View file @
96f9ff19
...
@@ -17,6 +17,7 @@ import (
...
@@ -17,6 +17,7 @@ import (
"github.com/QuantumNous/new-api/relay/reasonmap"
"github.com/QuantumNous/new-api/relay/reasonmap"
"github.com/QuantumNous/new-api/service"
"github.com/QuantumNous/new-api/service"
"github.com/QuantumNous/new-api/setting/model_setting"
"github.com/QuantumNous/new-api/setting/model_setting"
"github.com/QuantumNous/new-api/setting/reasoning"
"github.com/QuantumNous/new-api/types"
"github.com/QuantumNous/new-api/types"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin"
...
@@ -141,7 +142,16 @@ func RequestOpenAI2ClaudeMessage(c *gin.Context, textRequest dto.GeneralOpenAIRe
...
@@ -141,7 +142,16 @@ func RequestOpenAI2ClaudeMessage(c *gin.Context, textRequest dto.GeneralOpenAIRe
claudeRequest
.
MaxTokens
=
uint
(
model_setting
.
GetClaudeSettings
()
.
GetDefaultMaxTokens
(
textRequest
.
Model
))
claudeRequest
.
MaxTokens
=
uint
(
model_setting
.
GetClaudeSettings
()
.
GetDefaultMaxTokens
(
textRequest
.
Model
))
}
}
if
model_setting
.
GetClaudeSettings
()
.
ThinkingAdapterEnabled
&&
if
baseModel
,
effortLevel
,
ok
:=
reasoning
.
TrimEffortSuffix
(
textRequest
.
Model
);
ok
&&
effortLevel
!=
""
&&
strings
.
HasPrefix
(
textRequest
.
Model
,
"claude-opus-4-6"
)
{
claudeRequest
.
Model
=
baseModel
claudeRequest
.
Thinking
=
&
dto
.
Thinking
{
Type
:
"adaptive"
,
}
claudeRequest
.
OutputConfig
=
json
.
RawMessage
(
fmt
.
Sprintf
(
`{"effort":"%s"}`
,
effortLevel
))
claudeRequest
.
TopP
=
0
claudeRequest
.
Temperature
=
common
.
GetPointer
[
float64
](
1.0
)
}
else
if
model_setting
.
GetClaudeSettings
()
.
ThinkingAdapterEnabled
&&
strings
.
HasSuffix
(
textRequest
.
Model
,
"-thinking"
)
{
strings
.
HasSuffix
(
textRequest
.
Model
,
"-thinking"
)
{
// 因为BudgetTokens 必须大于1024
// 因为BudgetTokens 必须大于1024
...
...
relay/channel/vertex/adaptor.go
View file @
96f9ff19
...
@@ -42,6 +42,7 @@ var claudeModelMap = map[string]string{
...
@@ -42,6 +42,7 @@ var claudeModelMap = map[string]string{
"claude-sonnet-4-5-20250929"
:
"claude-sonnet-4-5@20250929"
,
"claude-sonnet-4-5-20250929"
:
"claude-sonnet-4-5@20250929"
,
"claude-haiku-4-5-20251001"
:
"claude-haiku-4-5@20251001"
,
"claude-haiku-4-5-20251001"
:
"claude-haiku-4-5@20251001"
,
"claude-opus-4-5-20251101"
:
"claude-opus-4-5@20251101"
,
"claude-opus-4-5-20251101"
:
"claude-opus-4-5@20251101"
,
"claude-opus-4-6"
:
"claude-opus-4-6"
,
}
}
const
anthropicVersion
=
"vertex-2023-10-16"
const
anthropicVersion
=
"vertex-2023-10-16"
...
...
relay/channel/vertex/dto.go
View file @
96f9ff19
package
vertex
package
vertex
import
(
import
(
"encoding/json"
"github.com/QuantumNous/new-api/dto"
"github.com/QuantumNous/new-api/dto"
)
)
...
@@ -17,6 +19,7 @@ type VertexAIClaudeRequest struct {
...
@@ -17,6 +19,7 @@ type VertexAIClaudeRequest struct {
Tools
any
`json:"tools,omitempty"`
Tools
any
`json:"tools,omitempty"`
ToolChoice
any
`json:"tool_choice,omitempty"`
ToolChoice
any
`json:"tool_choice,omitempty"`
Thinking
*
dto
.
Thinking
`json:"thinking,omitempty"`
Thinking
*
dto
.
Thinking
`json:"thinking,omitempty"`
OutputConfig
json
.
RawMessage
`json:"output_config,omitempty"`
}
}
func
copyRequest
(
req
*
dto
.
ClaudeRequest
,
version
string
)
*
VertexAIClaudeRequest
{
func
copyRequest
(
req
*
dto
.
ClaudeRequest
,
version
string
)
*
VertexAIClaudeRequest
{
...
@@ -33,5 +36,6 @@ func copyRequest(req *dto.ClaudeRequest, version string) *VertexAIClaudeRequest
...
@@ -33,5 +36,6 @@ func copyRequest(req *dto.ClaudeRequest, version string) *VertexAIClaudeRequest
Tools
:
req
.
Tools
,
Tools
:
req
.
Tools
,
ToolChoice
:
req
.
ToolChoice
,
ToolChoice
:
req
.
ToolChoice
,
Thinking
:
req
.
Thinking
,
Thinking
:
req
.
Thinking
,
OutputConfig
:
req
.
OutputConfig
,
}
}
}
}
relay/claude_handler.go
View file @
96f9ff19
...
@@ -2,6 +2,7 @@ package relay
...
@@ -2,6 +2,7 @@ package relay
import
(
import
(
"bytes"
"bytes"
"encoding/json"
"fmt"
"fmt"
"io"
"io"
"net/http"
"net/http"
...
@@ -14,6 +15,7 @@ import (
...
@@ -14,6 +15,7 @@ import (
"github.com/QuantumNous/new-api/relay/helper"
"github.com/QuantumNous/new-api/relay/helper"
"github.com/QuantumNous/new-api/service"
"github.com/QuantumNous/new-api/service"
"github.com/QuantumNous/new-api/setting/model_setting"
"github.com/QuantumNous/new-api/setting/model_setting"
"github.com/QuantumNous/new-api/setting/reasoning"
"github.com/QuantumNous/new-api/types"
"github.com/QuantumNous/new-api/types"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin"
...
@@ -49,7 +51,17 @@ func ClaudeHelper(c *gin.Context, info *relaycommon.RelayInfo) (newAPIError *typ
...
@@ -49,7 +51,17 @@ func ClaudeHelper(c *gin.Context, info *relaycommon.RelayInfo) (newAPIError *typ
request
.
MaxTokens
=
uint
(
model_setting
.
GetClaudeSettings
()
.
GetDefaultMaxTokens
(
request
.
Model
))
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
}
else
if
model_setting
.
GetClaudeSettings
()
.
ThinkingAdapterEnabled
&&
strings
.
HasSuffix
(
request
.
Model
,
"-thinking"
)
{
strings
.
HasSuffix
(
request
.
Model
,
"-thinking"
)
{
if
request
.
Thinking
==
nil
{
if
request
.
Thinking
==
nil
{
// 因为BudgetTokens 必须大于1024
// 因为BudgetTokens 必须大于1024
...
...
setting/ratio_setting/cache_ratio.go
View file @
96f9ff19
...
@@ -60,6 +60,12 @@ var defaultCacheRatio = map[string]float64{
...
@@ -60,6 +60,12 @@ var defaultCacheRatio = map[string]float64{
"claude-sonnet-4-5-20250929-thinking"
:
0.1
,
"claude-sonnet-4-5-20250929-thinking"
:
0.1
,
"claude-opus-4-5-20251101"
:
0.1
,
"claude-opus-4-5-20251101"
:
0.1
,
"claude-opus-4-5-20251101-thinking"
:
0.1
,
"claude-opus-4-5-20251101-thinking"
:
0.1
,
"claude-opus-4-6"
:
0.1
,
"claude-opus-4-6-thinking"
:
0.1
,
"claude-opus-4-6-max"
:
0.1
,
"claude-opus-4-6-high"
:
0.1
,
"claude-opus-4-6-medium"
:
0.1
,
"claude-opus-4-6-low"
:
0.1
,
}
}
var
defaultCreateCacheRatio
=
map
[
string
]
float64
{
var
defaultCreateCacheRatio
=
map
[
string
]
float64
{
...
@@ -82,6 +88,12 @@ var defaultCreateCacheRatio = map[string]float64{
...
@@ -82,6 +88,12 @@ var defaultCreateCacheRatio = map[string]float64{
"claude-sonnet-4-5-20250929-thinking"
:
1.25
,
"claude-sonnet-4-5-20250929-thinking"
:
1.25
,
"claude-opus-4-5-20251101"
:
1.25
,
"claude-opus-4-5-20251101"
:
1.25
,
"claude-opus-4-5-20251101-thinking"
:
1.25
,
"claude-opus-4-5-20251101-thinking"
:
1.25
,
"claude-opus-4-6"
:
1.25
,
"claude-opus-4-6-thinking"
:
1.25
,
"claude-opus-4-6-max"
:
1.25
,
"claude-opus-4-6-high"
:
1.25
,
"claude-opus-4-6-medium"
:
1.25
,
"claude-opus-4-6-low"
:
1.25
,
}
}
//var defaultCreateCacheRatio = map[string]float64{}
//var defaultCreateCacheRatio = map[string]float64{}
...
...
setting/ratio_setting/model_ratio.go
View file @
96f9ff19
...
@@ -142,6 +142,11 @@ var defaultModelRatio = map[string]float64{
...
@@ -142,6 +142,11 @@ var defaultModelRatio = map[string]float64{
"claude-sonnet-4-20250514"
:
1.5
,
"claude-sonnet-4-20250514"
:
1.5
,
"claude-sonnet-4-5-20250929"
:
1.5
,
"claude-sonnet-4-5-20250929"
:
1.5
,
"claude-opus-4-5-20251101"
:
2.5
,
"claude-opus-4-5-20251101"
:
2.5
,
"claude-opus-4-6"
:
2.5
,
"claude-opus-4-6-max"
:
2.5
,
"claude-opus-4-6-high"
:
2.5
,
"claude-opus-4-6-medium"
:
2.5
,
"claude-opus-4-6-low"
:
2.5
,
"claude-3-opus-20240229"
:
7.5
,
// $15 / 1M tokens
"claude-3-opus-20240229"
:
7.5
,
// $15 / 1M tokens
"claude-opus-4-20250514"
:
7.5
,
"claude-opus-4-20250514"
:
7.5
,
"claude-opus-4-1-20250805"
:
7.5
,
"claude-opus-4-1-20250805"
:
7.5
,
...
...
setting/reasoning/suffix.go
View file @
96f9ff19
...
@@ -6,7 +6,7 @@ import (
...
@@ -6,7 +6,7 @@ import (
"github.com/samber/lo"
"github.com/samber/lo"
)
)
var
EffortSuffixes
=
[]
string
{
"-high"
,
"-medium"
,
"-low"
,
"-minimal"
}
var
EffortSuffixes
=
[]
string
{
"-
max"
,
"-
high"
,
"-medium"
,
"-low"
,
"-minimal"
}
// TrimEffortSuffix -> modelName level(low) exists
// TrimEffortSuffix -> modelName level(low) exists
func
TrimEffortSuffix
(
modelName
string
)
(
string
,
string
,
bool
)
{
func
TrimEffortSuffix
(
modelName
string
)
(
string
,
string
,
bool
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment