diff --git a/astrbot/core/config/default.py b/astrbot/core/config/default.py index 0237b176d1..527cfbf9be 100644 --- a/astrbot/core/config/default.py +++ b/astrbot/core/config/default.py @@ -1206,7 +1206,7 @@ class ChatProviderTemplate(TypedDict): "provider_type": "chat_completion", "enable": True, "key": [], - "api_base": "https://api.kimi.com/coding/", + "api_base": "https://api.kimi.com/coding", "timeout": 120, "proxy": "", "custom_headers": {"User-Agent": "claude-code/0.1.0"}, @@ -1236,6 +1236,19 @@ class ChatProviderTemplate(TypedDict): "proxy": "", "custom_headers": {}, }, + "MiniMax Token Plan": { + "id": "minimax-token-plan", + "provider": "minimax-token-plan", + "type": "minimax_token_plan", + "provider_type": "chat_completion", + "enable": True, + "key": [], + "api_base": "https://api.minimaxi.com/anthropic", + "timeout": 120, + "proxy": "", + "custom_headers": {"User-Agent": "claude-code/0.1.0"}, + "anth_thinking_config": {"type": "", "budget": 0, "effort": ""}, + }, "xAI": { "id": "xai", "provider": "xai", diff --git a/astrbot/core/provider/manager.py b/astrbot/core/provider/manager.py index b4ff2742d0..0dfdbdcf6d 100644 --- a/astrbot/core/provider/manager.py +++ b/astrbot/core/provider/manager.py @@ -363,6 +363,10 @@ def dynamic_import_provider(self, type: str) -> None: ) case "longcat_chat_completion": from .sources.longcat_source import ProviderLongCat as ProviderLongCat + case "minimax_token_plan": + from .sources.minimax_token_plan_source import ( + ProviderMiniMaxTokenPlan as ProviderMiniMaxTokenPlan, + ) case "zhipu_chat_completion": from .sources.zhipu_source import ProviderZhipu as ProviderZhipu case "groq_chat_completion": diff --git a/astrbot/core/provider/sources/minimax_token_plan_source.py b/astrbot/core/provider/sources/minimax_token_plan_source.py new file mode 100644 index 0000000000..5a578424f9 --- /dev/null +++ b/astrbot/core/provider/sources/minimax_token_plan_source.py @@ -0,0 +1,55 @@ +from astrbot.core.provider.sources.anthropic_source import ProviderAnthropic + +from ..register import register_provider_adapter + +MINIMAX_TOKEN_PLAN_MODELS = [ + "MiniMax-M2.7", + "MiniMax-M2.5", + "MiniMax-M2.1", + "MiniMax-M2", +] + + +@register_provider_adapter( + "minimax_token_plan", + "MiniMax Token Plan Provider Adapter", +) +class ProviderMiniMaxTokenPlan(ProviderAnthropic): + """MiniMax Token Plan provider. + + The Token Plan API does not support the /models endpoint, so get_models() + returns a hard-coded model list. This is a Token Plan API limitation. + See https://github.com/AstrBotDevs/AstrBot/issues/7585 for details. + """ + + def __init__( + self, + provider_config, + provider_settings, + ) -> None: + # Keep api_base fixed; Token Plan users do not need to configure it. + provider_config["api_base"] = "https://api.minimaxi.com/anthropic" + # MiniMax Token Plan requires the Authorization: Bearer header. + key = provider_config.get("key", "") + actual_key = key[0] if isinstance(key, list) else key + provider_config.setdefault("custom_headers", {})["Authorization"] = ( + f"Bearer {actual_key}" + ) + + super().__init__( + provider_config, + provider_settings, + ) + + configured_model = provider_config.get("model", "MiniMax-M2.7") + if configured_model not in MINIMAX_TOKEN_PLAN_MODELS: + raise ValueError( + f"Unsupported model: {configured_model!r}. " + f"Supported models: {', '.join(MINIMAX_TOKEN_PLAN_MODELS)}" + ) + + self.set_model(configured_model) + + async def get_models(self) -> list[str]: + """Return the hard-coded known model list because Token Plan cannot fetch it dynamically.""" + return MINIMAX_TOKEN_PLAN_MODELS.copy() diff --git a/dashboard/src/utils/providerUtils.js b/dashboard/src/utils/providerUtils.js index b116fd73d7..dbf09b83a3 100644 --- a/dashboard/src/utils/providerUtils.js +++ b/dashboard/src/utils/providerUtils.js @@ -23,7 +23,7 @@ export function getProviderIcon(type) { 'moonshot': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/kimi.svg', 'kimi': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/kimi.svg', 'kimi-code': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/kimi.svg', - 'kimi-code': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/longcat-color.svg', + 'longcat': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/longcat-color.svg', 'ppio': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/ppio.svg', 'dify': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/dify-color.svg', "coze": "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@1.66.0/icons/coze.svg", @@ -33,6 +33,7 @@ export function getProviderIcon(type) { 'lm_studio': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/lmstudio.svg', 'fishaudio': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/fishaudio.svg', 'minimax': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/minimax.svg', + 'minimax-token-plan': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/minimax.svg', 'mimo': 'https://platform.xiaomimimo.com/favicon.874c9507.png', '302ai': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@1.53.0/icons/ai302-color.svg', 'microsoft': 'https://cdn.jsdelivr.net/npm/@lobehub/icons-static-svg@latest/icons/microsoft.svg',