Skip to content

MiniMax M2 + OpenCode: Agentic Coding on a Budget

Set up OpenCode with MiniMax M2 for cheap agentic coding. Provider config, model IDs, lightning mode, pricing and caching, and the common fixes — Windows or WSL.

MGMCSA Guru Team July 13, 2026 3 min read
OpenCode configured with MiniMax M2 for budget agentic coding

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 provider key (minimax) must match the model prefix.
  • Auth errorsMINIMAX_API_KEY not 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.

Frequently asked questions

Why pair MiniMax M2 with OpenCode?

Both are built for agentic work and cost little to run. OpenCode is free and open source, and MiniMax's M2 family is optimized for end-to-end coding at a fraction of frontier-model cost. Together they make a cheap, capable terminal agent.

How do I add MiniMax to OpenCode?

Add a custom provider in opencode.json using @ai-sdk/openai-compatible with MiniMax's OpenAI-compatible base URL and your key, then list the M2 model ID and set it as default.

Which MiniMax model should I use?

minimax-m2.5 is the current agentic coding flagship; minimax-m2 is the earlier compact model. Use M2.5 unless you have a reason to pin an older version. Confirm the exact ID on MiniMax's docs.

Does MiniMax cost much for agent sessions?

Not much — M2.5's rates are low and automatic caching discounts repeated context, which agent sessions generate a lot of. Confirm current rates on MiniMax's pricing page.

Does this run on Windows?

Yes, and cleanly in WSL. The OpenCode config is identical either way; WSL just gives the smoother terminal for a CLI agent.

Sources & further reading

Official vendor documentation referenced while writing this guide.

MG

MCSA Guru Team

IT & Systems Administration

We are working IT pros and system administrators who spend our days in Windows Server, Microsoft 365, and the wider Microsoft stack. MCSA Guru is where we write down the fixes and walkthroughs we wish we had found the first time.

MCSA Guru provides independent, educational IT guidance. Microsoft, Windows, Windows Server, Microsoft 365, Exchange, and Microsoft Teams are trademarks of Microsoft Corporation; Docker is a trademark of Docker, Inc. MCSA Guru is not affiliated with or endorsed by Microsoft or Docker. Always test changes in a safe environment before applying them in production.

Related guides

Fixing something right now?

Jump straight into the guide library or search for the exact error or task you are dealing with.