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
77d9a546
authored
Jan 21, 2026
by
Calcium-Ion
Committed by
GitHub
Jan 21, 2026
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2702 from seefs001/fix/ali-baseurl
fix: replace Alibaba's Claude-compatible url with new url
parents
3f208ee3
40f2b2fd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
5 deletions
+31
-5
relay/channel/ali/adaptor.go
+31
-5
No files found.
relay/channel/ali/adaptor.go
View file @
77d9a546
...
@@ -13,6 +13,7 @@ import (
...
@@ -13,6 +13,7 @@ import (
"github.com/QuantumNous/new-api/relay/channel/openai"
"github.com/QuantumNous/new-api/relay/channel/openai"
relaycommon
"github.com/QuantumNous/new-api/relay/common"
relaycommon
"github.com/QuantumNous/new-api/relay/common"
"github.com/QuantumNous/new-api/relay/constant"
"github.com/QuantumNous/new-api/relay/constant"
"github.com/QuantumNous/new-api/service"
"github.com/QuantumNous/new-api/types"
"github.com/QuantumNous/new-api/types"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin"
...
@@ -22,6 +23,11 @@ type Adaptor struct {
...
@@ -22,6 +23,11 @@ type Adaptor struct {
IsSyncImageModel
bool
IsSyncImageModel
bool
}
}
func
supportsAliAnthropicMessages
(
modelName
string
)
bool
{
// Only models with the "qwen" designation can use the Claude-compatible interface; others require conversion.
return
strings
.
Contains
(
strings
.
ToLower
(
modelName
),
"qwen"
)
}
var
syncModels
=
[]
string
{
var
syncModels
=
[]
string
{
"z-image"
,
"z-image"
,
"qwen-image"
,
"qwen-image"
,
...
@@ -43,7 +49,18 @@ func (a *Adaptor) ConvertGeminiRequest(*gin.Context, *relaycommon.RelayInfo, *dt
...
@@ -43,7 +49,18 @@ func (a *Adaptor) ConvertGeminiRequest(*gin.Context, *relaycommon.RelayInfo, *dt
}
}
func
(
a
*
Adaptor
)
ConvertClaudeRequest
(
c
*
gin
.
Context
,
info
*
relaycommon
.
RelayInfo
,
req
*
dto
.
ClaudeRequest
)
(
any
,
error
)
{
func
(
a
*
Adaptor
)
ConvertClaudeRequest
(
c
*
gin
.
Context
,
info
*
relaycommon
.
RelayInfo
,
req
*
dto
.
ClaudeRequest
)
(
any
,
error
)
{
return
req
,
nil
if
supportsAliAnthropicMessages
(
info
.
UpstreamModelName
)
{
return
req
,
nil
}
oaiReq
,
err
:=
service
.
ClaudeToOpenAIRequest
(
*
req
,
info
)
if
err
!=
nil
{
return
nil
,
err
}
if
info
.
SupportStreamOptions
&&
info
.
IsStream
{
oaiReq
.
StreamOptions
=
&
dto
.
StreamOptions
{
IncludeUsage
:
true
}
}
return
a
.
ConvertOpenAIRequest
(
c
,
info
,
oaiReq
)
}
}
func
(
a
*
Adaptor
)
Init
(
info
*
relaycommon
.
RelayInfo
)
{
func
(
a
*
Adaptor
)
Init
(
info
*
relaycommon
.
RelayInfo
)
{
...
@@ -53,7 +70,11 @@ func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
...
@@ -53,7 +70,11 @@ func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
var
fullRequestURL
string
var
fullRequestURL
string
switch
info
.
RelayFormat
{
switch
info
.
RelayFormat
{
case
types
.
RelayFormatClaude
:
case
types
.
RelayFormatClaude
:
fullRequestURL
=
fmt
.
Sprintf
(
"%s/api/v2/apps/claude-code-proxy/v1/messages"
,
info
.
ChannelBaseUrl
)
if
supportsAliAnthropicMessages
(
info
.
UpstreamModelName
)
{
fullRequestURL
=
fmt
.
Sprintf
(
"%s/apps/anthropic/v1/messages"
,
info
.
ChannelBaseUrl
)
}
else
{
fullRequestURL
=
fmt
.
Sprintf
(
"%s/compatible-mode/v1/chat/completions"
,
info
.
ChannelBaseUrl
)
}
default
:
default
:
switch
info
.
RelayMode
{
switch
info
.
RelayMode
{
case
constant
.
RelayModeEmbeddings
:
case
constant
.
RelayModeEmbeddings
:
...
@@ -197,11 +218,16 @@ func (a *Adaptor) DoRequest(c *gin.Context, info *relaycommon.RelayInfo, request
...
@@ -197,11 +218,16 @@ func (a *Adaptor) DoRequest(c *gin.Context, info *relaycommon.RelayInfo, request
func
(
a
*
Adaptor
)
DoResponse
(
c
*
gin
.
Context
,
resp
*
http
.
Response
,
info
*
relaycommon
.
RelayInfo
)
(
usage
any
,
err
*
types
.
NewAPIError
)
{
func
(
a
*
Adaptor
)
DoResponse
(
c
*
gin
.
Context
,
resp
*
http
.
Response
,
info
*
relaycommon
.
RelayInfo
)
(
usage
any
,
err
*
types
.
NewAPIError
)
{
switch
info
.
RelayFormat
{
switch
info
.
RelayFormat
{
case
types
.
RelayFormatClaude
:
case
types
.
RelayFormatClaude
:
if
info
.
IsStream
{
if
supportsAliAnthropicMessages
(
info
.
UpstreamModelName
)
{
return
claude
.
ClaudeStreamHandler
(
c
,
resp
,
info
,
claude
.
RequestModeMessage
)
if
info
.
IsStream
{
}
else
{
return
claude
.
ClaudeStreamHandler
(
c
,
resp
,
info
,
claude
.
RequestModeMessage
)
}
return
claude
.
ClaudeHandler
(
c
,
resp
,
info
,
claude
.
RequestModeMessage
)
return
claude
.
ClaudeHandler
(
c
,
resp
,
info
,
claude
.
RequestModeMessage
)
}
}
adaptor
:=
openai
.
Adaptor
{}
return
adaptor
.
DoResponse
(
c
,
resp
,
info
)
default
:
default
:
switch
info
.
RelayMode
{
switch
info
.
RelayMode
{
case
constant
.
RelayModeImagesGenerations
:
case
constant
.
RelayModeImagesGenerations
:
...
...
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