This skill is used to generate authentication files for CLI Proxy API. Please ensure that the openai domain has been routed to a non-China region.
Environment Variables
Obtained first from the workspace under.env, and secondarily from system environment variables. If not configured, request them from the user and update.env。
MAIL_API_KEY: Email service API key, defaults togpt-testthe official test key (200,000 quota per day), obtainable at: https://shop.chatgpt.org.uk/buy/prod_1768420938389CLI_PROXY_API_BASE: CPA Base URLCLI_PROXY_API_MKEY: CPA Management Key
Workflow
# 生成认证文件
uv scripts/main.py > {tempdir}/{temp-name}.json
Upload to CPA service
curl -X POST -H 'Content-Type: application/json'
-H "Authorization: Bearer $CLI_PROXY_API_MKEY"
"$CLI_PROXY_API_BASE/v0/management/auth-files?name=codex-.json"
-d "@{tempdir}/{temp-name}.json"
curl "${CLI_PROXY_API_BASE}/v0/management/auth-files"
-H "Authorization: Bearer ${CLI_PROXY_API_MKEY}"
| jq '.files[] | select(.provider == "codex" and .email == "") | {auth_index, id_token, status}'
curl "$CLI_PROXY_API_BASE/v0/management/api-call"
-H "Authorization: Bearer $CLI_PROXY_API_MKEY"
-H 'Content-Type: application/json'
-d '{
"authIndex":"<auth_index>",
"method":"GET",
"url":"https://chatgpt.com/backend-api/wham/usage",
"header":{
"Authorization":"Bearer $TOKEN$",
"Content-Type":"application/json",
"User-Agent":"codex_cli_rs/0.76.0 (Debian 13.0.0; x86_64) WindowsTerminal",
"Chatgpt-Account-Id":"<chatgpt_account_id>"
}
}'
rm {tempdir}/{temp-name}.json
## 清理流程
```shell
# 获取失效的认证文件列表
curl "${CLI_PROXY_API_BASE}/v0/management/auth-files" \
-H "Authorization: Bearer ${CLI_PROXY_API_MKEY}" \
| jq '.files[] | select(.provider == "codex" and .status == "error") | {name, status_message}'
# 删除认证文件
curl -X DELETE "${CLI_PROXY_API_BASE}/v0/management/auth-files?name=<name.json>" \
-H "Authorization: Bearer ${CLI_PROXY_API_MKEY}"
Cleanup Rules
Only clean upclearly invalidauthentication files.
Do not clean up (network/transient errors)
i/o timeoutEOF/unexpected EOFcontext canceled
Can be cleaned up (clearly invalid)
usage_limit_reachedinvalid authrevokedmalformed token