OpenCode
在 OpenCode 里同时接入 ApiRuna 的 Claude 和 GPT 模型。
只在当前页面内使用,刷新即清空,不会上传。填入后本页命令中的 YOUR_API_KEY 会被替换。
1. 安装 OpenCode
需要先装好 Node.js 18+,步骤见 Claude Code(终端) 第 1 步。然后执行:
npm install -g opencode-aiopencode --version2. 创建配置文件
配置文件位于 ~/.config/opencode/opencode.json。先创建目录:
macOS / Linux
mkdir -p ~/.config/opencodeWindows PowerShell
New-Item -ItemType Directory -Path "$env:USERPROFILE\.config\opencode" -Force | Out-Null然后用任意编辑器新建 opencode.json,写入以下内容。已有同名文件时,先备份再覆盖:
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"model": "apiruna-anthropic/claude-sonnet-5-5",
"provider": {
"apiruna-anthropic": {
"npm": "@ai-sdk/anthropic",
"name": "ApiRuna Anthropic",
"options": {
"baseURL": "https://api.apiruna.ai/v1",
"apiKey": "YOUR_API_KEY"
},
"models": {
"claude-opus-5-5": { "name": "Opus 5.5", "tool_call": true, "reasoning": true },
"claude-sonnet-5-5": { "name": "Sonnet 5.5", "tool_call": true, "reasoning": true },
"claude-haiku-5-5": { "name": "Haiku 5.5", "tool_call": true }
}
},
"apiruna-openai": {
"npm": "@ai-sdk/openai",
"name": "ApiRuna OpenAI",
"options": {
"baseURL": "https://api.apiruna.ai/v1",
"apiKey": "YOUR_API_KEY"
},
"models": {
"gpt-6.2-sol": { "name": "GPT-6.2 Sol", "tool_call": true, "reasoning": true }
}
}
}
}3. 验证安装
在项目目录里运行:
opencode输入 /models 选择 ApiRuna 下的模型,发送「你好」。能正常回复并在 使用记录 里看到调用,即配置成功。
更新于 2026 年 11 月 24 日