feat: add MiniMax as first-class LLM provider#727
Conversation
Add MiniMax AI as a third-party LLM provider alongside OpenAI and Azure OpenAI. MiniMax provides an OpenAI-compatible API, enabling integration via LangChain's ChatOpenAI with a custom base URL. Supported models: - MiniMax-M2.7 (flagship, 1M context) - MiniMax-M2.5 (204K context) - MiniMax-M2.5-highspeed (204K context, faster) Changes: - Add MINIMAX provider enum value - Add get_minimax_client() to clients module - Add _list_minimax_models() for auto-discovery when API key is set - Add MinimaxChatAdapter with temperature clamping [0,1] - Register adapter with registry pattern "^minimax*" - Update model-requirements docs with MiniMax setup instructions - Add 18 tests (11 unit + 3 integration + 4 provider tests) To enable: add MINIMAX_API_KEY to the Secrets Manager secret.
JiwaniZakir
left a comment
There was a problem hiding this comment.
The regex pattern r"^minimax*" in minimax_chat.py (registry line) has a subtle but critical bug: the * is a quantifier on the preceding character x (meaning "zero or more x's"), not a glob wildcard. This means the pattern matches strings like "minima", "minimax", "minimaxxx" — but more importantly, since the registered model IDs are "MiniMax-M2.7", "MiniMax-M2.5", etc. (capital M), a case-sensitive match against ^minimax will fail entirely and none of these models will ever be routed to MinimaxChatAdapter. The pattern should be r"^MiniMax" or r"(?i)^minimax" with re.IGNORECASE.
Additionally, get_minimax_client() in clients.py is added but never referenced anywhere in the visible diff — the adapter in minimax_chat.py reads os.environ.get("MINIMAX_API_KEY") directly rather than going through genai_core.parameters.get_external_api_key(). This inconsistency means the two code paths behave differently depending on how the key is stored, and the new client function appears to be dead code.
Finally, the _MINIMAX_MODELS list in provider.py includes a "description" field for each model, but the dict comprehension in _list_minimax_models() never includes "description" in the returned model dict — the field is defined and documented but silently dropped.
Change `r"^minimax*"` to `r"^minimax.*"` — the bare `*` was a quantifier on the preceding character `x` (zero or more x's), not a glob-style wildcard. With `.*` the pattern now correctly matches "minimax" followed by any characters (e.g. "minimax.MiniMax-M2.7").
|
Good catch @JiwaniZakir! Fixed the regex pattern from |
Summary
This PR adds MiniMax as a first-class third-party LLM provider, following the same adapter-registry pattern used by OpenAI and Azure OpenAI.
Supported models:
Key changes (11 files, 421 additions):
genai_core/types.py: AddMINIMAXto Provider enumgenai_core/clients.py: Addget_minimax_client()using OpenAI SDK with custom base URLgenai_core/model_providers/direct/provider.py: Add_list_minimax_models()for auto-discoveryadapters/minimax/minimax_chat.py:MinimaxChatAdapterextendingModelAdapterviaChatOpenAIwith OpenAI-compatible APIadapters/__init__.py: Register minimax adapter moduledocs/documentation/model-requirements.md: MiniMax setup documentationHow it works:
https://api.minimax.io/v1ChatOpenAIwith a customopenai_api_base[0, 1]per MiniMax API requirementsMINIMAX_API_KEYis added to Secrets ManagerTest plan
MinimaxChatAdapter(basic config, streaming, temperature clamping, max tokens, missing API key, all kwargs, model variants)_list_minimax_models()(with/without API key, model names, enum)To enable: Add
"MINIMAX_API_KEY": "your-key"to the Secrets Manager secret (same process as OpenAI/Cohere keys).