cliproxy-newapi-stack

cliproxy-newapi-stack is a skill for Claude Code, Codex from majiayu000/spellbook. It costs 171 tokens per session (3,083 once invoked), scanned C, original, MIT.

A deployment guide for adding NewAPI, a billing and usage-control layer, in front of an already running CLIProxyAPI service. CLIProxyAPI provides an OpenAI-compatible interface to several AI account providers.

In plain words
What is it for?
Connecting NewAPI to CLIProxyAPI, deploying the billing layer with Docker, configuring model prices and quota corrections, loading OAuth credentials, and verifying requests and logs.
Why use it?
It helps expose usage tracking, quotas, pricing, and multiple accounts without treating the existing upstream service as a fresh installation.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/majiayu000/spellbook/cliproxy-newapi-stack
Any agent
npx skills add majiayu000/spellbook --skill cliproxy-newapi-stack
Clone the repo
git clone --depth 1 https://github.com/majiayu000/spellbook

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for cliproxy-newapi-stack

README.md
[![agentmods](https://agentmods.dev/badge/skills/majiayu000/spellbook/cliproxy-newapi-stack.svg)](https://agentmods.dev/skills/majiayu000/spellbook/cliproxy-newapi-stack)
Your own site
<a href="https://agentmods.dev/skills/majiayu000/spellbook/cliproxy-newapi-stack"><img src="https://agentmods.dev/badge/skills/majiayu000/spellbook/cliproxy-newapi-stack.svg" alt="Measured on agentmods" height="20"></a>
Per session 171 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,083 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00171 $0.03083
Opus 5 $0.00086 $0.01541
Sonnet 5 $0.00034 $0.00617
Haiku 4.5 $0.00017 $0.00308

Measured 4d ago against content hash 23ec1657f9df, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade C, and why

cliproxy-newapi-stack scanned grade C with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

The scan reads SKILL.md. This mod also ships 7 executable files (scripts/add_codex_account.sh, scripts/deploy_newapi.sh, scripts/lib/validation.sh, …), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Reaches for credential fileshighPrivilege escalation

SSH keys, cloud credentials, git-credentials, .npmrc, /etc/shadow: reading these is how a config file becomes a credential leak.

SSH_TARGET=root@<HOST> SSH_KEY=~/.ssh/id_ed25519 PORT=8200 \
skills/cliproxy-newapi-stack/SKILL.md · 235 lines

How it starts

The opening of the file, as written. The whole thing — 235 lines — stays where its author put it; the contents beside it link to each section on GitHub.

CLIProxyAPI + NewAPI Metering Stack

在用户已有并已验证的 CLIProxyAPI upstream 前增加 NewAPI (calciumion/new-api) 计费、限流和多用户 token 层。本 Skill 不安装裸 CLIProxyAPI,也不调用其他部署 Skill 补齐这个前置条件。

所有"完成"结论必须基于本会话命令输出(W-16)。价格和额度变更后必须真发一次请求并查 logs.quota 与本次请求的 token 数和目标价格相符。

Operating Contract

  • Direct actions: 只读检查、配置备份和本地 dry-run 可直接执行。
  • Escalate before: 安装容器、修改既有 upstream、重启服务、改防火墙或写生产额度前必须取得本次任务的明确授权。
  • Evidence-backed pushback: 密钥只从环境变量或密码管理器读取;要求明文落盘或公网暴露原始端口时,展示具体风险并改用 tunnel/TLS。
  • Feedback loop: 每次变更后重跑 upstream、NewAPI 和精确计费验证;任一步骤无法取得真实状态时停止并报告,不用默认值伪造成功。

0. 前置确认(必问)

  • SSH 目标root@HOST 是否能免密
  • 端口分配CLIPROXY_PORT(默认 8317)、NEWAPI_PORT(默认 8200
  • upstream 证据:CLIProxyAPI 已在目标主机运行,当前会话能通过用户批准的 SSH tunnel 或 loopback 请求验证健康、模型列表和认证;证据不足就停止,不猜测、 不自动安装裸 upstream
  • 登录账号供应商codex / claude / qwen / iflow / gemini
  • 价格输入格式:每个虚拟模型给我 input / cached / output 三个 USD per 1M 数字
  • 客户端机器:要在哪些机器上落 BASE_URL 环境变量

安全默认:本地 OAuth + scp 同步;NewAPI 仅绑定 VPS loopback,通过 SSH tunnel 完成首次注册。公网访问必须走已配置 TLS 的反向代理,不能直接开放 NewAPI 原始 HTTP 端口。


Phase 1 — 验证现有 CLIProxyAPI upstream

先记录现有服务的进程、监听地址、健康响应、模型列表和配置备份位置。任何一项 无法验证都停止。只有用户在当前消息批准修改这个既有 upstream 时,才执行以下 两个补丁:

  1. 加稳定性开关/root/CLIProxyAPI/config.yaml

    disable-cooling: true
    

    原因见 references/troubleshooting.md "CLIProxyAPI cooldown 原理"。 若漏改,30 并发 5KB payload 会出现混合 ~50% 503。

  2. 不要把 CLIProxyAPI 端口暴露到公网(与裸部署不同):

    • 先用 ip -4 addr show docker0 确认 Docker bridge 地址,再把 host 绑定到该地址(常见值为 172.17.0.1
    • 删除已有的公网 ufw allow <CLIPROXY_PORT>/tcp;管理访问统一走 SSH tunnel,不保留公网 admin 后门

Phase 2 — 部署 NewAPI 容器

IMAGE='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:

ssh -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>

Read the full file on GitHub · 235 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 235 lines · 171 tokens per session scan C 23ec1657f9df

Subscribe to this mod's changes

cliproxy-newapi-stack is a skill published in the GitHub repository majiayu000/spellbook (265 stars, last pushed 4d ago), licensed MIT. It adds 171 tokens to every session and 3,083 once invoked, about $0.0009 per session on Opus 5. A static security scan graded it C with 1 finding (reaches for credential files). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

general-video

The fallback workflow for authoring custom HyperFrames video compositions at any length or format — longer or multi-scene pieces, brand / sizzle reels, montages, title cards, static loops, and freeform compositions. Input- and length-agnostic. If a specialized workflow clearly fits the input — a marketed product, a…

Sma1lboy/rove · 114 tokens

session-scan

Compute metrics for Claude Code sessions. Discovers via ccrider, filters trivial, computes friction/opportunity/fingerprint scores. Use for broad session triage.

oliver-kriska/claude-elixir-phoenix · 36 tokens

vc-autopilot

Emit and validate the provisional goal block for Autopilot Mode. Owns the 9-field format and resume detection from a pasted goal block.

withkynam/vibecode-pro-max-kit · 34 tokens

manage-schemas

Creates, views, edits, deletes, and validates note schemas for the MCP Task Orchestrator in .taskorchestrator/config.yaml — the templates that define which notes agents must fill at each workflow phase. Also recommends schema designs from a library of workflow patterns (autonomous coding loops, spec-driven teams…

jpicklyk/task-orchestrator · 212 tokens

vc-audit-vc

Audit agent harness health: Claude/Codex agent parity, skill registry consistency, README.md sync, and protocol file wiring. Use when agents, skills, README.md, or development-protocol files move, split, or drift.

withkynam/vibecode-pro-max-kit · 52 tokens

lov-env-management

统一管理平台、账号与多组 API Key,维护有效期和启用状态,安全同步到 zsh 或用户会话环境,并提供脱敏 Dashboard;用户说“管理环境变量”“rotate API keys”时使用。.

lovstudio/skills · 53 tokens