ClaudeMods
☰
ZH-TW
● 0 人在線上 · 瀏覽 0 次
贊助提交作品
GitHub 儲存庫 · 發布者 ShriD5

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.

更多類似作品