OpenCode 手动配置火山方舟 Agent Plan 教程

1.1 什么是 Agent Plan

Agent Plan 是火山方舟推出的智能体套餐,面向通用 Agent 场景,提供多模型聚合调用能力。一个 API Key 即可调用豆包、DeepSeek、Kimi、智谱、MiniMax 等多家主流模型。

接口地址(OpenAI 兼容 v3):

bash 复制代码
https://ark.cn-beijing.volces.com/api/plan/v3

1.2 准备工作

  • 已注册火山方舟账号并开通 Agent Plan
  • 已获取 Agent Plan API Key(格式:ark-xxxxxxxx
  • 已安装 OpenCode

1.3 找到配置文件

OpenCode 全局配置文件位置:

系统 路径
Windows %USERPROFILE%\.config\opencode\opencode.json
macOS / Linux ~/.config/opencode/opencode.json

如果文件不存在,可手动创建。

1.4 编辑配置文件

provider 节点下添加 volcengine-agent-plan 配置项,完整结构如下:

json 复制代码
{
  "model": "volcengine-agent-plan/doubao-seed-2.1-turbo",
  "provider": {
    "volcengine-agent-plan": {
      "name": "Volcano Engine (Agent Plan)",
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "apiKey": "你的AgentPlan-APIKey",
        "baseURL": "https://ark.cn-beijing.volces.com/api/plan/v3"
      },
      "models": {
        "doubao-seed-2.1-turbo": {
          "name": "doubao-seed-2-1-turbo-260628",
          "limit": {
            "context": 256000,
            "output": 4096
          },
          "modalities": {
            "input": ["text", "image"],
            "output": ["text"]
          }
        },
        "doubao-seed-2.0-pro": {
          "name": "doubao-seed-2.0-pro",
          "limit": {
            "context": 256000,
            "output": 4096
          },
          "modalities": {
            "input": ["text", "image"],
            "output": ["text"]
          }
        },
        "doubao-seed-2.0-lite": {
          "name": "doubao-seed-2.0-lite",
          "limit": {
            "context": 256000,
            "output": 4096
          },
          "modalities": {
            "input": ["text", "image"],
            "output": ["text"]
          }
        },
        "doubao-seed-2.0-code": {
          "name": "doubao-seed-2.0-code",
          "limit": {
            "context": 256000,
            "output": 4096
          },
          "modalities": {
            "input": ["text", "image"],
            "output": ["text"]
          }
        },
        "doubao-seed-code": {
          "name": "doubao-seed-code",
          "limit": {
            "context": 256000,
            "output": 4096
          },
          "modalities": {
            "input": ["text", "image"],
            "output": ["text"]
          }
        },
        "ark-code-latest": {
          "name": "ark-code-latest",
          "limit": {
            "context": 256000,
            "output": 4096
          },
          "modalities": {
            "input": ["text", "image"],
            "output": ["text"]
          }
        },
        "deepseek-v3.2": {
          "name": "deepseek-v3.2",
          "limit": {
            "context": 128000,
            "output": 4096
          },
          "modalities": {
            "input": ["text"],
            "output": ["text"]
          }
        },
        "kimi-k2.5": {
          "name": "kimi-k2.5",
          "limit": {
            "context": 256000,
            "output": 4096
          },
          "modalities": {
            "input": ["text", "image"],
            "output": ["text"]
          }
        },
        "kimi-k2.6": {
          "name": "kimi-k2.6",
          "limit": {
            "context": 256000,
            "output": 4096
          },
          "modalities": {
            "input": ["text", "image"],
            "output": ["text"]
          }
        },
        "glm-4.7": {
          "name": "glm-4.7",
          "limit": {
            "context": 200000,
            "output": 4096
          },
          "modalities": {
            "input": ["text"],
            "output": ["text"]
          }
        },
        "glm-5.1": {
          "name": "glm-5.1",
          "limit": {
            "context": 200000,
            "output": 4096
          },
          "modalities": {
            "input": ["text"],
            "output": ["text"]
          }
        },
        "minimax-m2.7": {
          "name": "minimax-m2.7",
          "limit": {
            "context": 200000,
            "output": 4096
          },
          "modalities": {
            "input": ["text"],
            "output": ["text"]
          }
        }
      }
    }
  }
}

关键参数说明:

参数 说明
name Provider 显示名称
npm SDK 包名,OpenAI 兼容协议统一用 @ai-sdk/openai-compatible
options.apiKey 你的 Agent Plan API Key
options.baseURL Agent Plan 接口地址
models 可用模型列表,每个模型需指定名称、上下文限制、模态能力

1.5 验证配置

保存配置后,打开终端执行:

bash 复制代码
opencode models volcengine-agent-plan

如果能看到刚才配置的模型列表,说明配置成功。

1.6 切换模型

方式一:修改默认模型(永久)

编辑 opencode.json,修改顶层 model 字段:

json 复制代码
"model": "volcengine-agent-plan/doubao-seed-2.1-turbo"

方式二:启动时临时指定(单次生效)

bash 复制代码
opencode -m volcengine-agent-plan/doubao-seed-2.0-pro

1.7 常用命令速查

命令 说明
opencode models 列出所有可用模型
opencode models volcengine-agent-plan 列出 Agent Plan 的模型
opencode -m volcengine-agent-plan/doubao-seed-2.1-turbo 临时指定模型启动
opencode 使用默认模型启动

提示 :模型列表可能随官方更新而变化,如果 opencode models 命令显示的模型比配置文件中多,说明 OpenCode 会自动探测远端模型,无需手动全部配置。但手动配置可以指定上下文窗口大小和模态能力,使用体验更稳定。

相关推荐
子兮曰2 天前
jev-ultrafast 深度解析:7 秒订机票的浏览器 Agent 是如何炼成的
前端·后端·agent
子兮曰2 天前
Jev 爆发一周:7 秒 Agent 背后的 System One 生态与三场争议
前端·后端·ai编程
前端小万2 天前
写公众号赚了 3000 块后,我做了一款叫 "一键成稿" 的软件
前端·微信小程序
爱勇宝2 天前
ZCode 开源 24 小时:一份没有历史的账本,回答不了"有没有偷代码"
前端·后端·chatglm (智谱)
三十而立洋2 天前
Cookie 详解:从产生到安全,一次讲透
前端·javascript
卡布鲁2 天前
把一个 Vite + Vue3 应用塞进 qiankun (React + Umi3) 主站:十个坑的复盘
前端·javascript·react.js
汉堡大王95272 天前
Jev:不是聊天机器人, 而是一个智能 if 语句
前端·人工智能·后端
梦想很大很大2 天前
从运行事实到回归证据:Workrun 的 Telemetry 与 Evaluation 实践
前端·人工智能·后端
计算机魔术师2 天前
Meta Muse agent 接入 Shopify 的 Shop Pay 实现代理式购物
前端
沙蒿同学2 天前
我用 Go 搭了一条 AI Agent 流水线:从 1 张商品图到一整套淘宝详情页
前端·javascript·后端