M2 for AI Coding Tools
How to plug MiniMax-M2 into popular AI coding assistants and IDE extensions.
M2 for AI Coding Tools
MiniMax-M2 exposes both OpenAI-compatible (chat completions) and Claude-compatible (messages) endpoints, making it simple to drop into existing AI coding workflows. This guide walks through common tools and configuration patterns.
1. Claude-Code (Recommended)
Claude Code reads its provider configuration from ~/.claude/settings.json. In this file, add or update the env field as shown below. Set MINIMAX_API_KEY to the API key obtained from the minimax-m2.com.
{
"env": {
"ANTHROPIC_BASE_URL": "https://minimax-m2.com/api/",
"ANTHROPIC_AUTH_TOKEN": "<MINIMAX_API_KEY>",
"API_TIMEOUT_MS": "3000000",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": 1,
// Model Selection: MiniMax-M2.1 (default) or MiniMax-M2
"ANTHROPIC_MODEL": "MiniMax-M2.1", // Change to "MiniMax-M2" for faster Python/JS projects
"ANTHROPIC_SMALL_FAST_MODEL": "MiniMax-M2",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "MiniMax-M2.1",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "MiniMax-M2.1", // M2.1 for highest quality
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "MiniMax-M2"
}
}Save the file and restart Claude Code. Every inline edit, "fix", or chat request will now hit https://minimax-m2.com/api/v1/messages with the Anthropic-compatible schema.
Model Selection Strategy:
- Set
ANTHROPIC_MODELtoMiniMax-M2if your project primarily uses Python/JavaScript and you prioritize speed - Keep
ANTHROPIC_MODELasMiniMax-M2.1(default) for Rust, Java, Golang, C++, Kotlin, or Objective-C projects - Use
MiniMax-M2.1for complex reasoning tasks requiring highest quality
2. Codex
Install codex
npm i -g @openai/codexConfigure MiniMax API
- Add the following configuration to the .codex/config.toml file:
[model_providers.minimax]
name = "MiniMax Chat Completions API"
base_url = "https://minimax-m2.com/api/v1"
env_key = "MINIMAX_API_KEY"
wire_api = "chat"
requires_openai_auth = false
request_max_retries = 4
stream_max_retries = 10
stream_idle_timeout_ms = 300000
[profiles.m2]
model = "codex-MiniMax-M2"
model_provider = "minimax"
# Alternative: Use M2.1 for multi-language projects (default recommended)
[profiles.m2.1]
model = "codex-MiniMax-M2.1"
model_provider = "minimax"
# Optional: Use M2.7 for independent usage attribution
[profiles.m2.7]
model = "codex-MiniMax-M2.7"
model_provider = "minimax"- Set the API key using environment variables in the current terminal session for security reasons. Use the API key obtained from the minimax-m2.com as the value for MINIMAX_API_KEY.
export MINIMAX_API_KEY="<MINIMAX_API_KEY>"- Start the Codex CLI with the specified profile.
# For multi-language projects (Rust, Java, Golang, C++, etc.) - Recommended default
codex --profile m2.1
# For Python/JavaScript agent workflows (faster inference)
codex --profile m2
# For independent M2.7 experiments / billing attribution
codex --profile m2.7