开放代码

通过与 Anthropic 兼容的 Model Gate API 连接 OpenCode

开放代码

配置 Anthropic 提供者 ~/.config/opencode/opencode.jsonc 在 Linux/macOS 或 C:\Users\%USERNAME%\.config\opencode\opencode.jsonc 在 Windows 上。

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "anthropic": {
      "options": {
        "baseURL": "https://api.model-gate.com/v1",
        "apiKey": "mg_live_..."
      }
    }
  }
}

对于 OpenCode, baseURL 包括 /v1。保存文件并正常启动 OpenCode。