1.4f Claude Code 中转
第三方中转(Claude Code 兼容)
学完你能做什么
- 配置一个独立 provider 把中转接到 OpenCode
- 配置 API Key
- 在 /models 里选择模型并发一句话验证
跟我做
第 1 步:在 opencode.json 配置一个独立 provider
编辑 ~/.config/opencode/opencode.json,添加一个自定义 provider:
jsonc
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"claudecode-relay": {
"npm": "@ai-sdk/anthropic",
"options": {
"baseURL": "https://url.com/v1",
"apiKey": "你的API Key"
},
"models": {
"claude-opus-4-5-20251101": {
"name": "中转站的 opus 4.5",
"limit": {
"context": 200000,
"output": 64000
}
}
}
}
}
}第 2 步:选择模型并验证
启动 OpenCode:
bash
opencode输入:/models
选择 claudecode-relay/claude-opus-4-5-20251101,然后发送一句话验证。
检查点
- [ ] /models 里能看到 claudecode-relay/... 并成功选择
- [ ] 发送消息能收到 AI 回复
踩坑提醒
| 现象 | 原因 | 解决 |
|---|---|---|
| 404 / Not Found | baseURL 写错了 | 优先检查 baseURL 是否应该是 .../v1 |
| 401 / Unauthorized | Key 无效/没权限 | 重新生成 Key |
下一步
回到 1.4 总览 选择下一条路线。

