Skip to content

CC Switch

通过 CC Switch 将 Claude Code、Codex、OpenCode、OpenClaw 接入 Trinity。用 trinity-config 生成 Deep Link 导入,或在 CC Switch 中手动添加自定义供应商。


获取 API Key

  1. 控制台 · API 密钥 创建 Key(xh-...)。
  2. 管理 API 密钥
  3. 安装 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。端点约定:

AppEndpoint协议要点
Claudehttps://api.trinitydesk.ai(不带 /v1Anthropic Messages
Codexhttps://api.trinitydesk.ai/v1Responses(wire_api = responses
OpenCode / OpenClaw按所选模型协议:Anthropic 不带 /v1,Responses / Completions 带 /v1trinity-config 按模型能力写入

手动配置

导入后确认

  1. CC Switch 弹出导入时确认接受 Trinity 供应商。
  2. 打开对应 App 页签(Claude / Codex / OpenCode / OpenClaw),启用名称类似 Trinity 的供应商。
  3. 确认该供应商 本地路由 / Needs Local Routing 为关闭(直连 Trinity)。
  4. 重启对应 CLI / App 后发送短任务验收。

手动添加自定义供应商

在 CC Switch 主界面选择目标 App → 添加供应商 → 自定义,按下列字段填写并保存,再启用。

字段ClaudeCodex
供应商名称TrinityTrinity
API Keyxh-...xh-...
请求地址 / 端点https://api.trinitydesk.ai(不带 /v1https://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,定期轮换。

© Trinity AI