fix(providers):add modelscope provider backend implementation

This commit is contained in:
KKparpar 2026-03-13 01:59:21 +08:00
parent 19835b2f60
commit 6cd71044a0
3 changed files with 11 additions and 1 deletions

View file

@ -51,6 +51,12 @@
"model": "openai/gpt-5.4",
"api_key": "sk-key2",
"api_base": "https://api2.example.com/v1"
},
{
"model_name": "MiniMax-M2.5",
"model": "modelscope/MiniMax/MiniMax-M2.5",
"api_key": "sk-key3",
"api_base": "https://api-inference.modelscope.cn/v1"
}
],
"channels": {

View file

@ -95,7 +95,7 @@ func CreateProviderFromConfig(cfg *config.ModelConfig) (LLMProvider, string, err
case "litellm", "openrouter", "groq", "zhipu", "gemini", "nvidia",
"ollama", "moonshot", "shengsuanyun", "deepseek", "cerebras",
"vivgrid", "volcengine", "vllm", "qwen", "mistral", "avian",
"minimax", "longcat":
"minimax", "longcat", "modelscope":
// All other OpenAI-compatible HTTP providers
if cfg.APIKey == "" && cfg.APIBase == "" {
return nil, "", fmt.Errorf("api_key or api_base is required for HTTP-based protocol %q", protocol)
@ -217,6 +217,8 @@ func getDefaultAPIBase(protocol string) string {
return "https://api.minimaxi.com/v1"
case "longcat":
return "https://api.longcat.chat/openai"
case "modelscope":
return "https://api.modelscope.cn/v1"
default:
return ""
}

View file

@ -464,6 +464,8 @@ func normalizeModel(model, apiBase string) string {
if strings.Contains(strings.ToLower(apiBase), "openrouter.ai") {
return model
} else if strings.Contains(strings.ToLower(apiBase), "api-inference.modelscope.cn") {
return model
}
prefix := strings.ToLower(before)