diff --git a/constant/channel.go b/constant/channel.go index 48502bedc52c..26e407de9806 100644 --- a/constant/channel.go +++ b/constant/channel.go @@ -206,4 +206,12 @@ var ChannelSpecialBases = map[string]ChannelSpecialBase{ ClaudeBaseURL: "https://ark.cn-beijing.volces.com/api/coding", OpenAIBaseURL: "https://ark.cn-beijing.volces.com/api/coding/v3", }, + "ali-token-plan": { + ClaudeBaseURL: "https://token-plan.cn-beijing.maas.aliyuncs.com/apps/anthropic", + OpenAIBaseURL: "https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1", + }, + "minimax-token-plan": { + ClaudeBaseURL: "https://api.minimaxi.com/anthropic", + OpenAIBaseURL: "https://api.minimaxi.com/v1", + }, } diff --git a/relay/channel/ali/adaptor.go b/relay/channel/ali/adaptor.go index cb3070ff367e..e64cd9990704 100644 --- a/relay/channel/ali/adaptor.go +++ b/relay/channel/ali/adaptor.go @@ -8,6 +8,7 @@ import ( "strings" "github.com/QuantumNous/new-api/common" + channelconstant "github.com/QuantumNous/new-api/constant" "github.com/QuantumNous/new-api/dto" "github.com/QuantumNous/new-api/relay/channel" "github.com/QuantumNous/new-api/relay/channel/claude" @@ -90,6 +91,17 @@ func (a *Adaptor) Init(info *relaycommon.RelayInfo) { func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) { var fullRequestURL string + + baseURL := info.ChannelBaseUrl + if specialPlan, ok := channelconstant.ChannelSpecialBases[baseURL]; ok { + switch info.RelayFormat { + case types.RelayFormatClaude: + return fmt.Sprintf("%s/v1/messages", specialPlan.ClaudeBaseURL), nil + default: + return fmt.Sprintf("%s/chat/completions", specialPlan.OpenAIBaseURL), nil + } + } + switch info.RelayFormat { case types.RelayFormatClaude: if supportsAliAnthropicMessages(info.UpstreamModelName) { diff --git a/relay/channel/minimax/relay-minimax.go b/relay/channel/minimax/relay-minimax.go index a1a05150c00f..3ada4f411218 100644 --- a/relay/channel/minimax/relay-minimax.go +++ b/relay/channel/minimax/relay-minimax.go @@ -14,9 +14,19 @@ func GetRequestURL(info *relaycommon.RelayInfo) (string, error) { if baseUrl == "" { baseUrl = channelconstant.ChannelBaseURLs[channelconstant.ChannelTypeMiniMax] } + + if specialPlan, ok := channelconstant.ChannelSpecialBases[baseUrl]; ok { + switch info.RelayFormat { + case types.RelayFormatClaude: + return fmt.Sprintf("%s/v1/messages", specialPlan.ClaudeBaseURL), nil + default: + return fmt.Sprintf("%s/chat/completions", specialPlan.OpenAIBaseURL), nil + } + } + switch info.RelayFormat { case types.RelayFormatClaude: - return fmt.Sprintf("%s/anthropic/v1/messages", info.ChannelBaseUrl), nil + return fmt.Sprintf("%s/anthropic/v1/messages", baseUrl), nil default: switch info.RelayMode { case constant.RelayModeChatCompletions: