Claude Code
Use MiniMax M3.1 Flash in Claude Code
The working settings.json, the environment variables that silently override it, and the model ID that unlocks the long context.
What you get
Claude Code talks to an Anthropic-compatible API, and MiniMax exposes exactly that shape at https://api.minimax.io/anthropic. Point Claude Code at that base URL and it runs the whole agent loop on M3.1 Flash: a 1,000,000-token context window, image and video input, and reasoning that is always on with adjustable depth.
Option 1: the one-click setup wizard
MiniMax ships a CLI that configures the agent for you:
npx -y mmx-cli@latest agent setupSelect Claude Code in the wizard. It installs the agent if the claude command is missing, checks claude --version, updates ~/.claude/settings.json and adds the MiniMax model list. The wizard also backs up the settings file it is about to change.
Option 2: edit settings.json manually
Open ~/.claude/settings.json and set the environment block:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.minimax.io/anthropic",
"ANTHROPIC_AUTH_TOKEN": "<MINIMAX_API_KEY>",
"CLAUDE_CODE_AUTO_COMPACT_WINDOW": "524288",
"ANTHROPIC_MODEL": "MiniMax-M3.1-Flash[1m]"
}
}Four details are easy to get wrong:
ANTHROPIC_BASE_URLmust point at the Anthropic-compatible path,/anthropic, not/v1.ANTHROPIC_AUTH_TOKENholds the MiniMax API key.CLAUDE_CODE_AUTO_COMPACT_WINDOW=524288sets the auto-compaction threshold in tokens. M3.1 Flash accepts a 1M-token input window; the harness still compacts earlier by default, and this value changes that.ANTHROPIC_MODEL=MiniMax-M3.1-Flash[1m]— the[1m]suffix is what requests long-context behaviour from the harness. Without it you may get a much smaller effective window.
Clear conflicting environment variables first
This is the single most common reason a correct settings.json appears to do nothing. Environment variables take priority over the settings file, so an inherited ANTHROPIC_AUTH_TOKEN pointing at a different provider silently wins.
unset ANTHROPIC_AUTH_TOKEN
unset ANTHROPIC_BASE_URLAnd if those are exported in ~/.bashrc or ~/.zshrc, remove the lines — otherwise every new shell reloads them and the problem comes back.
Option 3: CC Switch
MiniMax also documents CC Switch as a third route for managing the configuration. If you prefer a GUI or already use CC Switch for other providers, follow the official page rather than hand-editing the file.
Verify it works
- Start Claude Code with a short prompt and confirm the model name shown in the session header is MiniMax-M3.1-Flash.
- Ask it to repeat the base URL or print a token count; a request that never leaves your machine will not produce a MiniMax response.
- Send a deliberately long document and check that the context is not compacted immediately.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
| Still uses Claude, not MiniMax | ANTHROPIC_BASE_URL or ANTHROPIC_AUTH_TOKEN exported in the shell | Unset both, remove the shell rc lines, open a new terminal |
| Model not found error | ANTHROPIC_MODEL still uses a preview-era id | Use MiniMax-M3.1-Flash[1m] |
| Context compacts far too early | Default auto-compact window | Set CLAUDE_CODE_AUTO_COMPACT_WINDOW=524288 |
| Costs more than expected | Reasoning effort defaults to max | Lower effort in the API call path; see pricing |
| Requests fail on long input | Context window not applied | Keep the [1m] suffix in the model id |
Cost note
Long Claude Code sessions are the classic way to get a surprising invoice: a 1M-token context, re-sent every turn, plus reasoning tokens that are always on. Keep the stable prefix cacheable and check the effort setting. The pricing page has the arithmetic.
The alternative path
Ollama can launch Claude Code against the same model in one command:
ollama launch claude --model minimax-m3.1-flash:cloudThat path is shorter but routes through Ollama’s cloud, with its own pricing and provider behaviour. The OpenCode and agents page compares the two routes.
Next: the Codex guide covers the same model in OpenAI’s coding agent, and the FAQ collects the errors people hit most.
Sources and version notes
Checked October 21, 2026. We label official claims, third-party measurements, our own testing and community reports separately — see the sources policy for what each label means.