Skip to content

Commit 0ca6ba9

Browse files
BlueteemoSoulter
andauthored
feat: add MiniMax Token Plan provider with hardcoded model list (#7609)
* feat: add MiniMax Token Plan provider with hardcoded model list (fix #7585) - Add new provider 'minimax_token_plan' for MiniMax Token Plan users - Inherit ProviderAnthropic to reuse all chat/completion logic - Hardcode api_base to https://api.minimaxi.com/anthropic - get_models() returns hardcoded list: MiniMax-M2.7, M2.5, M2.1, M2 - Highspeed models excluded (require premium tier) - Reason for hardcoding: Token Plan API does not expose /models endpoint - Fixes: #7585 * fix: remove api_base from config template and add model validation - Remove api_base from default_config_tmpl (always overridden, misleading) - Add model validation against MINIMAX_TOKEN_PLAN_MODELS - Raise clear ValueError if user configures an unsupported model Addressed Sourcery AI review comments. * fix: use custom_headers for Bearer token auth instead of auth_header MiniMax Token Plan requires Authorization: Bearer <token> header. Use custom_headers to inject the correct auth header instead of the non-functional auth_header key. Addressed Gemini Code Assist review comment. * fix: update MiniMax Token Plan provider adapter and documentation to English * feat: add MiniMax Token Plan configuration and icon support * feat: remove default configuration template from MiniMax Token Plan provider adapter --------- Co-authored-by: Soulter <905617992@qq.com>
1 parent 5be6536 commit 0ca6ba9

4 files changed

Lines changed: 75 additions & 2 deletions

File tree

astrbot/core/config/default.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,7 @@ class ChatProviderTemplate(TypedDict):
12061206
"provider_type": "chat_completion",
12071207
"enable": True,
12081208
"key": [],
1209-
"api_base": "https://api.kimi.com/coding/",
1209+
"api_base": "https://api.kimi.com/coding",
12101210
"timeout": 120,
12111211
"proxy": "",
12121212
"custom_headers": {"User-Agent": "claude-code/0.1.0"},
@@ -1236,6 +1236,19 @@ class ChatProviderTemplate(TypedDict):
12361236
"proxy": "",
12371237
"custom_headers": {},
12381238
},
1239+
"MiniMax Token Plan": {
1240+
"id": "minimax-token-plan",
1241+
"provider": "minimax-token-plan",
1242+
"type": "minimax_token_plan",
1243+
"provider_type": "chat_completion",
1244+
"enable": True,
1245+
"key": [],
1246+
"api_base": "https://api.minimaxi.com/anthropic",
1247+
"timeout": 120,
1248+
"proxy": "",
1249+
"custom_headers": {"User-Agent": "claude-code/0.1.0"},
1250+
"anth_thinking_config": {"type": "", "budget": 0, "effort": ""},
1251+
},
12391252
"xAI": {
12401253
"id": "xai",
12411254
"provider": "xai",

astrbot/core/provider/manager.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,10 @@ def dynamic_import_provider(self, type: str) -> None:
363363
)
364364
case "longcat_chat_completion":
365365
from .sources.longcat_source import ProviderLongCat as ProviderLongCat
366+
case "minimax_token_plan":
367+
from .sources.minimax_token_plan_source import (
368+
ProviderMiniMaxTokenPlan as ProviderMiniMaxTokenPlan,
369+
)
366370
case "zhipu_chat_completion":
367371
from .sources.zhipu_source import ProviderZhipu as ProviderZhipu
368372
case "groq_chat_completion":
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
from astrbot.core.provider.sources.anthropic_source import ProviderAnthropic
2+
3+
from ..register import register_provider_adapter
4+
5+
MINIMAX_TOKEN_PLAN_MODELS = [
6+
"MiniMax-M2.7",
7+
"MiniMax-M2.5",
8+
"MiniMax-M2.1",
9+
"MiniMax-M2",
10+
]
11+
12+
13+
@register_provider_adapter(
14+
"minimax_token_plan",
15+
"MiniMax Token Plan Provider Adapter",
16+
)
17+
class ProviderMiniMaxTokenPlan(ProviderAnthropic):
18+
"""MiniMax Token Plan provider.
19+
20+
The Token Plan API does not support the /models endpoint, so get_models()
21+
returns a hard-coded model list. This is a Token Plan API limitation.
22+
See https://github.com/AstrBotDevs/AstrBot/issues/7585 for details.
23+
"""
24+
25+
def __init__(
26+
self,
27+
provider_config,
28+
provider_settings,
29+
) -> None:
30+
# Keep api_base fixed; Token Plan users do not need to configure it.
31+
provider_config["api_base"] = "https://api.minimaxi.com/anthropic"
32+
# MiniMax Token Plan requires the Authorization: Bearer <token> header.
33+
key = provider_config.get("key", "")
34+
actual_key = key[0] if isinstance(key, list) else key
35+
provider_config.setdefault("custom_headers", {})["Authorization"] = (
36+
f"Bearer {actual_key}"
37+
)
38+
39+
super().__init__(
40+
provider_config,
41+
provider_settings,
42+
)
43+
44+
configured_model = provider_config.get("model", "MiniMax-M2.7")
45+
if configured_model not in MINIMAX_TOKEN_PLAN_MODELS:
46+
raise ValueError(
47+
f"Unsupported model: {configured_model!r}. "
48+
f"Supported models: {', '.join(MINIMAX_TOKEN_PLAN_MODELS)}"
49+
)
50+
51+
self.set_model(configured_model)
52+
53+
async def get_models(self) -> list[str]:
54+
"""Return the hard-coded known model list because Token Plan cannot fetch it dynamically."""
55+
return MINIMAX_TOKEN_PLAN_MODELS.copy()

dashboard/src/utils/providerUtils.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export function getProviderIcon(type) {
2323
'moonshot': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/kimi.svg',
2424
'kimi': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/kimi.svg',
2525
'kimi-code': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/kimi.svg',
26-
'kimi-code': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/longcat-color.svg',
26+
'longcat': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/longcat-color.svg',
2727
'ppio': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/ppio.svg',
2828
'dify': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/dify-color.svg',
2929
"coze": "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@1.66.0/icons/coze.svg",
@@ -33,6 +33,7 @@ export function getProviderIcon(type) {
3333
'lm_studio': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/lmstudio.svg',
3434
'fishaudio': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/fishaudio.svg',
3535
'minimax': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/minimax.svg',
36+
'minimax-token-plan': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/minimax.svg',
3637
'mimo': 'https://platform.xiaomimimo.com/favicon.874c9507.png',
3738
'302ai': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@1.53.0/icons/ai302-color.svg',
3839
'microsoft': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/microsoft.svg',

0 commit comments

Comments
 (0)