2024-05-16 19:03:42 +08:00
|
|
|
package minimax
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
2025-10-11 15:30:09 +08:00
|
|
|
|
2025-10-20 13:54:53 +08:00
|
|
|
channelconstant "github.com/QuantumNous/new-api/constant"
|
2025-10-11 15:30:09 +08:00
|
|
|
relaycommon "github.com/QuantumNous/new-api/relay/common"
|
2025-10-20 13:54:53 +08:00
|
|
|
"github.com/QuantumNous/new-api/relay/constant"
|
2026-02-17 17:27:57 +08:00
|
|
|
"github.com/QuantumNous/new-api/types"
|
2024-05-16 19:03:42 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
|
2025-10-20 13:54:53 +08:00
|
|
|
baseUrl := info.ChannelBaseUrl
|
|
|
|
|
if baseUrl == "" {
|
|
|
|
|
baseUrl = channelconstant.ChannelBaseURLs[channelconstant.ChannelTypeMiniMax]
|
|
|
|
|
}
|
2026-02-17 17:27:57 +08:00
|
|
|
switch info.RelayFormat {
|
|
|
|
|
case types.RelayFormatClaude:
|
|
|
|
|
return fmt.Sprintf("%s/anthropic/v1/messages", info.ChannelBaseUrl), nil
|
2025-10-20 13:54:53 +08:00
|
|
|
default:
|
2026-02-17 17:27:57 +08:00
|
|
|
switch info.RelayMode {
|
|
|
|
|
case constant.RelayModeChatCompletions:
|
|
|
|
|
return fmt.Sprintf("%s/v1/text/chatcompletion_v2", baseUrl), nil
|
2026-04-08 16:57:44 +08:00
|
|
|
case constant.RelayModeImagesGenerations:
|
|
|
|
|
return fmt.Sprintf("%s/v1/image_generation", baseUrl), nil
|
2026-02-17 17:27:57 +08:00
|
|
|
case constant.RelayModeAudioSpeech:
|
|
|
|
|
return fmt.Sprintf("%s/v1/t2a_v2", baseUrl), nil
|
|
|
|
|
default:
|
|
|
|
|
return "", fmt.Errorf("unsupported relay mode: %d", info.RelayMode)
|
|
|
|
|
}
|
2025-10-20 13:54:53 +08:00
|
|
|
}
|
2024-05-16 19:03:42 +08:00
|
|
|
}
|