-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat(text_tasks): add MiniMax to external LM provider registry #1279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,6 +53,36 @@ class ExternalProviderProfile: | |
| ("OpenAI chat completions", "https://api.openai.com/v1/chat/completions"), | ||
| ), | ||
| ), | ||
| "minimax": ExternalProviderProfile( | ||
| provider_id="minimax", | ||
| label="MiniMax", | ||
| protocol="openai_chat", | ||
| default_model="MiniMax-M3", | ||
| default_base_url="https://api.minimax.io/v1/chat/completions", | ||
| api_key_env="ACESTEP_MINIMAX_API_KEY", | ||
| api_key_required=True, | ||
| secret_path_env="ACESTEP_MINIMAX_SECRET_PATH", | ||
| secret_file_name="minimax_api_key.enc", | ||
| base_url_presets=( | ||
| ("Global chat completions", "https://api.minimax.io/v1/chat/completions"), | ||
| ("Mainland China chat completions", "https://api.minimaxi.com/v1/chat/completions"), | ||
| ), | ||
| ), | ||
| "minimax_anthropic": ExternalProviderProfile( | ||
| provider_id="minimax_anthropic", | ||
| label="MiniMax (Anthropic API)", | ||
| protocol="anthropic_messages", | ||
| default_model="MiniMax-M3", | ||
| default_base_url="https://api.minimax.io/anthropic/v1/messages", | ||
| api_key_env="ACESTEP_MINIMAX_API_KEY", | ||
| api_key_required=True, | ||
| secret_path_env="ACESTEP_MINIMAX_SECRET_PATH", | ||
| secret_file_name="minimax_api_key.enc", | ||
| base_url_presets=( | ||
| ("Global Anthropic messages", "https://api.minimax.io/anthropic/v1/messages"), | ||
| ("Mainland China Anthropic messages", "https://api.minimaxi.com/anthropic/v1/messages"), | ||
| ), | ||
| ), | ||
|
Comment on lines
+71
to
+85
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== locate files =="
git ls-files | rg 'acestep/text_tasks/(external_lm_providers|external_ai_request_helpers)\.py$|external_lm_providers\.py|external_ai_request_helpers\.py' || true
echo "== file line counts =="
wc -l acestep/text_tasks/external_lm_providers.py acestep/text_tasks/external_ai_request_helpers.py
echo "== relevant provider lines =="
sed -n '1,130p' acestep/text_tasks/external_lm_providers.py
echo "== relevant helper lines =="
sed -n '1,220p' acestep/text_tasks/external_ai_request_helpers.py
echo "== search provider/auth references =="
rg -n "minimax_anthropic|anthropic_messages|x-api-key|Authorization: Bearer|ACESTEP_MINIMAX_MINIMAX|secret_path_env|ExternalProviderProfile" acestep/text_tasks acestep || trueRepository: ace-step/ACE-Step-1.5 Length of output: 20967 🌐 Web query:
💡 Result: To authenticate with the MiniMax API—including its Anthropic-compatible endpoints—you must use the HTTP Authorization header with the Bearer authentication scheme [1][2][3]. The correct header format is: Authorization: Bearer YOUR_API_KEY While some services and SDKs (such as those designed for Anthropic's native API) default to the x-api-key header, MiniMax endpoints explicitly require the Authorization header [4][5][6]. Using x-api-key may result in authentication errors (such as HTTP 401 or system error 1033) even when accessing Anthropic-compatible routes [4][5][6]. If both headers are provided, the Authorization header takes precedence [3]. Key implementation details: - Base URL: For Anthropic-compatible requests, the base URL is typically https://api.minimax.io/anthropic/v1 [4][7]. - Header requirement: Always use Authorization: Bearer <API_KEY> [8][3][5]. Ensure there is a single space between the word Bearer and your API key [7][9]. - Account Keys: Ensure you are using the correct key (Pay-as-you-go API key or Subscription Key) as obtained from your MiniMax account management portal [7][10][11]. These keys are not always interchangeable depending on the billing model [11]. Citations:
🌐 Web query:
💡 Result: The x-api-key header is a commonly used custom HTTP header for transmitting API keys, but it is not a formal or IANA-registered standard. While many web services implement it as a mechanism for authentication or authorization, it is considered a non-standard practice. In contrast, the official HTTP Authorization header is the standard mechanism for providing authentication credentials, typically using schemes like Bearer or Basic. Using the Authorization header with a custom scheme or standard token format is generally preferred for interoperability and adherence to HTTP specifications over custom headers like x-api-key. Developers often choose x-api-key for its simplicity in implementation or to bypass specific intermediary requirements, but it lacks the universal support and security semantics defined for the Authorization header. Citations: Use MiniMax’s documented
🧰 Tools🪛 Ruff (0.16.0)[error] 79-79: Possible hardcoded password assigned to argument: "secret_path_env" (S106) [error] 80-80: Possible hardcoded password assigned to argument: "secret_file_name" (S106) 🤖 Prompt for AI AgentsSource: MCP tools |
||
| "claude": ExternalProviderProfile( | ||
| provider_id="claude", | ||
| label="Anthropic Claude", | ||
|
|
@@ -101,7 +131,7 @@ def get_external_provider_profile(provider: str | None) -> ExternalProviderProfi | |
| def get_external_provider_choices() -> list[tuple[str, str]]: | ||
| """Return provider dropdown choices as ``(label, value)`` pairs.""" | ||
|
|
||
| order = ("zai", "openai", "claude", "ollama") | ||
| order = ("zai", "openai", "minimax", "minimax_anthropic", "claude", "ollama") | ||
| return [ | ||
| (_EXTERNAL_PROVIDER_PROFILES[provider_id].label, provider_id) | ||
| for provider_id in order | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: ace-step/ACE-Step-1.5
Length of output: 50379
🌐 Web query:
MiniMax text-chat OpenAI thinking field disabled adaptive thinking response_format json_object documentation💡 Result:
To control MiniMax model thinking and output formatting via the OpenAI-compatible Chat Completions API, use the following guidelines based on official documentation: Thinking Control For models that support it (e.g., MiniMax-M3), you can control the generation of thinking content by passing a thinking parameter within the extra_body of your API request [1][2]. - To disable thinking: Set extra_body={"thinking": {"type": "disabled"}} [1][3]. Note that for M2.x models, thinking cannot be disabled; the parameter may be accepted, but thinking will remain active [1][2][3]. - To enable thinking: Set extra_body={"thinking": {"type": "adaptive"}} [1][2]. This is generally the default behavior for M3 on the OpenAI-compatible route [3]. When handling interleaved thinking, you can use the extra_body parameter "reasoning_split": True to receive thinking content in a separate reasoning_details field rather than embedded in the content field [4][5][6]. If reasoning_split is false or omitted, the thinking content is wrapped in tags within the standard content field [4][5]. Response Format (JSON) Support for the response_format parameter, including {"type": "json_object"}, varies by model and endpoint [7][8][9]. While some documentation or third-party implementations suggest support for structured output via JSON mode [9][10], the native API specification notes that certain models (such as MiniMax-Text-01) have specific support for response_format [7]. For many standard MiniMax models (like M2.5) on the OpenAI-compatible endpoint, response_format may be ignored or limited, necessitating alternative methods for ensuring structured output [7]. Always verify specific model capabilities in the official MiniMax platform documentation for the most current information [11][1].
Citations:
response_formatsupport for MiniMax M2.5 via OpenAI-compatible API MiniMax-AI/MiniMax-M2.5#4🌐 Web query:
site:platform.minimax.io/docs/guides/text-openai-api MiniMax-M3 response_format json_object thinking disabled💡 Result:
MiniMax’s OpenAI-compatible text API supports the M2.x reasoning models (
MiniMax-M2.7,MiniMax-M2.5,MiniMax-M2.1,MiniMax-M2) andreasoning_split=Trueto separate thinking intoreasoning_details. The docs also sayresponse_formatis only supported byMiniMax-Text-01, soresponse_format: {"type":"json_object"}is not documented for MiniMax-M2.x. I also found no documentedthinking=disabledoption for the OpenAI-compatible M2.x endpoint. (platform.minimax.io)If you need JSON output with M2.x, the docs suggest using prompt instructions (e.g. “Return a JSON array only”) rather than
response_format. (platform.minimax.io)Citations:
🌐 Web query:
site:platform.minimax.io "MiniMax-M3" "thinking" "adaptive" "disabled"💡 Result:
For the MiniMax-M3 model, the thinking (or reasoning) capability can be controlled via the API to be enabled or disabled. Documentation from different integration paths (OpenAI SDK vs. Anthropic SDK) provides slightly different phrasing regarding defaults and parameter names, but the underlying functionality is consistent [1][2]. Thinking/Reasoning Control for MiniMax-M3: - To disable thinking: Set the parameter
thinking: {"type": "disabled"}in theextra_body(for OpenAI SDK) [1] or thethinkingfield (for Anthropic SDK) [2]. When disabled, the model skips thinking and provides a direct response [1][2]. - To enable thinking: Setthinking: {"type": "adaptive"}[1][2]. - Defaults: Depending on the specific API documentation page, the default behavior for MiniMax-M3 is stated as either "on by default" [1] or "off by default" [2]. Given this, it is recommended to explicitly set thethinkingparameter to your desired state to ensure consistent behavior [1][2]. - Alternative Reasoning Parameter: In some contexts, particularly the Responses API, the capability is controlled via areasoningfield [3]. Settingreasoning: {"effort": "none"}disables reasoning output [3]. Values such asminimal,low,medium, orhighenable it [3]. Important Considerations: - M2.x models: Thinking cannot be disabled for M2.x models; even ifthinking: {"type": "disabled"}is passed, thinking remains active [1][2][3]. - Message History: When using Interleaved Thinking, it is critical to preserve the entire response message—includingreasoning_contentorreasoning_details—in the message history for subsequent turns to ensure the model maintains optimal performance [4]. For developers, it is highly recommended to review the specific API documentation relevant to your SDK (e.g., OpenAI vs. Anthropic vs. Responses API) as parameter keys can vary slightly between these implementations [1][2][3].Citations:
🌐 Web query:
site:platform.minimax.io docs/api-reference/text-chat-openai "extra_body" "thinking" "MiniMax-M3"💡 Result:
When using the MiniMax-M3 model via the OpenAI-compatible Chat Completions API, you can control the model's thinking behavior and output format using the extra_body parameter in your API request [1][2]. Thinking Control The thinking parameter within extra_body allows you to manage whether the model emits thinking content [1]: - {"type": "adaptive"}: Explicitly enables thinking (the default behavior for MiniMax-M3 if the parameter is omitted) [1][3]. - {"type": "disabled"}: Disables thinking content, causing the model to answer directly [1][3]. Output Formatting (reasoning_split) You can use the reasoning_split parameter within extra_body to determine how thinking content is returned [1][4]: - reasoning_split=True: Separates thinking content into distinct fields (reasoning_content and reasoning_details) [1][4]. This is the recommended "Interleaved Thinking" compatible format, which provides a more developer-friendly output [4][5]. - reasoning_split=False: Embeds the model's thinking within the content field, enclosed in tags [4][5]. This format requires manual parsing if you wish to separate the reasoning from the final answer [4]. Important Usage Note If you are implementing multi-turn conversations, it is essential that you preserve the entire response object (including reasoning content or details) and pass it back in the message history for subsequent turns [4][5]. Modifying or removing the thinking content from the history can negatively impact the model's performance and chain-of-thought capabilities [4][5]. Example Usage python client.chat.completions.create( model="MiniMax-M3", messages=[{"role": "user", "content": "Hi, how are you?"}], extra_body={ "thinking": {"type": "adaptive"}, "reasoning_split": True, },)
Citations:
🏁 Script executed:
Repository: ace-step/ACE-Step-1.5
Length of output: 3354
Disable MiniMax M3 thinking for format JSON requests.
For
MiniMax-M3, omittingthinkingon the MiniMax endpoint enables adaptive thinking by default. Whenrequire_json_output=Truefor MiniMax, emitthinking: {"type": "disabled"and assert that payload in the MiniMax test as well, not field absence.📍 Affects 2 files
acestep/text_tasks/external_ai_request_helpers.py#L137-L139(this comment)acestep/text_tasks/external_ai_request_helpers_test.py#L130-L146🤖 Prompt for AI Agents
Source: MCP tools