~/projects/cctop

可用工具Available tool2026-06-03 更新Updated 2026-06-03

cctop

对账 Claude Code 本地 token 用量与中转站实际扣费的命令行电表。A command-line meter that reconciles Claude Code token usage against what a relay provider actually charges.

PythonSQLiteFastAPICLImacOS
01 / PROBLEM

要解决的问题The problem

使用模型中转服务时,本地 token 消耗与服务商扣费之间缺少可核对的统一账本。With a model relay service, there is no single ledger to check local token consumption against the provider’s actual billing.

02 / APPROACH

实现思路Approach

增量解析本地会话记录,采集中转站余额快照,并反推有效倍率和异常差异。Incrementally parses local session logs, snapshots relay balances and derives the effective multiplier and anomalous gaps.

03 / EVIDENCE

公开证据Public evidence

  • 实现 token 同步、余额快照、倍率校准、报表导出和阈值告警Implements token sync, balance snapshots, multiplier calibration, report export and threshold alerts
  • 使用 SQLite 保存游标、快照与日聚合,支持后台守护进程SQLite stores cursors, snapshots and daily aggregates, with background daemon support
  • CI 覆盖 Python 3.9–3.12,每个版本通过 23 项测试并通过 ruff 检查CI covers Python 3.9–3.12, passing 23 tests and the ruff check on each version
04 / LIMITS

当前限制Current limits

  • 账单准确度依赖中转站接口和价格配置Billing accuracy depends on the relay’s API and price configuration
  • 仓库具备发布工作流,但目前没有 GitHub Release,不能视为已正式发布The repository has a release workflow but no GitHub Release yet, so it is not formally published