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
Unverified
Commit
763c3ff7
authored
Mar 23, 2026
by
Calcium-Ion
Committed by
GitHub
Mar 23, 2026
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3331 from seefs001/fix/claude-beta-query
fix: apply forced beta query at final upstream URL stage
parents
c667e470
e520977e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
9 deletions
+26
-9
relay/channel/claude/adaptor.go
+25
-3
relay/common/relay_info.go
+1
-6
No files found.
relay/channel/claude/adaptor.go
View file @
763c3ff7
...
@@ -5,6 +5,7 @@ import (
...
@@ -5,6 +5,7 @@ import (
"fmt"
"fmt"
"io"
"io"
"net/http"
"net/http"
"net/url"
"github.com/QuantumNous/new-api/dto"
"github.com/QuantumNous/new-api/dto"
"github.com/QuantumNous/new-api/relay/channel"
"github.com/QuantumNous/new-api/relay/channel"
...
@@ -41,11 +42,32 @@ func (a *Adaptor) Init(info *relaycommon.RelayInfo) {
...
@@ -41,11 +42,32 @@ func (a *Adaptor) Init(info *relaycommon.RelayInfo) {
}
}
func
(
a
*
Adaptor
)
GetRequestURL
(
info
*
relaycommon
.
RelayInfo
)
(
string
,
error
)
{
func
(
a
*
Adaptor
)
GetRequestURL
(
info
*
relaycommon
.
RelayInfo
)
(
string
,
error
)
{
baseURL
:=
fmt
.
Sprintf
(
"%s/v1/messages"
,
info
.
ChannelBaseUrl
)
requestURL
:=
fmt
.
Sprintf
(
"%s/v1/messages"
,
info
.
ChannelBaseUrl
)
if
!
shouldAppendClaudeBetaQuery
(
info
)
{
return
requestURL
,
nil
}
parsedURL
,
err
:=
url
.
Parse
(
requestURL
)
if
err
!=
nil
{
return
""
,
err
}
query
:=
parsedURL
.
Query
()
query
.
Set
(
"beta"
,
"true"
)
parsedURL
.
RawQuery
=
query
.
Encode
()
return
parsedURL
.
String
(),
nil
}
func
shouldAppendClaudeBetaQuery
(
info
*
relaycommon
.
RelayInfo
)
bool
{
if
info
==
nil
{
return
false
}
if
info
.
IsClaudeBetaQuery
{
if
info
.
IsClaudeBetaQuery
{
baseURL
=
baseURL
+
"?beta=true"
return
true
}
if
info
.
ChannelOtherSettings
.
ClaudeBetaQuery
{
return
true
}
}
return
baseURL
,
nil
return
false
}
}
func
CommonClaudeHeadersOperation
(
c
*
gin
.
Context
,
req
*
http
.
Header
,
info
*
relaycommon
.
RelayInfo
)
{
func
CommonClaudeHeadersOperation
(
c
*
gin
.
Context
,
req
*
http
.
Header
,
info
*
relaycommon
.
RelayInfo
)
{
...
...
relay/common/relay_info.go
View file @
763c3ff7
...
@@ -338,15 +338,10 @@ func GenRelayInfoClaude(c *gin.Context, request dto.Request) *RelayInfo {
...
@@ -338,15 +338,10 @@ func GenRelayInfoClaude(c *gin.Context, request dto.Request) *RelayInfo {
info
.
ClaudeConvertInfo
=
&
ClaudeConvertInfo
{
info
.
ClaudeConvertInfo
=
&
ClaudeConvertInfo
{
LastMessagesType
:
LastMessageTypeNone
,
LastMessagesType
:
LastMessageTypeNone
,
}
}
info
.
IsClaudeBetaQuery
=
c
.
Query
(
"beta"
)
==
"true"
||
isClaudeBetaForced
(
c
)
info
.
IsClaudeBetaQuery
=
c
.
Query
(
"beta"
)
==
"true"
return
info
return
info
}
}
func
isClaudeBetaForced
(
c
*
gin
.
Context
)
bool
{
channelOtherSettings
,
ok
:=
common
.
GetContextKeyType
[
dto
.
ChannelOtherSettings
](
c
,
constant
.
ContextKeyChannelOtherSetting
)
return
ok
&&
channelOtherSettings
.
ClaudeBetaQuery
}
func
GenRelayInfoRerank
(
c
*
gin
.
Context
,
request
*
dto
.
RerankRequest
)
*
RelayInfo
{
func
GenRelayInfoRerank
(
c
*
gin
.
Context
,
request
*
dto
.
RerankRequest
)
*
RelayInfo
{
info
:=
genBaseRelayInfo
(
c
,
request
)
info
:=
genBaseRelayInfo
(
c
,
request
)
info
.
RelayMode
=
relayconstant
.
RelayModeRerank
info
.
RelayMode
=
relayconstant
.
RelayModeRerank
...
...
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