Skip to main content

Install OpenCode

  • Use curl to install the OpenCode
curl -fsSL https://opencode.ai/install | bash
  • Use npm to install the OpenCode
npm i -g opencode-ai
For more information, please refer to the OpenCode website

Configure MiniMax API

Important: Clear Anthropic Environment Variables Before ConfigurationBefore configuring, ensure you clear the following Anthropic-related environment variables to avoid conflicts with MiniMax API:
  • ANTHROPIC_AUTH_TOKEN
  • ANTHROPIC_BASE_URL
  1. Edit or create the OpenCode configuration file located at ~/.config/opencode/opencode.json. In this file, add or update the env field as shown below.
  • The baseURL should be set based on your location: for international users, use https://api.minimax.io/anthropic/v1; for users in China, use https://api.minimaxi.com/anthropic/v1.
  • Set <MINIMAX_API_KEY> to the API key obtained from the MiniMax Developer Platform (For users in China, visit MiniMax Developer Platform).
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "minimax": {
      "npm": "@ai-sdk/anthropic",
      "options": {
        "baseURL": "https://api.minimax.io/anthropic/v1",
        "apiKey": "<MINIMAX_API_KEY> (Optional)"
      },
      "models": {
        "MiniMax-M2.1": {
          "name": "MiniMax-M2.1"
        }
      }
    }
  }
}
Alternative Authentication Method: If you prefer not to add the API key directly to the configuration file, you can authenticate using the interactive login command. Follow these steps: i. Run the authentication command:
opencode auth login
ii. When prompted, select provider “Other”: iii. Enter the provider ID as “minimax”: iv. Enter your MiniMax API key when prompted:
  1. Navigate to your project and start interactive session
cd /path/to/your/project

opencode
  1. Enter /models, select the “MiniMax-M2.1” model and use it in OpenCode