Codex CLI
将 Codex CLI 接到 Trinity:使用 xh-... API Key,模型 ID 取自 模型广场。
获取 API Key
- 在 控制台 · API 密钥 创建 Key(
xh-...)。 - 管理与轮换见 管理 API 密钥。
快速配置
bash
npx -y trinity-config@latest --type codex -k xh-你的key --model gpt-5.4写入 ~/.codex/config.toml 与 auth.json。wire_api 为 responses;Base URL(含 /v1):
text
https://api.trinitydesk.ai/v1完成后运行:
bash
codex手动配置
编辑 ~/.codex/config.toml:
toml
model_provider = "trinity"
model = "gpt-5.4"
disable_response_storage = true
[model_providers.trinity]
name = "Trinity"
base_url = "https://api.trinitydesk.ai/v1"
wire_api = "responses"
requires_openai_auth = true模型 ID 须来自 模型广场。
将 Key 写入 ~/.codex/auth.json:
json
{
"OPENAI_API_KEY": "xh-你的key"
}或导出环境变量:
bash
export OPENAI_API_KEY="xh-你的key"配置后运行:
bash
codex故障排查
| 问题 | 排查 |
|---|---|
| 401 Unauthorized | 确认 API Key 以 xh- 开头且未过期 |
| 403 model_not_allowed | 在控制台确认 Key 有该模型的调用权限 |
| 连接超时 | 确认 Base URL 为 https://api.trinitydesk.ai/v1 |
| 模型未找到 | 在 模型广场 核对模型 ID |
WARNING
不要将 API Key 提交到 Git 仓库。使用环境变量或配置文件管理 Key,定期轮换。