Install any skill in seconds. Free to start, no credit card required.
Get Started Free →在已经过独立验证的 CLIProxyAPI upstream 之上部署 NewAPI 计费层,把 Codex/Claude/Gemini/Qwen 等订阅账号包装成可计费的 OpenAI 兼容 API。本 Skill 不负责新建裸 CLIProxyAPI;负责 NewAPI Docker 部署、容器到宿主桥接、模型计费倍率、参数化额度修正、多账号 OAuth 凭据热加载和双路径验证。当用户说“给现有 cliproxy 加 NewAPI”“配置 NewAPI 渠道接已运行的 cliproxy”“NewAPI 价格不对”“给现有部署加账号”“172.17.0.1 容器网络”或“408 冷却放大故障”时触发。
.claude/skills/majiayu000-cliproxy-newapi-stack/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-08 | ✗→✓ | ▲ Improved | 173% | 0% |
| case-04 | ✗→✓ | ▲ Improved | 251% | 0% |
| case-06 | ✗→✓ | ▲ Improved | 99% | 0% |
| case-10 | ✗→✓ | ▲ Improved | 98% | 0% |
| case-12 | ✗→✓ | ▲ Improved | 97% | 0% |
在用户已有并已验证的 CLIProxyAPI upstream 前增加 NewAPI (calciumion/new-api) 计费、限流和多用户 token 层。本 Skill 不安装裸 CLIProxyAPI,也不调用其他部署 Skill 补齐这个前置条件。
所有"完成"结论必须基于本会话命令输出(W-16)。价格和额度变更后必须真发一次请求并查 logs.quota 与本次请求的 token 数和目标价格相符。
root@HOST 是否能免密CLIPROXY_PORT(默认 8317)、NEWAPI_PORT(默认 8200)SSH tunnel 或 loopback 请求验证健康、模型列表和认证;证据不足就停止,不猜测、 不自动安装裸 upstream
codex / claude / qwen / iflow / geminiBASE_URL 环境变量安全默认:本地 OAuth + scp 同步;NewAPI 仅绑定 VPS loopback,通过 SSH tunnel 完成首次注册。公网访问必须走已配置 TLS 的反向代理,不能直接开放 NewAPI 原始 HTTP 端口。
先记录现有服务的进程、监听地址、健康响应、模型列表和配置备份位置。任何一项 无法验证都停止。只有用户在当前消息批准修改这个既有 upstream 时,才执行以下 两个补丁:
/root/CLIProxyAPI/config.yaml:yaml disable-cooling: true 原因见 references/troubleshooting.md "CLIProxyAPI cooldown 原理"。 若漏改,30 并发 5KB payload 会出现混合 ~50% 503。
ip -4 addr show docker0 确认 Docker bridge 地址,再把 host 绑定到该地址(常见值为 172.17.0.1)ufw allow <CLIPROXY_PORT>/tcp;管理访问统一走 SSH tunnel,不保留公网 admin 后门bashIMAGE='calciumion/new-api@sha256:<VERIFIED_DIGEST>' \ SSH_TARGET=root@<HOST> SSH_KEY=~/.ssh/id_ed25519 PORT=8200 \ scripts/deploy_newapi.sh
脚本只绑定远端 127.0.0.1:8200。首次注册前保持防火墙关闭该端口,建立 SSH tunnel:
bashssh -N -L 8200:127.0.0.1:8200 -i <KEY> <SSH_TARGET>
仅访问本机 http://127.0.0.1:8200 完成 root 账号注册,并把密码保存到密码 管理器。注册和登录验证成功后,再配置带 TLS 的 Caddy/Nginx 反向代理;先 验证 HTTPS、认证和来源限制,再按需开放 443/tcp。禁止开放 <NEWAPI_PORT>。
NewAPI 后台 → "渠道" → 新建 → OpenAI 类型:
http://172.17.0.1:<CLIPROXY_PORT>⚠️ 不能写 127.0.0.1 — 容器里的 127.0.0.1 是容器自己。详见 references/troubleshooting.md "容器网络速记"。
cpa_xxx keygpt-5.4,gpt-5.3-codex,gpt-5.3-codex-spark,gpt-5.4-mini,gpt-5.2
references/troubleshooting.md。NewAPI 后台 → "令牌" → 新建:
client-default 之类标识unlimited 或一个大数(实际计费由 user.quota 控制)sk-xxx(这是客户端的 BASE_API_KEY)用 scripts/set_pricing.py(基于实测 USD/1M 自动算出三个倍率):
bashSSH_TARGET=root@<HOST> SSH_KEY=~/.ssh/id_ed25519 \ scripts/set_pricing.py \ --model gpt-5.4 --input 2.5 --cached 0.25 --output 15 \ --model gpt-5.3-codex --input 1.75 --cached 0.175 --output 14
脚本会:合并写入 options 表的 ModelRatio / CacheRatio / CompletionRatio,重启容器。
⚠️ 倍率语义见 references/newapi-pricing.md —— CacheRatio / CompletionRatio 是相对 输入价的倍数,不是绝对单价。ModelRatio 在不同 fork 里可能除以 2,第一次配置务必发请求 看 logs.quota 实际值匹配预期。
NewAPI 在线充值通常未配。需要紧急修正额度时,可使用参数化 SQLite helper:
bashSSH_TARGET=root@<HOST> SSH_KEY=~/.ssh/id_ed25519 \ scripts/topup.sh <user_id> <quota> # 例:1 1000000000 → 1B quota ≈ USD 2000 (默认 QuotaPerUnit=500000)
如果要让用户自助充值,NewAPI 后台 → 系统 → 支付:
TopUpLink 等字段scripts/topup.sh;输入必须为整数,脚本会参数化 SQL 并验证恰好更新一行只把非敏感配置写入客户端 shell 配置:
bashexport BASE_URL="https://<NEWAPI_DOMAIN>/v1" export BASE_MODEL="<虚拟模型名>" # 如 gpt-5.4
API key 必须存进 Keychain 或其他密码管理器,在当前进程启动前读取;禁止写入 ~/.zshrc、聊天、脚本或命令行参数。例如 macOS 可使用:
bashexport BASE_API_KEY="$(security find-generic-password -s newapi-client -a client-default -w)"
跨多台机器同步时(W-14 文件归属):单台单台手动 SSH 改各自的 rc 文件,避免并行写覆盖。
不需要重启服务,CLIProxyAPI 有 file watcher。
最简单:
bashPROVIDER=codex \ SSH_TARGET=root@<HOST> SSH_KEY=~/.ssh/id_ed25519 \ CLIPROXY_LOCAL=<本地 CLIProxyAPI 仓库路径> \ scripts/add_codex_account.sh
脚本流程:
go run ./cmd/server -<provider>-login -config config.yaml覆盖回去)
~/.cli-proxy-api/<provider>-*.json,把新文件 scp 到 VPSauth file changed (CREATE)详见 references/multi-account.md(含订阅条件、轮询语义、删除账号、验证方法)。
bashSSH_TARGET=root@<HOST> SSH_KEY=~/.ssh/id_ed25519 \ CLIPROXY_URL=http://127.0.0.1:<TUNNELED_CLIPROXY_PORT> \ NEWAPI_URL=https://<NEWAPI_DOMAIN> \ CLIPROXY_KEY="$(security find-generic-password -s cliproxy-admin -w)" \ NEWAPI_TOKEN="$(security find-generic-password -s newapi-client -a client-default -w)" \ MODEL=<虚拟模型> INPUT_USD_PER_M=<输入价> OUTPUT_USD_PER_M=<输出价> \ QUOTA_PER_UNIT=500000 \ scripts/verify_stack.sh
通过判定:
logs 中对应 request_id、模型和 token 数匹配本次请求quota 与目标输入/输出价格计算结果的误差不超过 5%(且至少允许 1 quota 的整数舍入)任一不满足都不得声称"部署完成"。
| 文件 | 用途 | |---|---| | scripts/deploy_newapi.sh | NewAPI 容器一键部署 + 健康自检 | | scripts/set_pricing.py | 用 USD/1M 三参数自动写 NewAPI ratios | | scripts/topup.sh | 直接 SQLite 改 users.quota | | scripts/verify_stack.sh | 双路径 + 计费日志验证 | | scripts/add_codex_account.sh | OAuth 登录 + 同步凭据 + watcher 校验 | | agents/openai.yaml | 需要独立复核高风险部署或计费方案时的 agent 配置 | | references/newapi-pricing.md | ModelRatio / CacheRatio / CompletionRatio / QuotaPerUnit 完整语义 + 计算示例 | | references/troubleshooting.md | 容器网络、cooldown、PUT 不生效、UFW 等踩坑表 | | references/multi-account.md | 多账号轮询语义 + 加号 / 删号 / 订阅条件 |
http://127.0.0.1:<port>(容器内自指)CacheRatio 当绝对单价(实际是相对输入的倍数)/api/option/ PUT 不验证(已知该接口可能静默失败)cpa_ key 和 NewAPI 的 sk- token 共享给同一类客户端logs.quotadisable-cooling: true 的情况下做高并发压测| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-02 | fail→fail | 5,306 | 8,125 | +53% | 1 | 1 | 0% | 394 | 3,537 | +798% | 0 | 0 | — |
case-01 | fail→fail | 11,520 | 9,443 | -18% | 1 | 1 | 0% | 402 | 3,838 | +855% | 0 | 0 | — |
case-08 | fail→pass | 10,094 | 7,871 | -22% | 1 | 1 | 0% | 1,559 | 4,254 | +173% | 0 | 0 | — |
case-03 | fail→fail | 22,950 | 8,894 | -61% | 1 | 1 | 0% | 4,103 | 4,613 | +12% | 0 | 0 | — |
case-04 | fail→pass | 20,219 | 3,712 | -82% | 1 | 1 | 0% | 1,027 | 3,607 | +251% | 0 | 0 | — |
case-05 | pass→pass | 10,558 | 6,761 | -36% | 1 | 1 | 0% | 1,865 | 4,243 | +128% | 0 | 0 | — |
case-06 | fail→pass | 10,737 | 4,501 | -58% | 1 | 1 | 0% | 1,917 | 3,810 | +99% | 0 | 0 | — |
case-07 | pass→pass | 7,969 | 5,907 | -26% | 1 | 1 | 0% | 1,423 | 4,143 | +191% | 0 | 0 | — |
case-09 | pass→pass | 10,523 | 7,336 | -30% | 1 | 1 | 0% | 1,923 | 4,093 | +113% | 0 | 0 | — |
case-10 | fail→pass | 12,885 | 8,015 | -38% | 1 | 1 | 0% | 2,177 | 4,301 | +98% | 0 | 0 | — |
case-11 | fail→fail | 14,766 | 2,868 | -81% | 1 | 1 | 0% | 2,019 | 3,385 | +68% | 0 | 0 | — |
case-12 | fail→pass | 13,119 | 5,890 | -55% | 1 | 1 | 0% | 2,007 | 3,962 | +97% | 0 | 0 | — |
case-13 | fail→fail | 9,785 | 7,702 | -21% | 1 | 1 | 0% | 1,730 | 4,437 | +156% | 0 | 0 | — |
case-14 | fail→pass | 12,065 | 8,247 | -32% | 1 | 1 | 0% | 1,967 | 4,315 | +119% | 0 | 0 | — |
case-15 | fail→pass | 10,020 | 6,533 | -35% | 1 | 1 | 0% | 1,477 | 4,089 | +177% | 0 | 0 | — |
case-16 | fail→pass | 10,294 | 5,054 | -51% | 1 | 1 | 0% | 1,644 | 3,840 | +134% | 0 | 0 | — |
case-17 | fail→fail | 6,432 | 5,148 | -20% | 1 | 1 | 0% | 970 | 3,396 | +250% | 0 | 0 | — |
case-22 | pass→pass | 8,148 | 5,373 | -34% | 1 | 1 | 0% | 1,227 | 3,446 | +181% | 0 | 0 | — |
case-18 | fail→pass | 6,838 | 4,197 | -39% | 1 | 1 | 0% | 1,128 | 3,564 | +216% | 0 | 0 | — |
case-19 | fail→pass | 12,140 | 8,452 | -30% | 1 | 1 | 0% | 2,349 | 4,274 | +82% | 0 | 0 | — |
case-20 | fail→fail | 16,292 | 11,339 | -30% | 1 | 1 | 0% | 3,085 | 4,804 | +56% | 0 | 0 | — |
case-21 | fail→fail | 14,525 | 9,184 | -37% | 1 | 1 | 0% | 2,598 | 4,348 | +67% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted, and 19 counted toward the lift figure. The other 3 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +45 percentage points is the difference between those two pass rates over the 19 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.