MiniMax M4 Setup for Claude Code & Cursor: Config, Effort & Caching
Copyable Claude Code (https://api.minimax.io/anthropic) and Cursor (https://api.minimax.io/v1) configurations for MiniMax M4,
including the effort="medium" setting that lowered our measured coding bill by 46% ($0.0290 vs $0.0534/task) and prefix-cache verification checks.
Step 0: Clear Conflicting Shell Environment Variables
If you previously exported Anthropic or OpenAI keys in ~/.zshrc or ~/.bashrc, unset them first so Claude Code reads your updated config cleanly:
unset ANTHROPIC_AUTH_TOKEN ANTHROPIC_BASE_URL unset OPENAI_API_KEY OPENAI_BASE_URL
1. Claude Code Setup (Anthropic-Compatible Endpoint)
Option A — Official CLI Wizard (Fastest):
npx -y mmx-cli@latest agent setup
Option B — Manual ~/.claude/settings.json (Cost-Optimized effort="medium"):
MiniMax's starter template sets CLAUDE_CODE_EFFORT_LEVEL to "max". In our 218-run coding benchmark, switching to "medium" reduced average thinking tokens from 15,787 to 8,053 and cut per-task spend from $0.0534 to $0.0290 (88.9% vs 90.0% pass rate).
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.minimax.io/anthropic",
"ANTHROPIC_AUTH_TOKEN": "<YOUR_MINIMAX_API_KEY>",
"CLAUDE_CODE_AUTO_COMPACT_WINDOW": "524288",
"CLAUDE_CODE_EFFORT_LEVEL": "medium",
"ANTHROPIC_MODEL": "MiniMax-M4",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "MiniMax-M4",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "MiniMax-M4",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "MiniMax-M4"
}
}
2. Cursor Setup (Direct vs Multi-Model Coexistence)
Official OpenAI-Compatible Route
- Open Cursor → Settings → Models → API Keys (Cursor Pro+ required).
- Enable Override OpenAI Base URL and enter
https://api.minimax.io/v1. - Paste your MiniMax API or M Plan key into OpenAI API Key and toggle it on.
- Scroll to Add Custom Model, add
MiniMax-M4, and select it in chat.
Route via OpenRouter or LiteLLM
Overriding Cursor's OpenAI Base URL directly to api.minimax.io disables native OpenAI model IDs. To keep GPT-6.2, Claude, and M4 together:
- Set Override OpenAI Base URL to
https://openrouter.ai/api/v1(or your local LiteLLM proxy). - Add custom model ID
minimax/minimax-m4alongside your other models. - For raw API scripts, pin first-party weights with the JSON below:
{
"model": "minimax/minimax-m4",
"max_tokens": 32768,
"reasoning": { "effort": "medium" },
"provider": { "only": ["minimax"], "allow_fallbacks": false }
}
3. Cost, Prefix Cache & Token Limit Checklist (Verified 2026-12-04)
| Observed Behavior | Measured Fact | Recommended Config |
|---|---|---|
| Always-On Thinking Tokens | reasoning.enabled: false returns HTTP 400; default uses ~15.8K thinking tokens/task. |
Use effort: "medium" for daily coding; reserve "max" for hard debugging. |
| Output Cap Truncation | 8,192 cap achieved 37.5% pass rate vs 90.0% at 32,768 cap. | Always configure max_tokens ≥ 32768. |
| Automatic Prefix Caching | 99.9% hit on repeated 30,709-token prefix ($0.0252 → $0.0023, -35% TTFT). | Keep system prompts & repo context stable at the top of messages; avoid dynamic timestamps in prefix. |
| Dense Code Token Density | Source code & JSON measured ~2.76 chars/token (+26.8% vs prose); >1M returned HTTP 502. | Set CLAUDE_CODE_AUTO_COMPACT_WINDOW to 524288 to stay safely inside the 1M ceiling. |
Estimate your exact monthly coding spend on the Solo Coding Agent Preset Calculator → or compare fixed plans on M Plan vs API →.
FAQ: MiniMax M4 in Claude Code & Cursor
What is the official MiniMax M4 endpoint for Claude Code?
Set ANTHROPIC_BASE_URL to https://api.minimax.io/anthropic and ANTHROPIC_MODEL to MiniMax-M4 inside ~/.claude/settings.json, or run `npx -y mmx-cli@latest agent setup` to configure Claude Code automatically.
How do I cut MiniMax M4 token cost in Claude Code without losing coding quality?
Change CLAUDE_CODE_EFFORT_LEVEL from the default 'max' to 'medium' (or pass reasoning: {'effort': 'medium'} with max_tokens >= 32768 on direct/OpenRouter API calls). In our 218-run coding benchmark, effort='medium' lowered per-task cost from $0.0534 to $0.0290 (-46%) and runtime from 209.9s to 124.7s while holding an 88.9% pass rate.
How can I use MiniMax M4 in Cursor without breaking OpenAI GPT models?
Overriding Cursor's global OpenAI Base URL to https://api.minimax.io/v1 routes all OpenAI-protocol requests to MiniMax. To keep GPT-6.2, Claude, and MiniMax M4 working side by side, point Cursor's OpenAI Base URL to OpenRouter (https://openrouter.ai/api/v1) or a local LiteLLM proxy and add `minimax/minimax-m4` as a custom model.
Why does my MiniMax M4 response get cut off or return empty code blocks?
MiniMax M4 uses always-on internal reasoning tokens (averaging 8,053 tokens at medium effort and 15,787 at max effort on multi-step coding tasks). Setting max_tokens below 16K–32K can exhaust the output budget during thinking—in our tests, raising max_tokens from 8,192 to 32,768 increased pass rate from 37.5% to 90.0%.
How do I verify implicit prefix caching ($0.05/MTok) is working?
Keep your system prompt and repo prefix byte-identical across turns. In our official-route probe on a 30,709-token prompt, turn 2 automatically hit cache on 30,680 tokens (99.9%), cutting input cost by 90.7% and TTFT by 35% with zero extra headers.
MiniMax M4 Raw Benchmark Dataset & Repro Kit
Download all 218 first-party benchmark logs (JSONL + CSV with allow_fallbacks: false),
1M-context needle outputs, Python benchmark scripts, and our computed FinOps cost sheet.
Preview sample CSV rows.
MiniMax-M4-218-Run-Benchmark-Dataset-2026-12.zip (59.5 KB · SHA-256 514b81ca16b93204…) · 30-day re-download pass.