Skip to content

feat(llm): add MiniMax provider with global/China regional endpoints - #196

Open
octo-patch wants to merge 1 commit into
memovai:mainfrom
octo-patch:octo/20260729-provider-add-recvq9MkiUPVOH
Open

feat(llm): add MiniMax provider with global/China regional endpoints#196
octo-patch wants to merge 1 commit into
memovai:mainfrom
octo-patch:octo/20260729-provider-add-recvq9MkiUPVOH

Conversation

@octo-patch

@octo-patch octo-patch commented Jul 29, 2026

Copy link
Copy Markdown

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/completions

The default model is MiniMax-M3, with MiniMax-M2.7 available 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() and provider_is_openai_compat() so every OpenAI-shaped branch (auth header, request body, response parsing) also covers MiniMax.
    • minimax_region_is_cn() plus region-aware llm_api_url() / llm_api_host() / llm_api_path().
    • Region loaded from the build-time secret then overridden by NVS, mirroring the existing provider/model handling.
    • llm_set_minimax_region() to persist the region to NVS.
  • main/llm/llm_proxy.h: declaration for llm_set_minimax_region().
  • main/cli/serial_cli.c: set_minimax_region <global_en|cn_zh> command; set_model_provider help updated to list minimax.
  • 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_zh falls back to the global endpoint. Anthropic and OpenAI behavior is unchanged.

Checks

  • Host-compiled a standalone harness that includes the real main/mimi_config.h and exercises the region-selection helpers (gcc -Wall -Wextra): verified global_en/default -> api.minimax.io and cn_zh -> api.minimaxi.com for 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

    • Added MiniMax as a supported LLM provider.
    • Added support for MiniMax models, region-specific endpoints, and configurable regions.
    • Added a CLI command to select the MiniMax region at runtime.
    • Added support for saving MiniMax region settings for future use.
  • Documentation

    • Updated English, Chinese, and Japanese setup guides with MiniMax configuration, model, API key, and CLI instructions.

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>
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

MiniMax 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.

Changes

MiniMax Provider Integration

Layer / File(s) Summary
MiniMax configuration and provider contracts
main/mimi_config.h, main/mimi_secrets.h.example, main/llm/llm_proxy.h
Defines MiniMax models, regions, endpoints, secrets, NVS storage, and the public region setter API.
Region-aware OpenAI-compatible proxy behavior
main/llm/llm_proxy.c
Adds MiniMax provider detection, regional endpoint routing, configuration overrides, compatible request/response handling, and NVS-backed region updates.
CLI wiring and provider documentation
main/cli/serial_cli.c, README.md, README_CN.md, README_JA.md
Adds MiniMax provider and region CLI commands and documents MiniMax credentials, models, provider selection, and region configuration.

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
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding MiniMax provider support with regional endpoints.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between bb10ea0 and ab33e74.

📒 Files selected for processing (8)
  • README.md
  • README_CN.md
  • README_JA.md
  • main/cli/serial_cli.c
  • main/llm/llm_proxy.c
  • main/llm/llm_proxy.h
  • main/mimi_config.h
  • main/mimi_secrets.h.example

Comment thread main/llm/llm_proxy.c
Comment on lines 22 to +25
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;

Copy link
Copy Markdown

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

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.

Comment thread README.md
Comment on lines +172 to +175
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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 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 the set_api_key comment to include MiniMax.
  • README_CN.md#L187-L190: update the Chinese set_api_key comment to include MiniMax.
  • README_JA.md#L172-L175: update the Japanese set_api_key comment to include MiniMax.
📍 Affects 3 files
  • README.md#L172-L175 (this comment)
  • README_CN.md#L187-L190
  • README_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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant