MiniMax’s M2 family is built for exactly what a coding agent does — multi-step, end-to-end tasks — and it’s cheap to run. OpenCode is free, open source, and provider-agnostic. Put them together and you get a budget agentic-coding setup that’s both capable and responsive, all in the terminal.
This is the OpenCode + MiniMax setup. For OpenCode’s general provider model, see OpenCode custom providers.
Step 1: Install OpenCode and get a MiniMax key
npm install -g opencode-ai
Sign up on the MiniMax platform and create an API key. On Windows, WSL gives the cleaner shell — see install OpenCode on Windows with WSL.
Step 2: Add the MiniMax provider
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"minimax": {
"npm": "@ai-sdk/openai-compatible",
"name": "MiniMax",
"options": {
"baseURL": "https://api.minimax.io/v1",
"apiKey": "{env:MINIMAX_API_KEY}"
},
"models": {
"minimax-m2.5": { "name": "MiniMax M2.5" }
}
}
},
"model": "minimax/minimax-m2.5"
}
Export the key:
export MINIMAX_API_KEY="your-minimax-key"
Confirm the exact base URL and model ID on MiniMax’s docs.
Step 3: Run it
opencode
The default is minimax/minimax-m2.5. Start a multi-step task and you’ll see the agentic strengths — it’s tuned for exactly this.
MiniMax models in OpenCode
| minimax/minimax-m2.5 | Current agentic coding flagship |
|---|---|
| minimax/minimax-m2 | Earlier compact agentic model |
Pricing
OpenCode is free; MiniMax M2.5 is low-cost pay-per-token with automatic caching that discounts the repeated context agent sessions generate. Some MiniMax products also offer subscription plans. Confirm current rates on MiniMax’s pricing page. For the broader comparison, see MiniMax vs DeepSeek vs GLM.
Troubleshooting
- Provider not found — the
providerkey (minimax) must match themodelprefix. - Auth errors —
MINIMAX_API_KEYnot set in the launching shell. - Model rejected — confirm the current M2.5 model ID on MiniMax.
- Format errors — confirm you’re using the OpenAI-compatible endpoint.
MiniMax + OpenCode checklist
- OpenCode installed
- MiniMax API key created and exported
- Provider block with MiniMax's OpenAI base URL
- minimax-m2.5 listed; default set
- Launched with opencode
Wrapping up
MiniMax M2 with OpenCode is budget agentic coding done right: a free, open agent on a model purpose-built for multi-step tasks, at low pay-per-token rates with caching. Add the provider block, set minimax-m2.5 as default, and launch. Verify the current endpoint and IDs on MiniMax’s docs.
To run MiniMax with Claude Code instead, see run MiniMax M2.5 with Claude Code.