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 会自动探测远端模型,无需手动全部配置。但手动配置可以指定上下文窗口大小和模态能力,使用体验更稳定。

相关推荐
文章永久免费只为良心10 小时前
Ctfshow_Web应用安全与防护_第二章_无字母数字命令执行
前端·python·安全·网络安全·渗透测试·ctf·红队渗透测试
小羊没烦恼!10 小时前
在.net中读写config文件的各种方法
java·大数据·运维·服务器·前端·数据库·oracle
@PHARAOH10 小时前
WHAT - Vite 8(Rolldown 底层构建引擎升级)
前端·架构
阿Q的AI笔记10 小时前
从ReAct到GRPO、从OpenHands到SWE-agent:Agent完整知识体系全拆解
前端·react.js·前端框架
计算机魔术师10 小时前
从六个月路线图到JIT规划:代码评审不只是审代码
前端
迅猛龙办公室10 小时前
Python实现PM空气质量提醒
服务器·前端·python
鬼手点金11 小时前
模型即 Agent:当模型本身成为产品
开发语言·前端·人工智能·python·机器学习
kiracrimson12 小时前
npm 入门:包管理器、依赖与 npx
前端·npm·node.js