文档Docs
用 OpenCode 接火山方舟 Agent PlanConnect OpenCode to Volcano Ark Agent Plan
分清 Agent Plan、Coding Plan 和按量付费,用正确的地址、模型名和环境变量接入 OpenCode,排查内置连接选项的常见错误。Choose between Agent Plan, Coding Plan and pay-as-you-go, configure OpenCode with the right endpoint, model and environment variable, and troubleshoot built-in connection options.
用 OpenCode 接火山方舟 Agent Plan,先确认三件事:用套餐专属 key,地址用 https://ark.cn-beijing.volces.com/api/plan/v3,模型用 doubao-seed-2.1-pro。不要把按量付费的日期版模型名直接放进套餐配置。
Agent J 已支持这条接法,默认使用自定义服务商 ark-agent-plan。本页也给出独立使用 OpenCode 的配置方法。还没决定用哪家,先看按你用的模型选;开通与拿 key 见火山方舟套餐,安装与配对见安装。
适合谁
- 已开通 Agent Plan,想用豆包 Seed 2.1 Pro 做主力,并让它读截图。
- 已有 Coding Plan,继续使用原套餐。
- 需要按量付费接入,或在 OpenCode 里找不到正确的套餐选项。
三种接入怎么选
| Agent Plan | Coding Plan | 按量付费 | |
|---|---|---|---|
| 适合谁 | 新订阅 Agent Plan 的用户 | 已有 Coding Plan 的用户 | 按调用量结算的应用与任务 |
| OpenAI 兼容地址 | https://ark.cn-beijing.volces.com/api/plan/v3 | https://ark.cn-beijing.volces.com/api/coding/v3 | https://ark.cn-beijing.volces.com/api/v3 |
| 默认模型 | doubao-seed-2.1-pro | doubao-seed-2.1-pro | doubao-seed-2-1-pro-260915 |
| key 环境变量 | ARK_AGENT_PLAN_API_KEY | ARK_CODING_PLAN_API_KEY | ARK_API_KEY |
| Agent J 服务商名 | ark-agent-plan | ark-coding-plan | ark-api |
先认清套餐,再选地址、key 和模型。 Agent Plan 的专属 key 不能当成 Coding Plan 或按量付费 key 使用;不能靠切换地址把同一把 key 当作三种套餐通用。套餐用法与可用模型以方舟控制台和官方文档为准,价格以官方价格页和下单页为准。
Agent J 的模型验证与使用都交给 OpenCode,客服 bot 不会拿到套餐 key。只有套餐误配返回 401 时,Agent J 会向固定官方地址读取模型列表核对 key,不发送推理请求;模型列表不支持时仍由 OpenCode 验证。
拿对 key
Agent Plan:在方舟控制台 https://console.volcengine.com/ark/ 的 订阅 → Agent Plan → 使用配置 里取套餐专属 API Key。不要用 API Key 管理里新建的按量 key 代替。
Coding Plan:使用原套餐配置说明对应的 key。按量付费:在 API Key 管理中创建 key,并确认余额与模型已开通。不要把 key 发到聊天里;Agent J 用户等手机密钥卡,独立使用 OpenCode 的用户在本机安全设置环境变量。
用 Agent J 一步切换
跟 Agent 说:把 OpenCode 接到火山方舟 Agent Plan。它运行:
agentj agent switch opencode --preset ark --plan agent
已有 Coding Plan 时选这一条:
agentj agent switch opencode --preset ark --plan coding
按量付费选这一条:
agentj agent switch opencode --preset ark --plan payg
Agent J 会检查 OpenCode,必要时让你填手机密钥卡,写入方舟配置,再用 OpenCode 真实调用一次。成功才切;失败保留原工具并撤回这次新增的配置。已经在用 OpenCode 时,它会告诉你如何只换模型。密钥卡用法见手机上录入密钥。
手动配置 OpenCode
把下面的字段合并进 ~/.config/opencode/opencode.json,保留已有的其他服务商和设置。这是 JSON 配置,不是终端命令。示例使用 OpenAI 兼容的 Chat Completions;方舟官方 OpenCode 指南也提供使用 @ai-sdk/openai 的 Responses 接法,两种配置不要混在同一服务商里。
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"ark-agent-plan": {
"npm": "@ai-sdk/openai-compatible",
"name": "Volcano Ark Agent Plan",
"options": {
"baseURL": "https://ark.cn-beijing.volces.com/api/plan/v3",
"apiKey": "{env:ARK_AGENT_PLAN_API_KEY}"
},
"models": {
"doubao-seed-2.1-pro": {
"name": "Doubao Seed 2.1 Pro",
"modalities": { "input": ["text", "image"], "output": ["text"] }
}
}
}
},
"model": "ark-agent-plan/doubao-seed-2.1-pro"
}
让运行 OpenCode 的进程实际继承 ARK_AGENT_PLAN_API_KEY。终端里设置变量不会自动传给已经启动的 Agent J 后台服务;Agent J 用户应使用密钥卡,并按命令提示重启后台服务。不要把真实 key 写进 JSON、脚本或版本库。
重开 OpenCode 后确认选中 ark-agent-plan/doubao-seed-2.1-pro。验证一句话:让它回答“只回复 OK”,能收到正常回复且没有鉴权或模型错误,才说明这条调用跑通。模型自称豆包不能证明实际调用了哪个模型。
独立 OpenCode 用户可在已设置好环境变量的终端验证:
opencode run --model ark-agent-plan/doubao-seed-2.1-pro "Reply only OK"
/connect 内置选项的坑
在 /connect 搜 Volc Engine 时,看到 Coding Plan 或普通 Volc Engine,并不表示它适配你的 Agent Plan。Coding Plan 对应 /api/coding/v3,普通按量入口对应 /api/v3;Agent Plan 应用 /api/plan/v3。
即使看到内置火山方舟 Agent Plan,也要核对实际模型 ID 和地址。内置目录会随 OpenCode 版本与模型目录更新;不要只凭显示名称判断。出现 The requested model does not support the agent plan feature 时,优先检查请求中的模型是否属于当前套餐、拼写是否为套餐模型 ID,并核对地址。这个报错本身不能证明地址错了。
使用上面的自定义 ark-agent-plan 配置可以明确固定这两个字段,避免混用按量模型 ID 与套餐模型 ID。保留内置服务商也可以,调用时明确选择自定义模型。
模型与看图
先用 doubao-seed-2.1-pro 跑通,再按方舟套餐模型说明换模型。套餐的 doubao-seed-2.1-pro 与按量的 doubao-seed-2-1-pro-260915 是不同 ID,不要把点、连字符或日期自行互换。
发截图或做浏览器自动化时,要同时确认模型支持图片输入、OpenCode 配置声明了图片输入。模型列表与套餐档位会变化,换模型前查当前控制台。
和官方 arkcli 的关系
arkcli 是火山方舟官方命令行工具。它管理方舟资源与套餐,也能调用模型;helper 可给 OpenCode 等工具生成方舟配置。它适合查询套餐、模型与用量、排查方舟配置,不能仅凭能调用模型就替代一个完整的交互式编程工具。
Agent J 目前由 OpenCode 或 Claude Code 执行方舟对话,自己写入服务商配置;它会检测 arkcli 版本,但没有把 arkcli 接成可切换的主工具,也不自动调用它的 helper。无需为了使用 Agent Plan 先安装 arkcli。查看方舟官方文档。
常见报错
| 现象 | 先检查 | 处理 |
|---|---|---|
The requested model does not support the agent plan feature | 套餐模型 ID、套餐档位、baseURL | 先用本页的 /api/plan/v3 与 doubao-seed-2.1-pro,不要用带日期的按量 ID;再查当前套餐模型清单 |
401 / 403 | key 所属套餐、变量是否传给实际进程 | 用 Agent Plan 专属 key;不要打印 key,确认变量存在并重启实际服务 |
找不到模型、ModelNotFound | 是否选到了内置同名服务商、模型拼写 | 明确选择 ark-agent-plan/doubao-seed-2.1-pro;按量模型还需开通 |
429 / 额度不足 | 套餐用量、并发或频率限制 | 查看控制台,等额度刷新或降低并发;不反复重试 |
| 另外扣余额 | 是否误用 /api/v3 与按量 key | 切回套餐地址和套餐 key;账单以控制台为准 |
| 终端能用,Agent J 不行 | 后台进程是否继承变量 | 用手机密钥卡,按提示重启后台服务,再验证 |
| 模型看不到截图 | 模型能力与 modalities.input | 换支持图片的模型,并声明 image 输入 |
Agent Plan 和 Coding Plan 误配时,Agent J 确认另一套餐可用后,会提供改用对应套餐并重试的操作。它复用本地保存的 key,成功验证才切;已有不同 key 或自定义配置不会被覆盖。
切回原来的工具
跟 Agent 说切回 Claude Code,或运行:
agentj agent switch --undo
详见换 AI 编程工具。
Start with three matching settings: the Agent Plan's dedicated key, https://ark.cn-beijing.volces.com/api/plan/v3, and model doubao-seed-2.1-pro. A dated pay-as-you-go model ID is not a substitute for a plan model ID.
Agent J already supports this setup through its custom ark-agent-plan provider. This page also covers standalone OpenCode. See Choose by your model if you are still deciding, Volcano Ark plans to subscribe and get a key, and Install to pair Agent J.
Who it is for
- Agent Plan subscribers who want Doubao Seed 2.1 Pro as their main model, including screenshots.
- Existing Coding Plan subscribers keeping their current plan.
- Users choosing pay-as-you-go or unable to find the right plan in OpenCode.
Choose the right access method
| Agent Plan | Coding Plan | Pay-as-you-go | |
|---|---|---|---|
| Who should pick it | Agent Plan subscribers | Existing Coding Plan subscribers | Apps and tasks billed by usage |
| OpenAI-compatible URL | https://ark.cn-beijing.volces.com/api/plan/v3 | https://ark.cn-beijing.volces.com/api/coding/v3 | https://ark.cn-beijing.volces.com/api/v3 |
| Default model | doubao-seed-2.1-pro | doubao-seed-2.1-pro | doubao-seed-2-1-pro-260915 |
| Key environment variable | ARK_AGENT_PLAN_API_KEY | ARK_CODING_PLAN_API_KEY | ARK_API_KEY |
| Agent J provider ID | ark-agent-plan | ark-coding-plan | ark-api |
Match the plan, URL, key and model. An Agent Plan key does not double as a Coding Plan or pay-as-you-go key. Changing the URL does not make one key interchangeable across all three. The console and official documentation determine permitted uses and supported models. The official pricing page and order page are authoritative for prices.
Agent J runs model checks and conversations through OpenCode; support bots never receive plan keys. Only after a plan mismatch returns 401 may Agent J read the model list at a fixed official URL to identify the key, without sending an inference request. If that list is unavailable, OpenCode still performs the check.
Get the right key
For Agent Plan, use the dedicated API key under Subscription → Agent Plan → Usage configuration in the Ark console at https://console.volcengine.com/ark/ . A pay-as-you-go key created under API Key management is not the same credential.
For Coding Plan, follow the key instructions for your existing plan. For pay-as-you-go, create a key under API Key management and check your balance and model activation. Never paste a key into chat. Agent J users enter it on the phone key card; standalone OpenCode users set the environment variable securely on their own computer.
Switch with Agent J
Ask the Agent to connect OpenCode to Volcano Ark Agent Plan. It runs:
agentj agent switch opencode --preset ark --plan agent
For an existing Coding Plan, use:
agentj agent switch opencode --preset ark --plan coding
For pay-as-you-go, use:
agentj agent switch opencode --preset ark --plan payg
Agent J checks OpenCode, requests a phone key card when needed, writes the provider settings and makes a real call through OpenCode. It switches only after success; a failed check keeps your original tool and rolls back settings added by this attempt. If OpenCode is already selected, it explains how to change only the model. See Enter secrets on your phone.
Configure OpenCode yourself
Merge these fields into ~/.config/opencode/opencode.json, preserving other providers and settings. This is JSON configuration, not a terminal command. The example uses OpenAI-compatible Chat Completions. The official Ark OpenCode guide also documents a Responses setup with @ai-sdk/openai; keep the two provider configurations separate.
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"ark-agent-plan": {
"npm": "@ai-sdk/openai-compatible",
"name": "Volcano Ark Agent Plan",
"options": {
"baseURL": "https://ark.cn-beijing.volces.com/api/plan/v3",
"apiKey": "{env:ARK_AGENT_PLAN_API_KEY}"
},
"models": {
"doubao-seed-2.1-pro": {
"name": "Doubao Seed 2.1 Pro",
"modalities": { "input": ["text", "image"], "output": ["text"] }
}
}
}
},
"model": "ark-agent-plan/doubao-seed-2.1-pro"
}
The process running OpenCode must actually inherit ARK_AGENT_PLAN_API_KEY. Setting a variable in a terminal does not update an already running Agent J service. Agent J users should use its key card and restart the service when instructed. Keep real keys out of JSON, scripts and version control.
Restart OpenCode and select ark-agent-plan/doubao-seed-2.1-pro. For a quick check, ask it to reply only OK. A normal response without authentication or model errors confirms the call works. A model calling itself Doubao does not prove which model served the request.
Standalone OpenCode users can check in a terminal where the environment variable is already set:
opencode run --model ark-agent-plan/doubao-seed-2.1-pro "Reply only OK"
Pitfalls in /connect
Searching for Volc Engine in /connect may show Coding Plan or the ordinary Volc Engine provider. Neither label means it fits your Agent Plan key. Coding Plan uses /api/coding/v3; ordinary pay-as-you-go uses /api/v3; Agent Plan needs /api/plan/v3.
Even a built-in Agent Plan option needs the correct model ID and URL. The built-in catalogue changes with OpenCode versions and model-directory updates; a display name alone is insufficient. For The requested model does not support the agent plan feature, check that the requested model belongs to your plan and uses its plan ID, then check the URL. That error alone does not establish that the URL is wrong.
The custom ark-agent-plan configuration above pins both fields explicitly and avoids mixing dated pay-as-you-go IDs with plan IDs. You can keep the built-in provider; explicitly select the custom model for this call.
Models and screenshots
Get doubao-seed-2.1-pro working first, then choose another model using the Ark plan model guidance. The plan ID doubao-seed-2.1-pro and pay-as-you-go ID doubao-seed-2-1-pro-260915 are different. Do not interchange dots, hyphens or date suffixes.
For screenshots or browser automation, both the model and the OpenCode configuration must accept image input. Model availability and subscription tiers change; check your current console before switching.
The official arkcli
arkcli is Volcano Ark's official command-line tool. It manages Ark resources and subscriptions and can call models; its helper configures tools such as OpenCode. It is useful for checking plans, models and usage or diagnosing Ark configuration. A model-calling command alone does not replace an interactive coding tool.
Agent J currently runs Ark conversations through OpenCode or Claude Code and writes its own provider settings. It detects arkcli's version, but does not expose arkcli as a switchable main tool or invoke its helper automatically. Installing arkcli is not required for Agent Plan. See the official Ark documentation.
Common errors
| Symptom | Check first | What to do |
|---|---|---|
The requested model does not support the agent plan feature | Plan model ID, subscription tier and baseURL | Start with /api/plan/v3 and doubao-seed-2.1-pro, without a dated pay-as-you-go ID; check the current plan model list |
401 / 403 | Key's plan and environment inherited by the real process | Use the dedicated Agent Plan key; check variable presence without printing it, then restart the actual service |
Model missing or ModelNotFound | Built-in provider selected by mistake, model spelling | Explicitly choose ark-agent-plan/doubao-seed-2.1-pro; pay-as-you-go models may also need activation |
429 or quota exhausted | Plan usage, concurrency and rate limits | Check the console, wait for quota refresh or reduce concurrency; avoid repeated retries |
| Balance charged separately | /api/v3 and a pay-as-you-go key selected | Restore the plan URL and key; the console is authoritative for billing |
| Terminal works, Agent J fails | Service environment | Use the phone key card, restart the service when instructed and check again |
| Screenshots unavailable | Model capability and modalities.input | Choose an image-capable model and declare image input |
When Agent Plan and Coding Plan are mismatched, Agent J offers to retry with the other plan only after confirming it works. It reuses the locally saved key and switches only after a successful check. A different existing target key or custom configuration is not overwritten.
Switch back
Ask the Agent to switch back to Claude Code, or run:
agentj agent switch --undo