How to Set Up Claude Code with the MiniMax API in 2026
Claude Code is Anthropic’s official command-line coding agent. It’s powerful, well-designed, and — until recently — locked to Anthropic’s own API. Which meant you had to pay Anthropic pricing, route your code through their servers, and trust the defaults.
You can now point Claude Code at any OpenAI-compatible API endpoint. That includes OpenAI, DeepSeek, MiniMax, OpenRouter, or any other provider that exposes the chat-completions interface. Run the same Claude Code interface, but with the model that makes sense for you.
This guide covers the full setup — from a clean machine to a working Claude Code that talks to the MiniMax API. Works on macOS, Linux, and Windows.
Why MiniMax Over the Default Anthropic API?
| Reason | Details |
| :— | :— |
| Cost | MiniMax’s promo pricing is a fraction of Anthropic’s API rates |
| Performance | M3 scores competitively with Claude on coding benchmarks |
| Data sovereignty | Your code goes to a Chinese lab instead of US-based Anthropic |
| Reasoning capability | M3 is strong on multi-step agent tasks — exactly what Claude Code does |
For solo developers and small teams, this is the cheapest way to use Claude Code.
What You’ll Need
– A machine with Node.js 18+ (any OS)
– A MiniMax API key (and optionally a Group ID for TTS)
– 10 minutes
Step 1: Install Claude Code
The official way:
“`bash
macOS / Linux / WSL
curl -fsSL https://claude.ai/install.sh | sh
Or via npm (works everywhere)
npm install -g @anthropic-ai/claude-code
Windows (PowerShell)
irm https://claude.ai/install.ps1 | iex
“`
Verify:
“`bash
claude –version
Should print something like 2.1.x
“`
Step 2: Get Your API Credentials
You need a MiniMax API key. The endpoint format is `https://api.minimaxi.com/anthropic` (note the path — it’s the Anthropic-compatible endpoint, not the standard OpenAI-compatible one).
Get your key from the MiniMax platform dashboard. You’ll have:
– `ANTHROPIC_API_KEY` — your MiniMax API key
– `ANTHROPIC_BASE_URL` — set to `https://api.minimaxi.com/anthropic`
– `ANTHROPIC_MODEL` — the model name (e.g., `MiniMax-M3`, `MiniMax-M2.7`, `MiniMax-M2.7-highspeed`)
Step 3: Configure Claude Code
Claude Code reads environment variables. Set them in your shell profile so they persist:
On macOS / Linux / WSL — add to `~/.bashrc`, `~/.zshrc`, or `~/.profile`:
“`bash
export ANTHROPIC_BASE_URL=”https://api.minimaxi.com/anthropic”
export ANTHROPIC_API_KEY=”your-minimax-api-key-here”
export ANTHROPIC_MODEL=”MiniMax-M3″
export ANTHROPIC_DEFAULT_SONNET_MODEL=”MiniMax-M3″
export ANTHROPIC_DEFAULT_OPUS_MODEL=”MiniMax-M3″
export ANTHROPIC_SMALL_FAST_MODEL=”MiniMax-M3″
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
“`
On Windows (PowerShell) — run in PowerShell as admin:
“`powershell
[System.Environment]::SetEnvironmentVariable(“ANTHROPIC_BASE_URL”, “https://api.minimaxi.com/anthropic”, “User”)
[System.Environment]::SetEnvironmentVariable(“ANTHROPIC_API_KEY”, “your-minimax-api-key-here”, “User”)
[System.Environment]::SetEnvironmentVariable(“ANTHROPIC_MODEL”, “MiniMax-M3”, “User”)
[System.Environment]::SetEnvironmentVariable(“ANTHROPIC_DEFAULT_SONNET_MODEL”, “MiniMax-M3”, “User”)
[System.Environment]::SetEnvironmentVariable(“ANTHROPIC_DEFAULT_OPUS_MODEL”, “MiniMax-M3”, “User”)
[System.Environment]::SetEnvironmentVariable(“ANTHROPIC_SMALL_FAST_MODEL”, “MiniMax-M3”, “User”)
[System.Environment]::SetEnvironmentVariable(“CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC”, “1”, “User”)
“`
Reload the shell:
“`bash
source ~/.bashrc # or: exec zsh # or: open a new PowerShell window
“`
Step 4: Skip the Onboarding (Optional)
Claude Code’s first run normally asks you to log in to an Anthropic account. Skip this by pre-creating the config file:
On macOS / Linux:
“`bash
mkdir -p ~/.claude
cat > ~/.claude.json << 'EOF'
{
“hasCompletedOnboarding”: true
}
EOF
“`
On Windows (PowerShell):
“`powershell
New-Item -ItemType Directory -Path “$env:USERPROFILE\.claude” -Force
@’
{
“hasCompletedOnboarding”: true
}
‘@ | Set-Content “$env:USERPROFILE\.claude.json”
“`
Step 5: First Run
Open a terminal in any project directory and run:
“`bash
claude
“`
Claude Code will start. It will use the MiniMax model (since the environment variables override the defaults). You can verify the model by running:
“`bash
claude -p “what model are you using”
“`
If the model field shows `MiniMax-M3` or whatever you set, you’re connected.
Step 6: Set API Timeout (Optional but Recommended)
If you work with large repos or long prompts, the default timeout can be tight. Add a generous timeout:
“`bash
macOS / Linux
echo ‘export API_TIMEOUT_MS=”3000000″‘ >> ~/.bashrc
source ~/.bashrc
Windows PowerShell
[System.Environment]::SetEnvironmentVariable(“API_TIMEOUT_MS”, “3000000”, “User”)
“`
Common Issues
“Invalid API key”
Double-check that the key was copied correctly and that you’re using the right endpoint. The MiniMax API uses a different URL path than OpenAI’s:
– ❌ `https://api.minimaxi.com/v1/chat/completions` (OpenAI-style — wrong here)
– ✅ `https://api.minimaxi.com/anthropic` (Anthropic-compatible — correct)
“Model not found”
The MiniMax model names are case-sensitive. Common working values:
– `MiniMax-M3` (latest, recommended)
– `MiniMax-M2.7` (previous version, stable)
– `MiniMax-M2.7-highspeed` (faster M2.7 tier)
“Onboarding required” prompt keeps appearing
The `.claude.json` file isn’t being read. Check the location:
– macOS/Linux: `~/.claude.json` (note the dot, no nested folder)
– Windows: `%USERPROFILE%\.claude.json`
The file just needs `{“hasCompletedOnboarding”: true}`.
Slow responses
This is the API endpoint, not your machine. If M3 is too slow, try `MiniMax-M2.7-highspeed` — same model, faster tier.
Daily Workflow
Once set up, your daily workflow is identical to the default Claude Code experience:
“`bash
Start Claude Code in your project
cd ~/projects/my-app
claude
Common commands
/help
/clear
/agents
“`
Slash commands, tool calling, code editing — everything works exactly the same. The only thing that’s different is which model is on the other end.
Cost Comparison
Rough monthly cost for a solo developer using Claude Code ~3 hours/day:
| Setup | Approx. monthly |
| :— | :— |
| Anthropic default (Sonnet 4.5) | $80-150 |
| MiniMax M3 (current setup) | $5-15 |
| OpenAI GPT-5 mini | $15-30 |
| DeepSeek V4 Pro | $10-20 |
The savings are real. M3 handles 95% of what Sonnet does, at roughly 1/10th the cost for an individual user.
When to Switch Back
Some tasks still benefit from the actual Claude model:
– Hard reasoning puzzles where M3 makes mistakes
– Tasks requiring extremely careful code review where Anthropic’s models still have a slight edge
– Work where you need the highest-stakes output and cost isn’t the bottleneck
For most daily coding work, M3 is more than good enough.
—
Total time: 10 minutes. After setup, Claude Code is indistinguishable from the default — except much cheaper.
If you hit any snags with the setup, drop me a note. I do this configuration as part of my remote deployment service.
Related Articles
Get Notified About New Articles
One email per week when I publish a new article or update an existing one. New AI tool reviews, deployment updates, behind-the-scenes notes. No marketing, no spam, unsubscribe in one click.
Or learn more · RSS feed
- How to Set Up Hermes Web UI for AI Agent Management in 2026
- How to Self-Host n8n for $5/Month
- OpenClaw vs ChatGPT: Why Self-Hosting Wins for Power Users in 2026
- OpenClaw Docker Setup: From Zero to Running AI Assistant in 30 Minutes
Get Notified About New Articles
One email per week when I publish a new article or update an existing one. No marketing, no spam.