通过 OAuth 认证使用 OpenAI Codex 服务。
Codex Provider 允许你使用 OpenAI Codex 的 OAuth 凭证访问 GPT 模型,无需 API Key。
credential_pool:
codex:
- id: "codex-main"
token_file: "codex/oauth.json"
disabled: false
proxy_url: "http://proxy:8080" # 可选
| 配置项 | 类型 | 必填 | 说明 |
|---|---|---|---|
| id | string | ✅ | 凭证唯一标识 |
| token_file | string | ✅ | Token 文件路径(相对于 auth_dir) |
| disabled | boolean | ❌ | 是否禁用此凭证 |
| proxy_url | string | ❌ | 单独的代理 URL |
{
"access_token": "eyJ...",
"refresh_token": "eyJ...",
"expires_at": "2025-01-01T00:00:00Z",
"token_type": "Bearer"
}
ProxyCast 会自动在 Token 过期前刷新:
curl http://127.0.0.1:8999/v1/chat/completions \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4",
"messages": [{"role": "user", "content": "Hello!"}]
}'
将 GPT 模型路由到 Codex:
routing:
rules:
- pattern: "gpt-*"
provider: "codex"
priority: 1
credential_pool:
codex:
- id: "codex-1"
token_file: "codex/account1.json"
- id: "codex-2"
token_file: "codex/account2.json"
ProxyCast 会自动在多个凭证之间负载均衡。