SuperAPI AI Directory

cpa-codex-free

Deployment & operations

View repository

Updated 10-15 09:47

About this skill

Skill Description

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。

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"

Check authentication files

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}'

Query remaining quota

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>" } }'

Clean up temporary files

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 timeout
  • EOF / unexpected EOF
  • context canceled

Can be cleaned up (clearly invalid)

  • usage_limit_reached
  • invalid auth
  • revoked
  • malformed token