feat: add MiniMax Token Plan provider with hardcoded model list#7609
Merged
Soulter merged 6 commits intoAstrBotDevs:masterfrom Apr 17, 2026
Merged
Conversation
…strBotDevs#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: AstrBotDevs#7585
Contributor
There was a problem hiding this comment.
Hey - I've found 2 issues, and left some high level feedback:
- Since
api_baseis intentionally fixed in__init__, consider omitting it fromdefault_config_tmplor clearly treating it as read-only to avoid confusing users who might think they can override it. - Instead of mutating the incoming
provider_configdict in-place when settingapi_baseandauth_header, consider copying it first (e.g.,provider_config = {**provider_config, "api_base": ..., "auth_header": True}) to avoid unexpected side effects on shared configuration objects.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Since `api_base` is intentionally fixed in `__init__`, consider omitting it from `default_config_tmpl` or clearly treating it as read-only to avoid confusing users who might think they can override it.
- Instead of mutating the incoming `provider_config` dict in-place when setting `api_base` and `auth_header`, consider copying it first (e.g., `provider_config = {**provider_config, "api_base": ..., "auth_header": True}`) to avoid unexpected side effects on shared configuration objects.
## Individual Comments
### Comment 1
<location path="astrbot/core/provider/sources/minimax_token_plan_source.py" line_range="13-21" />
<code_context>
+@register_provider_adapter(
+ "minimax_token_plan",
+ "MiniMax Token Plan 提供商适配器",
+ default_config_tmpl={
+ "key": "",
+ "api_base": "https://api.minimaxi.com/anthropic",
+ },
+ provider_display_name="MiniMax Token Plan",
</code_context>
<issue_to_address>
**suggestion:** Configuration template exposes `api_base` even though it is always overridden.
Because `__init__` always overwrites `provider_config["api_base"]` with the MiniMax endpoint, exposing `api_base` here implies it’s user-configurable when it isn’t. Please either remove it from `default_config_tmpl` or mark it clearly as internal-only to avoid a misleading no-op config option.
```suggestion
@register_provider_adapter(
"minimax_token_plan",
"MiniMax Token Plan 提供商适配器",
default_config_tmpl={
"key": "",
},
provider_display_name="MiniMax Token Plan",
)
```
</issue_to_address>
### Comment 2
<location path="astrbot/core/provider/sources/minimax_token_plan_source.py" line_range="39-44" />
<code_context>
+ provider_settings,
+ )
+
+ self.set_model(provider_config.get("model", "MiniMax-M2.7"))
+
+ async def get_models(self) -> list[str]:
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Model selection is not validated against the known Token Plan model list.
Given `MINIMAX_TOKEN_PLAN_MODELS` is the source of truth for supported models, consider validating `provider_config["model"]` against this list before calling `set_model`. Either normalize to a supported value or raise a clear error for unsupported models to avoid confusing downstream failures and to keep behavior consistent with `get_models()`.
```suggestion
super().__init__(
provider_config,
provider_settings,
)
# Validate configured model against the supported Token Plan model list
configured_model = provider_config.get("model", "MiniMax-M2.7")
if configured_model not in MINIMAX_TOKEN_PLAN_MODELS:
raise ValueError(
f"Unsupported MiniMax Token Plan model: {configured_model!r}. "
f"Supported models: {', '.join(MINIMAX_TOKEN_PLAN_MODELS)}"
)
self.set_model(configured_model)
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
- 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.
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces the MiniMax Token Plan provider adapter, extending the Anthropic provider with a fixed API base and a hardcoded model list. A review comment points out that the auth_header configuration is likely ineffective and suggests using custom_headers to correctly provide the Authorization token.
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.
Soulter
approved these changes
Apr 17, 2026
2 tasks
Aster-amellus
pushed a commit
to Aster-amellus/AstrBot
that referenced
this pull request
Apr 18, 2026
…BotDevs#7609) * feat: add MiniMax Token Plan provider with hardcoded model list (fix AstrBotDevs#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: AstrBotDevs#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>
|
我是购买了 MiniMax Plus-极速版 的用户,当前硬编码的限制导致我无法配置 MiniMax-M2.7-highspeed 并抛出 ValueError。建议将白名单校验改为 Warning 警告,或者把 highspeed 模型加回列表,不要做强行阻断。 |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
本次 PR 解决 issue #7585 中反馈的 MiniMax Token Plan 用户无法正常使用 AstrBot 的问题。
调研发现:
/models接口,无法动态获取模型列表anthropic_chat_completionprovider 依赖/models接口,导致 Token Plan 用户无法获取模型列表解决方案
新增专门的
minimax_token_planprovider:ProviderAnthropic,复用所有聊天/补全/工具调用逻辑api_base写死为https://api.minimaxi.com/anthropiccustom_headers注入Authorization: Bearer <token>header(Token Plan 要求此认证方式)get_models()返回硬编码的模型列表,避免调用/models接口MiniMax-M2.7、MiniMax-M2.5、MiniMax-M2.1、MiniMax-M2ValueError模型列表来源:MiniMax 官方 Anthropic 兼容 API 文档
后续展望
如果 MiniMax 官方后续支持了
/models接口,只需将get_models()改为动态调用即可,无需修改其他逻辑。Summary
Add a new provider
minimax_token_planfor MiniMax Token Plan users, dedicated to MiniMax's Token Plan subscription API.Problem: When using MiniMax Token Plan API key with the existing
anthropic_chat_completionprovider, users cannot get model list because the Token Plan API does not expose a/modelsendpoint. See issue #7585.Solution:
minimax_token_planthat inherits fromProviderAnthropicapi_basehardcoded tohttps://api.minimaxi.com/anthropiccustom_headersto injectAuthorization: Bearer <token>header (required by Token Plan)get_models()returns hardcoded model list: MiniMax-M2.7, M2.5, M2.1, M2 (from official docs)Future: If MiniMax adds a
/modelsendpoint in the future, onlyget_models()needs to be updated.Closes #7585
Summary by Sourcery
Add a dedicated MiniMax Token Plan provider that reuses the Anthropic adapter while handling Token Plan–specific configuration and model discovery.
New Features:
minimax_token_planprovider adapter for MiniMax Token Plan subscriptions with a fixed API base and auth header requirements.Enhancements:
/modelsendpoint.