本文介绍如何在 OpenCode 中配置并使用方舟 Coding Plan。
核心配置#
接入工具的核心参数如下:
模型配置#
支持以下两种方式配置模型:
在工具配置文件中指定 Model Name,可实时切换模型。支持配置的 Model Name:
doubao-seed-evolvingdoubao-seed-2.1-prodoubao-seed-2.1-litedoubao-seed-2.0-miniglm-5.3(glm-latest)glm-5.3-flashdeepseek-v4.1-flashdeepseek-v4.1-flash-economydeepseek-v4-flashdeepseek-v4-prokimi-k2.8-previewkimi-k3.1-pro
- 在配置文件中指定模型为
ark-code-latest。 - 通过 开通管理页面 选择或切换目标模型,切换模型后 3-5 分钟即可生效。
支持 Auto 模式,通过「效果 + 速度」双维度智能算法自动选择模型。
Base URL#
不同的工具配置的 Base URL 根据兼容的协议会有不同:
- 兼容 Anthropic 接口协议工具:
https://ark.cn-beijing.volces.com/api/coding - 兼容 OpenAI 接口协议工具:
https://ark.cn-beijing.volces.com/api/coding/v3
API Key#
前提条件#
您已按需订阅 Coding Plan 套餐。如未订阅,请访问 方舟 Coding Plan 活动 按需订阅套餐。
安装 OpenCode#
前提条件:安装 Node.js 18 或更新版本。
在命令行界面,执行以下命令安装 OpenCode。
npm install -g opencode-ai
安装结束后,执行以下命令查看安装结果,若显示版本号则安装成功。
opencode --version
配置 OpenCode#
需配置的信息#
如您对 OpenCode 熟悉,或本地已有配置,可获取以下信息直接配置。
- Base URL:
https://ark.cn-beijing.volces.com/api/coding/v3。 - API Key:获取API Key。
- Model:支持配置 Model Name(实时切换模型)或
ark-code-latest(控制台切换模型)。
具体配置方式参见 模型配置。
方式 1:一键配置(推荐)#
Ark CLI 是火山方舟平台官方命令行工具,支持在本地终端快速完成认证与资源管理,并可将能力安装到常用 AI Agent 中,降低手动配置的时间成本和出错风险。
-
安装 Ark CLI
环境要求:Node.js 18 或更新版本。支持 macOS、Linux、Windows。
npm install -g @volcengine/ark-cli@latest
arkcli --version
-
登录 Ark CLI
根据界面提示选择登录方式,推荐选择 火山 SSO (浏览器登录),在浏览器中完成授权即可。
arkcli auth login
- 一键配置 OpenCode
arkcli helper
运行 ArkCLI Helper,根据界面提示完成配置。
- 选择 Profile:
coding-plan_cn-beijing_personal。 - 选择默认 model:按需选择。
- 选择 AI Agent:
OpenCode。
配置完成后,OpenCode 会自动识别配置的模型。启动 OpenCode 即可使用。
方式 2:手动配置#
新建 ~/.config/opencode/opencode.json(Windows 路径:%USERPROFILE%\.config\opencode\opencode.json),配置信息如下:
Coding Plan 兼容 OpenAI 接口协议,支持 Responses API、Chat API。推荐使用 Responses API 的配置,推理效果更好。
支持的两类 API 仅在 npm 配置上不同:
- Responses API 配置:
"npm": "@ai-sdk/openai" - Chat API 配置:
"npm": "@ai-sdk/openai-compatible"
以配置 ark-code-latest 为例,具体信息如下。
{
"$schema": "https://opencode.ai/config.json",
"model": "volcengine-coding-plan/ark-code-latest",
"provider": {
"volcengine-coding-plan": {
"npm": "@ai-sdk/openai",
"name": "Volcano Engine(Responses API)",
"options": {
"baseURL": "https://ark.cn-beijing.volces.com/api/coding/v3",
"apiKey": "<ARK_API_KEY>"
},
"models": {
"ark-code-latest": {
"name": "ark-code-latest",
"limit": {
"context": 256000,
"output": 32000
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
}
},
"doubao-seed-2.1-pro": {
"name": "doubao-seed-2.1-pro",
"limit": {
"context": 1024000,
"output": 65536
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
}
},
"doubao-seed-evolving": {
"name": "doubao-seed-evolving",
"limit": {
"context": 1024000,
"output": 65536
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
}
},
"glm-5.3": {
"name": "glm-5.3",
"limit": {
"context": 1024000,
"output": 65536
},
"modalities": {
"input": [
"text"
],
"output": [
"text"
]
}
},
"glm-5.3-flash": {
"name": "glm-5.3-flash",
"limit": {
"context": 1024000,
"output": 65536
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
}
},
"glm-latest": {
"name": "glm-latest",
"limit": {
"context": 1024000,
"output": 65536
},
"modalities": {
"input": [
"text"
],
"output": [
"text"
]
}
},
"deepseek-v4-flash": {
"name": "deepseek-v4-flash",
"limit": {
"context": 1024000,
"output": 65536
}
},
"deepseek-v4-pro": {
"name": "deepseek-v4-pro",
"limit": {
"context": 1024000,
"output": 65536
}
},
"deepseek-v4.1-flash": {
"name": "deepseek-v4.1-flash",
"limit": {
"context": 1024000,
"output": 65536
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
}
},
"deepseek-v4.1-flash-economy": {
"name": "deepseek-v4.1-flash-economy",
"limit": {
"context": 1024000,
"output": 65536
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
}
},
"doubao-seed-2.1-lite": {
"name": "doubao-seed-2.1-lite",
"limit": {
"context": 1024000,
"output": 65536
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
}
},
"doubao-seed-2.0-mini": {
"name": "doubao-seed-2.0-mini",
"limit": {
"context": 256000,
"output": 65536
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
}
},
"kimi-k2.8-preview": {
"name": "kimi-k2.8-preview",
"limit": {
"context": 1024000,
"output": 65536
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
}
},
"kimi-k3.1-pro": {
"name": "kimi-k3.1-pro",
"limit": {
"context": 1024000,
"output": 65536
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
}
}
}
}
}
}
{
"$schema": "https://opencode.ai/config.json",
"model": "volcengine-coding-plan/ark-code-latest",
"provider": {
"volcengine-coding-plan": {
"npm": "@ai-sdk/openai-compatible",
"name": "Volcano Engine(Chat API)",
"options": {
"baseURL": "https://ark.cn-beijing.volces.com/api/coding/v3",
"apiKey": "<ARK_API_KEY>"
},
"models": {
"ark-code-latest": {
"name": "ark-code-latest",
"limit": {
"context": 256000,
"output": 32000
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
}
},
"doubao-seed-2.1-pro": {
"name": "doubao-seed-2.1-pro",
"limit": {
"context": 1024000,
"output": 65536
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
}
},
"doubao-seed-evolving": {
"name": "doubao-seed-evolving",
"limit": {
"context": 1024000,
"output": 65536
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
}
},
"glm-5.3": {
"name": "glm-5.3",
"limit": {
"context": 1024000,
"output": 65536
},
"modalities": {
"input": [
"text"
],
"output": [
"text"
]
}
},
"glm-5.3-flash": {
"name": "glm-5.3-flash",
"limit": {
"context": 1024000,
"output": 65536
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
}
},
"glm-latest": {
"name": "glm-latest",
"limit": {
"context": 1024000,
"output": 65536
},
"modalities": {
"input": [
"text"
],
"output": [
"text"
]
}
},
"deepseek-v4-flash": {
"name": "deepseek-v4-flash",
"limit": {
"context": 1024000,
"output": 65536
}
},
"deepseek-v4-pro": {
"name": "deepseek-v4-pro",
"limit": {
"context": 1024000,
"output": 65536
}
},
"deepseek-v4.1-flash": {
"name": "deepseek-v4.1-flash",
"limit": {
"context": 1024000,
"output": 65536
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
}
},
"deepseek-v4.1-flash-economy": {
"name": "deepseek-v4.1-flash-economy",
"limit": {
"context": 1024000,
"output": 65536
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
}
},
"doubao-seed-2.1-lite": {
"name": "doubao-seed-2.1-lite",
"limit": {
"context": 1024000,
"output": 65536
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
}
},
"doubao-seed-2.0-mini": {
"name": "doubao-seed-2.0-mini",
"limit": {
"context": 256000,
"output": 65536
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
}
},
"kimi-k2.8-preview": {
"name": "kimi-k2.8-preview",
"limit": {
"context": 1024000,
"output": 65536
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
}
},
"kimi-k3.1-pro": {
"name": "kimi-k3.1-pro",
"limit": {
"context": 1024000,
"output": 65536
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
}
}
}
}
}
}
使用 OpenCode#
-
启动 OpenCode:
opencode -
输入
/models,选择配置的模型并在 OpenCode 中使用。