CC Switch
通过 CC Switch 将 Claude Code、Codex、OpenCode、OpenClaw 接入 Trinity。用 trinity-config 生成 Deep Link 导入,或在 CC Switch 中手动添加自定义供应商。
获取 API Key
- 在 控制台 · API 密钥 创建 Key(
xh-...)。 - 见 管理 API 密钥。
- 安装 CC Switch,并已安装对应 CLI / App。
模型 ID 见 模型广场。
快速配置
--type ccswitch 必须带 --app(支持 claude / codex / opencode / openclaw,可逗号多选)。命令会生成 ccswitch:// Deep Link;在 CC Switch 确认导入后,到对应 App 页签启用 Trinity。
同一工具请只选一种配置方式:直连或 CC Switch。
bash
npx -y trinity-config@latest --type ccswitch --app claude -k xh-你的key --model claude-sonnet-4-6
npx -y trinity-config@latest --type ccswitch --app codex -k xh-你的key --model gpt-5.4
npx -y trinity-config@latest --type ccswitch --app opencode -k xh-你的key --model gpt-5.4
npx -y trinity-config@latest --type ccswitch --app openclaw -k xh-你的key --model gpt-5.4
npx -y trinity-config@latest --type ccswitch --app claude,codex -k xh-你的key直连 Trinity 时关闭该供应商的 本地路由 / Needs Local Routing。端点约定:
| App | Endpoint | 协议要点 |
|---|---|---|
| Claude | https://api.trinitydesk.ai(不带 /v1) | Anthropic Messages |
| Codex | https://api.trinitydesk.ai/v1 | Responses(wire_api = responses) |
| OpenCode / OpenClaw | 按所选模型协议:Anthropic 不带 /v1,Responses / Completions 带 /v1 | 由 trinity-config 按模型能力写入 |
手动配置
导入后确认
- CC Switch 弹出导入时确认接受 Trinity 供应商。
- 打开对应 App 页签(Claude / Codex / OpenCode / OpenClaw),启用名称类似
Trinity的供应商。 - 确认该供应商 本地路由 / Needs Local Routing 为关闭(直连 Trinity)。
- 重启对应 CLI / App 后发送短任务验收。
手动添加自定义供应商
在 CC Switch 主界面选择目标 App → 添加供应商 → 自定义,按下列字段填写并保存,再启用。
| 字段 | Claude | Codex |
|---|---|---|
| 供应商名称 | Trinity | Trinity |
| API Key | xh-... | xh-... |
| 请求地址 / 端点 | https://api.trinitydesk.ai(不带 /v1) | https://api.trinitydesk.ai/v1 |
| 本地路由 / Needs Local Routing | 关闭 | 关闭 |
| 模型 | 模型广场 模型 ID,如 claude-sonnet-4-6 | 模型 ID,如 gpt-5.4;对齐 Responses |
OpenCode / OpenClaw 同样添加自定义供应商:API Key 填 xh-...,模型 ID 来自 模型广场,Endpoint 按上表协议规则填写(与 trinity-config 生成结果一致即可)。
故障排查
| 问题 | 排查 |
|---|---|
| 401 Unauthorized | 确认 API Key 以 xh- 开头且未过期 |
| 403 model_not_allowed | 在控制台确认 Key 有该模型的调用权限 |
| 连接超时 | 确认各 App 的 Endpoint 正确(Claude 不带 /v1,其余带 /v1) |
| 导入后不生效 | 确认已启用 Trinity 供应商且关闭本地路由 |
WARNING
不要将 API Key 提交到 Git 仓库。使用环境变量或配置文件管理 Key,定期轮换。