OpenCode 配置 MiniMax 免费模型指南

minimax

今天把 OpenCode 的默认模型配置成了 MiniMax M2.5 Free,教程记录一下。

背景

我想把自己的 OpenCode 配置成使用 MiniMax 的免费模型,于是研究了一下。最新版本是 M2.7(2026年3月发布),但是在 OpenRouter 上免费只有 M2.5,且 oh-my-openagent 插件内部也硬编码了 M2.7,需要一并修改。

MiniMax M2.5 Free 配置教程

1. 申请 OpenRouter API Key

OpenRouter 是一个聚合多家 AI 模型 API 的平台,其中提供了免费的 MiniMax 模型。

  1. 访问 https://openrouter.ai/keys
  2. 点击 “Create a new key” 创建免费 API Key
  3. 复制生成的 Key

2. 配置 OpenCode

编辑配置文件 ~/.config/opencode/opencode.json

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": [
    "oh-my-openagent@latest"
  ],
  "mcp": {
    "playwright": {
      "type": "local",
      "command": [
        "bun",
        "x",
        "@playwright/mcp@latest"
      ],
      "enabled": true
    }
  },
  "provider": {
    "openrouter": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "MiniMax M2.5 Free",
      "options": {
        "baseURL": "https://openrouter.ai/api/v1",
        "apiKey": "你的 OpenRouter API Key"
      },
      "models": {
        "minimax-m2.5-free": {
          "name": "minimax/minimax-m2.5:free"
        }
      }
    }
  },
  "model": "openrouter/minimax/minimax-m2.5:free"
}

3. 配置 oh-my-openagent(如有安装)

如果安装了 oh-my-openagent 插件,它内部默认配置了 minimax-m2.7-free 模型,但 OpenRouter 上免费只有 M2.5。需要修改插件配置。

编辑 ~/.config/opencode/oh-my-openagent.json,将所有 openrouter/minimax/minimax-m2.5:free 替换为 openrouter/minimax/minimax-m2.5:free

{
  "$schema": "https://raw.githubusercontent.com/code-yeongyu/oh-my-opencode/master/assets/oh-my-opencode.schema.json",
  "agents": {
    "hephaestus": {
      "model": "openrouter/minimax/minimax-m2.5:free"
    },
    "oracle": {
      "model": "openrouter/minimax/minimax-m2.5:free"
    },
    "librarian": {
      "model": "openrouter/minimax/minimax-m2.5:free"
    },
    "explore": {
      "model": "openrouter/minimax/minimax-m2.5:free"
    },
    "multimodal-looker": {
      "model": "openrouter/minimax/minimax-m2.5:free"
    },
    "prometheus": {
      "model": "openrouter/minimax/minimax-m2.5:free"
    },
    "metis": {
      "model": "openrouter/minimax/minimax-m2.5:free"
    },
    "momus": {
      "model": "openrouter/minimax/minimax-m2.5:free"
    },
    "sisyphus": {
      "model": "openrouter/minimax/minimax-m2.5:free"
    },
    "sisyphus-junior": {
      "model": "openrouter/minimax/minimax-m2.5:free"
    },
    "atlas": {
      "model": "openrouter/minimax/minimax-m2.5:free"
    }
  },
  "categories": {
    "visual-engineering": {
      "model": "ollama/qwen3-coder-next:q4_K_M"
    },
    "ultrabrain": {
      "model": "openrouter/minimax/minimax-m2.5:free"
    },
    "deep": {
      "model": "openrouter/minimax/minimax-m2.5:free"
    },
    "artistry": {
      "model": "openrouter/minimax/minimax-m2.5:free"
    },
    "quick": {
      "model": "openrouter/minimax/minimax-m2.5:free"
    },
    "unspecified-low": {
      "model": "openrouter/minimax/minimax-m2.5:free"
    },
    "unspecified-high": {
      "model": "openrouter/minimax/minimax-m2.5:free"
    },
    "writing": {
      "model": "openrouter/minimax/minimax-m2.5:free"
    }
  }
}

4. 重启 OpenCode

配置完成后重启 OpenCode 即可使用免费的 MiniMax 模型。

模型信息

模型 价格 Context
MiniMax M2.5 Free $0/M tokens 196K tokens

完全免费!香!

参考资料

  • MiniMax 官方文档:https://platform.minimax.io/docs/
  • OpenRouter:https://openrouter.ai/

为什么 cAdvisor 在部分节点采集不到容器的内存数据? Mac 下 QwenPaw 安装记录 - 从零配置 OpenRouter MiniMax 模型