feat: add MiniMax as native AI provider#414
feat: add MiniMax as native AI provider#414regardtvdvyver wants to merge 3 commits intoBeehiveInnovations:mainfrom
Conversation
Add MiniMax (M2.5, M2.5-highspeed, M2.1, M2.1-highspeed, M2) as a registry-backed OpenAI-compatible provider. Follows the same pattern as the X.AI provider with JSON model config, registry loader, and full alias support.
- Add MiniMax to listmodels provider display - Add MiniMax to startup model restriction validation - Fix test env isolation for MINIMAX_API_KEY leakage
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces MiniMax as a new native AI provider, expanding the platform's capabilities to support additional large language models. The changes involve adding specific MiniMax model definitions and integrating them into the existing provider architecture, allowing users to configure and utilize MiniMax models for various AI tasks. This enhancement broadens the range of available AI services without disrupting current functionalities. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request effectively adds MiniMax as a native AI provider, following the established patterns in the codebase. The changes include a new model registry, provider implementation, and necessary updates to server configuration and tests. My review includes a couple of suggestions to refactor small parts of the new code to improve clarity and reduce duplication. Overall, this is a well-executed feature addition.
| def get_preferred_model(self, category: "ToolModelCategory", allowed_models: list[str]) -> Optional[str]: | ||
| """Get MiniMax's preferred model for a given category from allowed models. | ||
|
|
||
| Args: | ||
| category: The tool category requiring a model | ||
| allowed_models: Pre-filtered list of models allowed by restrictions | ||
|
|
||
| Returns: | ||
| Preferred model name or None | ||
| """ | ||
| from tools.models import ToolModelCategory | ||
|
|
||
| if not allowed_models: | ||
| return None | ||
|
|
||
| if category == ToolModelCategory.EXTENDED_REASONING: | ||
| # Prefer M2.5 for advanced reasoning tasks | ||
| if self.PRIMARY_MODEL in allowed_models: | ||
| return self.PRIMARY_MODEL | ||
| if self.FAST_MODEL in allowed_models: | ||
| return self.FAST_MODEL | ||
| return allowed_models[0] | ||
|
|
||
| elif category == ToolModelCategory.FAST_RESPONSE: | ||
| # Prefer M2.5-highspeed for speed | ||
| if self.FAST_MODEL in allowed_models: | ||
| return self.FAST_MODEL | ||
| if self.PRIMARY_MODEL in allowed_models: | ||
| return self.PRIMARY_MODEL | ||
| return allowed_models[0] | ||
|
|
||
| else: # BALANCED or default | ||
| # Prefer M2.5 for balanced use | ||
| if self.PRIMARY_MODEL in allowed_models: | ||
| return self.PRIMARY_MODEL | ||
| if self.FAST_MODEL in allowed_models: | ||
| return self.FAST_MODEL | ||
| return allowed_models[0] |
There was a problem hiding this comment.
The logic for selecting a preferred model is a bit repetitive across the different categories. The EXTENDED_REASONING and BALANCED categories have identical logic, and the FAST_RESPONSE category just swaps the preference order. You can simplify this by defining the preference order in a list and then iterating through it to make the code more concise and maintainable.
def get_preferred_model(self, category: "ToolModelCategory", allowed_models: list[str]) -> Optional[str]:
"""Get MiniMax's preferred model for a given category from allowed models.
Args:
category: The tool category requiring a model
allowed_models: Pre-filtered list of models allowed by restrictions
Returns:
Preferred model name or None
"""
from tools.models import ToolModelCategory
if not allowed_models:
return None
if category == ToolModelCategory.FAST_RESPONSE:
preference_order = [self.FAST_MODEL, self.PRIMARY_MODEL]
else: # BALANCED, EXTENDED_REASONING, or default
preference_order = [self.PRIMARY_MODEL, self.FAST_MODEL]
for model in preference_order:
if model in allowed_models:
return model
return allowed_models[0]| minimax_key = get_env("MINIMAX_API_KEY") | ||
| if minimax_key and minimax_key != "your_minimax_api_key_here": | ||
| valid_providers.append("MiniMax") | ||
| has_native_apis = True | ||
| logger.info("MiniMax API key found - MiniMax models available") |
There was a problem hiding this comment.
The condition minimax_key and minimax_key != "your_minimax_api_key_here" is used here and again later when registering the provider. To improve readability and avoid repetition, you could store the result of this check in a boolean variable (e.g., is_minimax_configured) and reuse it in both places.
| minimax_key = get_env("MINIMAX_API_KEY") | |
| if minimax_key and minimax_key != "your_minimax_api_key_here": | |
| valid_providers.append("MiniMax") | |
| has_native_apis = True | |
| logger.info("MiniMax API key found - MiniMax models available") | |
| minimax_key = get_env("MINIMAX_API_KEY") | |
| is_minimax_configured = minimax_key and minimax_key != "your_minimax_api_key_here" | |
| if is_minimax_configured: | |
| valid_providers.append("MiniMax") | |
| has_native_apis = True | |
| logger.info("MiniMax API key found - MiniMax models available") |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 16f258c26a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| ProviderType.OPENAI, # Direct OpenAI access | ||
| ProviderType.AZURE, # Azure-hosted OpenAI deployments | ||
| ProviderType.XAI, # Direct X.AI GROK access | ||
| ProviderType.MINIMAX, # Direct MiniMax access |
There was a problem hiding this comment.
Apply MiniMax allowlist before fallback model selection
By adding ProviderType.MINIMAX to PROVIDER_PRIORITY_ORDER, auto-mode can now prefer MiniMax models in get_preferred_fallback_model, but MINIMAX_ALLOWED_MODELS is not wired into ModelRestrictionService.ENV_VARS (utils/model_restrictions.py), so registry-level filtering still treats all MiniMax models as allowed. In deployments that restrict MiniMax to a subset (for example only m2), the registry can still select MiniMax-M2.5, and the request then fails later when provider-level checks reject that model, instead of selecting an actually allowed model up front.
Useful? React with 👍 / 👎.
Summary
Adds MiniMax as a native AI provider following the established X.AI provider pattern. MiniMax offers an OpenAI-compatible API at
https://api.minimax.io/v1with 5 models:All models support streaming, function calling, and system prompts. No vision support.
Changes
New files:
conf/minimax_models.json— Model registry with 5 models and 13 aliasesproviders/registries/minimax.py— MiniMaxModelRegistryproviders/minimax.py— MiniMaxModelProviderModified files:
providers/shared/provider_type.py— Added MINIMAX enumproviders/registry.py— Key mapping + priority orderserver.py— Registration, key check, startup validationproviders/__init__.py— Exportproviders/registries/__init__.py— Exporttools/listmodels.py— Display in model listing.env.example— Configuration docs and examplestests/test_auto_mode_model_listing.py— Test env isolationTest plan
./code_quality_checks.sh— 890 passed, 0 failedlistmodelsMCP tool shows MiniMax models and aliases