feat(llm): add MiniMax provider with global/China regional endpoints - #196
feat(llm): add MiniMax provider with global/China regional endpoints#196octo-patch wants to merge 1 commit into
Conversation
MiniMax exposes an OpenAI-compatible chat-completions API, so it reuses the existing OpenAI-shaped request conversion, tool handling, and response parsing. The provider is reachable through two regional endpoints selected at runtime: global_en (api.minimax.io, default) and cn_zh (api.minimaxi.com). Default model is MiniMax-M3, with MiniMax-M2.7 as an alternative. Region is configurable via mimi_secrets.h and the new set_minimax_region CLI command, persisted to NVS. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughMiniMax is added as a region-aware OpenAI-compatible LLM provider. Configuration supports build-time and NVS region overrides, runtime CLI updates, compatible request handling, and setup documentation in English, Chinese, and Japanese. ChangesMiniMax Provider Integration
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Operator
participant SerialCLI
participant LLMProxy
participant NVS
participant MiniMaxAPI
Operator->>SerialCLI: set_minimax_region(region)
SerialCLI->>LLMProxy: llm_set_minimax_region(region)
LLMProxy->>NVS: Save region
LLMProxy->>LLMProxy: Update runtime region
LLMProxy->>MiniMaxAPI: Send OpenAI-compatible request to regional endpoint
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@main/llm/llm_proxy.c`:
- Around line 22-25: Update the default model initialization in the LLM
configuration state around s_model and s_provider so selecting the MiniMax
provider without an explicit MIMI_SECRET_MODEL uses MIMI_MINIMAX_DEFAULT_MODEL
instead of MIMI_LLM_DEFAULT_MODEL, while preserving the existing default for
other providers and explicit model overrides.
In `@README.md`:
- Around line 172-175: Update the set_api_key comments to list MiniMax alongside
Anthropic and OpenAI in README.md lines 172-175, README_CN.md lines 187-190, and
README_JA.md lines 172-175; keep the existing language and examples unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 19f136be-3f08-4935-b9b0-dfe3609d931d
📒 Files selected for processing (8)
README.mdREADME_CN.mdREADME_JA.mdmain/cli/serial_cli.cmain/llm/llm_proxy.cmain/llm/llm_proxy.hmain/mimi_config.hmain/mimi_secrets.h.example
| static char s_api_key[LLM_API_KEY_MAX_LEN] = {0}; | ||
| static char s_model[LLM_MODEL_MAX_LEN] = MIMI_LLM_DEFAULT_MODEL; | ||
| static char s_provider[16] = MIMI_LLM_PROVIDER_DEFAULT; | ||
| static char s_minimax_region[LLM_REGION_MAX_LEN] = MIMI_MINIMAX_REGION_DEFAULT; |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Initialize MiniMax with its actual default model.
With an empty MIMI_SECRET_MODEL, Line 23 keeps claude-opus-4-5; selecting minimax then sends that Anthropic model ID to MiniMax. Select MIMI_MINIMAX_DEFAULT_MODEL when MiniMax is configured and no explicit model override exists.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@main/llm/llm_proxy.c` around lines 22 - 25, Update the default model
initialization in the LLM configuration state around s_model and s_provider so
selecting the MiniMax provider without an explicit MIMI_SECRET_MODEL uses
MIMI_MINIMAX_DEFAULT_MODEL instead of MIMI_LLM_DEFAULT_MODEL, while preserving
the existing default for other providers and explicit model overrides.
| mimi> set_model_provider openai # switch provider (anthropic|openai|minimax) | ||
| mimi> set_model gpt-4o # change LLM model | ||
| mimi> set_model MiniMax-M3 # MiniMax default (also: MiniMax-M2.7) | ||
| mimi> set_minimax_region cn_zh # MiniMax region (global_en|cn_zh) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Include MiniMax in the set_api_key examples.
The immediately preceding API-key comments still say Anthropic/OpenAI only, although MiniMax now uses the same command.
README.md#L172-L175: change theset_api_keycomment to include MiniMax.README_CN.md#L187-L190: update the Chineseset_api_keycomment to include MiniMax.README_JA.md#L172-L175: update the Japaneseset_api_keycomment to include MiniMax.
📍 Affects 3 files
README.md#L172-L175(this comment)README_CN.md#L187-L190README_JA.md#L172-L175
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@README.md` around lines 172 - 175, Update the set_api_key comments to list
MiniMax alongside Anthropic and OpenAI in README.md lines 172-175, README_CN.md
lines 187-190, and README_JA.md lines 172-175; keep the existing language and
examples unchanged.
Reason: The firmware's LLM transport supported only Anthropic and OpenAI, with no MiniMax provider or China/global regional endpoint selection.
What this adds
Adds MiniMax as a first-class LLM provider. MiniMax exposes an OpenAI-compatible chat-completions API, so it reuses the existing OpenAI-shaped request conversion, tool-call handling, and response parsing. The provider is reachable through two regional endpoints selected at runtime:
global_en->https://api.minimax.io/v1/chat/completions(default)cn_zh->https://api.minimaxi.com/v1/chat/completionsThe default model is
MiniMax-M3, withMiniMax-M2.7available as an alternative.Changes
main/mimi_config.h: MiniMax endpoint macros for both regions (URL, host, path), default model, default region, region secret default, and an NVS key for the region.main/llm/llm_proxy.c:provider_is_minimax()andprovider_is_openai_compat()so every OpenAI-shaped branch (auth header, request body, response parsing) also covers MiniMax.minimax_region_is_cn()plus region-awarellm_api_url()/llm_api_host()/llm_api_path().llm_set_minimax_region()to persist the region to NVS.main/llm/llm_proxy.h: declaration forllm_set_minimax_region().main/cli/serial_cli.c:set_minimax_region <global_en|cn_zh>command;set_model_providerhelp updated to listminimax.main/mimi_secrets.h.example: MiniMax provider/region configuration example.README.md,README_CN.md,README_JA.md: document the MiniMax provider, its models, and regional selection.Any region value other than
cn_zhfalls back to the global endpoint. Anthropic and OpenAI behavior is unchanged.Checks
main/mimi_config.hand exercises the region-selection helpers (gcc -Wall -Wextra): verifiedglobal_en/default ->api.minimax.ioandcn_zh->api.minimaxi.comfor both host and full URL, and that Anthropic/OpenAI selection is unaffected by the region. All assertions passed.Note: the full ESP-IDF firmware build was not run because the ESP-IDF / Xtensa toolchain is not available in this environment.
Summary by CodeRabbit
New Features
Documentation