OpenCode

更新时间:
复制为 MD 格式

OpenCode 是一款开源 AI 编程工具,本文介绍如何在 OpenCode 中配置与使用阿里云百炼 Coding Plan。

安装 OpenCode

  1. 安装或更新 Node.js(v18.0 或更高版本)。

  2. 在终端中执行以下命令安装 OpenCode。

    npm install -g opencode-ai

    在终端中执行以下命令,若输出版本号,则表示安装成功。

    opencode -v

在 OpenCode 中配置 Coding Plan

复制以下内容并将YOUR_API_KEY替换为您的 Coding Plan 专属 API Key,写入 OpenCode 配置文件~/.config/opencode/opencode.json中并保存。您可以自行设置并切换支持的模型列表中的模型。

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "bailian-coding-plan": {
      "npm": "@ai-sdk/anthropic",
      "name": "Model Studio Coding Plan",
      "options": {
        "baseURL": "https://coding.dashscope.aliyuncs.com/apps/anthropic/v1",
        "apiKey": "YOUR_API_KEY"
      },
      "models": {
        "qwen3.5-plus": {
          "name": "Qwen3.5 Plus",
          "modalities": {
            "input": [
              "text",
              "image"
            ],
            "output": [
              "text"
            ]
          },
          "options": {
            "thinking": {
              "type": "enabled",
              "budgetTokens": 1024
            }
          }
        },
        "qwen3-max-2026-01-23": {
          "name": "Qwen3 Max 2026-01-23"
        },
        "qwen3-coder-next": {
          "name": "Qwen3 Coder Next"
        },
        "qwen3-coder-plus": {
          "name": "Qwen3 Coder Plus"
        },
        "MiniMax-M2.5": {
          "name": "MiniMax M2.5",
          "options": {
            "thinking": {
              "type": "enabled",
              "budgetTokens": 1024
            }
          }
        },
        "glm-5": {
          "name": "GLM-5",
          "options": {
            "thinking": {
              "type": "enabled",
              "budgetTokens": 1024
            }
          }
        },
        "glm-4.7": {
          "name": "GLM-4.7",
          "options": {
            "thinking": {
              "type": "enabled",
              "budgetTokens": 1024
            }
          }
        },
        "kimi-k2.5": {
          "name": "Kimi K2.5",
          "modalities": {
            "input": [
              "text",
              "image"
            ],
            "output": [
              "text"
            ]
          },
          "options": {
            "thinking": {
              "type": "enabled",
              "budgetTokens": 1024
            }
          }
        }
      }
    }
  }
}

使用 OpenCode

在终端中执行以下命令进入 OpenCode。

opencode

在命令行输入/models,输入Model Studio Coding Plan,选择模型后即可使用。

image

image