ShriD5/claude-mods/tree/main/chai-meter
chai-meter
一个 Claude Code 插件,在状态行中显示会话成本计量器(以美元和杯装奶茶为单位),并带有一个 /chai 命令,该命令按令牌类型和轮次细分成本,跟踪会话和所有时间总计。
关于这个 mod
chai-meter 是一个 Claude Code 插件,它将状态行变成一个会话成本的计价器,以美元和杯装奶茶的形式显示。当请求发出和响应流式传输时,计价器会实时更新,然后在响应结束时根据实际使用情况稳定下来,与 Claude Code 自己的成本账本保持一致。/chai 命令会打印一个细目,包括按模型定价的输入、输出、缓存写入和缓存读取令牌,最昂贵的轮次,以及会话和所有时间总计。会话总计在重新加载时保留在 $.state 中,所有时间总计在会话之间保留在 $.store 中。
安装通过 claude --plugin-dir ./chai-meter 或通过将仓库添加为市场并通过 /plugin 安装。选项包括 chaiPriceInr(每杯奶茶的卢比价格,默认为 20)、usdToInr(默认为 84)以及用于按模型定价的 priceOverrides。内置价格位于 hooks/prices.ts 中,是 Anthropic API 列表价格;没有行的模型按 Opus 5.5 费率定价,如 /chai 所述。
从机制上讲,流式 turn.step 钩子会估算传入的响应(先前请求的输入成本加上每个输出令牌大约四个字符),然后从表中添加响应的实际使用成本。每个 session.measure 将基础设置为 Claude Code 自己的 cost.usd,而 turn.start 和 turn.complete 则按轮次分配成本,以便 /chai 可以识别最昂贵的一个。
安装
请先查看作者 README 确认 marketplace 和插件名称;命令可能随仓库结构改变。
claude plugin marketplace add ShriD5/claude-mods claude plugin install chai-meter
原文 / README
chai-meter
A taxi meter for your Claude Code session, in the status line:
☕ $0.42 · ≈ 1.8 chai
The meter jumps when a request goes out and ticks up while the response streams. When the response ends, it settles on the real usage. After each turn it lines up with Claude Code's own cost ledger.
/chai prints the breakdown:
☕ This session: $0.74 ≈ 3.1 chai (₹62 at ₹20 a cup, $1 = ₹84)
input 1,500 tokens $0.01
output 32,000 tokens $0.64
cache write 10,000 tokens $0.05
cache read 200,000 tokens $0.04
Priced with the table in hooks/prices.ts.
Priciest turn: $0.64, "now rewrite the whole billing module in Rust ple…"
All time: $10.74 ≈ 45 chai
The session total is kept in $.state, so a reload doesn't reset it. The all-time total is kept in $.store and carries across sessions.
Install
claude --plugin-dir ./chai-meter
or add this repo as a marketplace and install it with /plugin.
Options
| Option | Default | What it does |
| --- | --- | --- |
| chaiPriceInr | 20 | Rupees per cup of chai. |
| usdToInr | 84 | Rupees per US dollar. |
| priceOverrides | "" | JSON of model id to [input, output, cache write, cache read] dollars per million tokens, e.g. {"claude-opus-5-5": [4, 20, 5, 0.2]}. Rows you leave out keep the built-in prices. |
The built-in prices live in hooks/prices.ts, one row per model. They are Anthropic API list prices as of 2026-09-25, so update them when prices change. Wherever Claude Code keeps a cost ledger, the session total comes from that ledger. The table only prices the live tick and the per-kind and per-turn rows. A model with no row is priced at Opus 5.5 rates, and /chai says so.
How it works
A streaming turn.step hook estimates the response as it arrives: the previous request's input cost, plus about four characters per output token. It then adds the response's real usage, priced from the table. Each session.measure sets the base to Claude Code's own cost.usd. turn.start and turn.complete attribute cost to each turn so /chai can name the priciest one.

