@tokenzero/cli

中文文档
0.2.13发布于 2026/11/03Apache-2.0ES Module零依赖

TokenZero CLI: connect a project to the TokenZero BYOK gateway, audit LLM token waste locally, check usage and verify signed savings receipts.

原始使用文档

@tokenzero/cli

Command line for TokenZero: audit LLM token waste in a project, connect it to the TokenZero bring-your-own-key gateway, check usage, and verify signed savings receipts.

npx -y @tokenzero/cli audit                    # local static audit; nothing is uploaded
npx -y @tokenzero/cli audit --json
npx -y @tokenzero/cli audit --fail-over 30     # CI gate: exit 1 above 30% recoverable
git diff origin/main | npx -y @tokenzero/cli audit --diff - --format markdown

Audits are static heuristics: they read code, not traffic, and report estimates at list prices. Library and SDK repositories are detected and their findings downgraded.

Connecting to the gateway

These commands talk to the hosted gateway at https://tokenzero.sh. To use another deployment, pass --url or set TOKENZERO_URL.

npx -y @tokenzero/cli init        # audit, create a workspace, write base URLs to .env (asks first)
npx -y @tokenzero/cli usage       # routed spend vs the free tier, savings
npx -y @tokenzero/cli verify <request_id>   # check a receipt's Ed25519 signature locally
npx -y @tokenzero/cli rotate-key  # new workspace key; rewrites it in .env

Authentication. Send your workspace key as the X-TokenZero-Key header; this is the recommended form. Your provider key is sent exactly as you would send it to the provider and passes through untouched. For setups where you cannot add headers, init can embed the workspace key in the base URL (<gateway>/w/<key>/v1). Treat such URLs as secrets, and run rotate-key if one leaks into logs.

Node >= 18. Single file, no dependencies. Apache-2.0.

版本与发布记录

@tokenzero/cli 共发布 22 个版本,首次发布于 2026/10/26;过去 12 个月发布了 22 个版本。

版本发布日期距今
0.2.13latest2026/11/03今天
0.2.122026/11/021 天前
0.2.112026/11/012 天前
0.2.102026/11/012 天前
0.2.92026/10/295 天前
0.2.82026/10/286 天前

关于 @tokenzero/cli 的常见问题

@tokenzero/cli 是什么?

TokenZero CLI:将项目连接到TokenZero BYOK网关,在本地审计LLM令牌浪费,检查使用情况并验证签名的储蓄收据。

如何安装 @tokenzero/cli?

在项目目录运行 npm install @tokenzero/cli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 tokenzero,可以用 npx tokenzero 直接运行。

@tokenzero/cli 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/tokenzero__cli 是否存在。

@tokenzero/cli 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@tokenzero/cli 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@tokenzero/cli 可以商用吗?

@tokenzero/cli 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@tokenzero/cli 还在维护吗?

最新版本 0.2.13 发布于 2026/11/03(今天);至今共发布 22 个版本,其中过去 12 个月发布了 22 个;首次发布于 2026/10/26。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。