From 0d1057830b0ac39f11780834ad329fbe50481e3e Mon Sep 17 00:00:00 2001 From: feitianbubu Date: Mon, 20 Oct 2025 14:00:07 +0800 Subject: [PATCH] feat: add minimax api adaptor --- common/api_type.go | 2 ++ constant/api_type.go | 1 + relay/channel/minimax/adaptor.go | 6 +++--- relay/channel/openai/adaptor.go | 14 +++++++------- relay/relay_adaptor.go | 3 +++ 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/common/api_type.go b/common/api_type.go index 6d7a70529..8dbf4a900 100644 --- a/common/api_type.go +++ b/common/api_type.go @@ -69,6 +69,8 @@ func ChannelType2APIType(channelType int) (int, bool) { apiType = constant.APITypeMoonshot case constant.ChannelTypeSubmodel: apiType = constant.APITypeSubmodel + case constant.ChannelTypeMiniMax: + apiType = constant.APITypeMiniMax } if apiType == -1 { return constant.APITypeOpenAI, false diff --git a/constant/api_type.go b/constant/api_type.go index 130ae9455..156ccc83c 100644 --- a/constant/api_type.go +++ b/constant/api_type.go @@ -33,5 +33,6 @@ const ( APITypeJimeng APITypeMoonshot APITypeSubmodel + APITypeMiniMax APITypeDummy // this one is only for count, do not add any channel after this ) diff --git a/relay/channel/minimax/adaptor.go b/relay/channel/minimax/adaptor.go index e2a96503a..cba2271cf 100644 --- a/relay/channel/minimax/adaptor.go +++ b/relay/channel/minimax/adaptor.go @@ -10,6 +10,7 @@ import ( "github.com/QuantumNous/new-api/dto" "github.com/QuantumNous/new-api/relay/channel" + "github.com/QuantumNous/new-api/relay/channel/openai" relaycommon "github.com/QuantumNous/new-api/relay/common" "github.com/QuantumNous/new-api/relay/constant" "github.com/QuantumNous/new-api/types" @@ -116,9 +117,8 @@ func (a *Adaptor) DoResponse(c *gin.Context, resp *http.Response, info *relaycom return handleTTSResponse(c, resp, info) } - // For chat completions, just pass through the response - // MiniMax API is compatible with OpenAI format - return handleChatCompletionResponse(c, resp, info) + adaptor := openai.Adaptor{} + return adaptor.DoResponse(c, resp, info) } func (a *Adaptor) GetModelList() []string { diff --git a/relay/channel/openai/adaptor.go b/relay/channel/openai/adaptor.go index ec40fa25b..4e41c866a 100644 --- a/relay/channel/openai/adaptor.go +++ b/relay/channel/openai/adaptor.go @@ -18,7 +18,7 @@ import ( "github.com/QuantumNous/new-api/relay/channel" "github.com/QuantumNous/new-api/relay/channel/ai360" "github.com/QuantumNous/new-api/relay/channel/lingyiwanwu" - "github.com/QuantumNous/new-api/relay/channel/minimax" + //"github.com/QuantumNous/new-api/relay/channel/minimax" "github.com/QuantumNous/new-api/relay/channel/openrouter" "github.com/QuantumNous/new-api/relay/channel/xinference" relaycommon "github.com/QuantumNous/new-api/relay/common" @@ -161,8 +161,8 @@ func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) { requestURL = fmt.Sprintf("/openai/realtime?deployment=%s&api-version=%s", model_, apiVersion) } return relaycommon.GetFullRequestURL(info.ChannelBaseUrl, requestURL, info.ChannelType), nil - case constant.ChannelTypeMiniMax: - return minimax.GetRequestURL(info) + //case constant.ChannelTypeMiniMax: + // return minimax.GetRequestURL(info) case constant.ChannelTypeCustom: url := info.ChannelBaseUrl url = strings.Replace(url, "{model}", info.UpstreamModelName, -1) @@ -599,8 +599,8 @@ func (a *Adaptor) GetModelList() []string { return ai360.ModelList case constant.ChannelTypeLingYiWanWu: return lingyiwanwu.ModelList - case constant.ChannelTypeMiniMax: - return minimax.ModelList + //case constant.ChannelTypeMiniMax: + // return minimax.ModelList case constant.ChannelTypeXinference: return xinference.ModelList case constant.ChannelTypeOpenRouter: @@ -616,8 +616,8 @@ func (a *Adaptor) GetChannelName() string { return ai360.ChannelName case constant.ChannelTypeLingYiWanWu: return lingyiwanwu.ChannelName - case constant.ChannelTypeMiniMax: - return minimax.ChannelName + //case constant.ChannelTypeMiniMax: + // return minimax.ChannelName case constant.ChannelTypeXinference: return xinference.ChannelName case constant.ChannelTypeOpenRouter: diff --git a/relay/relay_adaptor.go b/relay/relay_adaptor.go index 485abe5af..736a58223 100644 --- a/relay/relay_adaptor.go +++ b/relay/relay_adaptor.go @@ -18,6 +18,7 @@ import ( "github.com/QuantumNous/new-api/relay/channel/gemini" "github.com/QuantumNous/new-api/relay/channel/jimeng" "github.com/QuantumNous/new-api/relay/channel/jina" + "github.com/QuantumNous/new-api/relay/channel/minimax" "github.com/QuantumNous/new-api/relay/channel/mistral" "github.com/QuantumNous/new-api/relay/channel/mokaai" "github.com/QuantumNous/new-api/relay/channel/moonshot" @@ -108,6 +109,8 @@ func GetAdaptor(apiType int) channel.Adaptor { return &moonshot.Adaptor{} // Moonshot uses Claude API case constant.APITypeSubmodel: return &submodel.Adaptor{} + case constant.APITypeMiniMax: + return &minimax.Adaptor{} } return nil }