OpenCode 接入
1. 前提条件
- 已注册并获取本平台 API Key。已登录的话,到接入中心选 OpenCode,复制已填好 Key 和模型的一条命令,在终端运行即可,可跳过第 2 步的三步选择。
- 已安装 Node.js 环境。
- 已安装 OpenCode:bash
curl -fsSL https://opencode.ai/install | bash
2. 推荐方式:使用 codesw 一键配置
codesw 会直接写入 ~/.config/opencode/opencode.json,自动填好 provider、baseURL、apiKey 与模型列表,不做任何代理或中转。
2.1 安装
bash
npm i -g @bumocc/codesw
# 或
yarn global add @bumocc/codesw2.2 运行交互模式
直接执行:
bash
codesw按提示用方向键选择、回车确认,三步完成:
- 要配置哪个客户端:选择
OpenCode。 - 使用哪个供应商:选择
Bumo Router。首次使用时粘贴您在 API Keys 页面获取的 Key(输入时以*显示),之后会自动复用。 - 使用哪个模型:推荐模型排在最前,例如
claude-sonnet-5-5;也可选「手动输入模型 ID…」。
完成后直接运行 opencode 即可。codesw 写完配置会用这把 Key 和模型自动测一次连通:Key 无效、模型不存在、余额不足会分别提示怎么改;之后随时可以运行 codesw test 复测。
3. 启动
bash
opencode附:手动配置(备选)
打开 ~/.config/opencode/opencode.json,在对应字段增加以下配置:
json
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"router.bumo.ai": {
"npm": "@ai-sdk/openai-compatible",
"name": "router.bumo.ai",
"options": {
"baseURL": "https://router.bumo.ai/v1",
"apiKey": "YOUR_API_KEY"
},
"models": {
"claude-sonnet-4-6": {
"name": "claude-sonnet-4-6"
},
"gpt-5.3-codex": {
"name": "gpt-5.3-codex"
}
}
}
}
}请将
YOUR_API_KEY替换为您的平台 API Key。
