yflmq001/dsh-cost-tracker
DeepSeek Harness 的令牌成本追踪
项目介绍Project Overview
dsh-cost-tracker 是 DeepSeek Harness 的插件,按每百万 token 的可配置表对每次 LLM 调用计费,支持缓存命中/未命中、输出及高峰时段费率。它向 Web UI 发布 session 级 cost 投影,并提供 /cost 命令查看跨会话账单。需要按模型手动填入价格;无条目的模型会以"未配置"占位标出,避免静默漏算。注意需用 id 而非 name 覆盖配置层,且部分适配器缺 usage 时无法计费。
dsh-cost-tracker is a DeepSeek Harness plugin that prices each finalized LLM call against a per-model table you configure manually (in units per million tokens), covering cache-hit/miss input, output, and optional peak-window rates. It registers a session-level cost projection surfaced in the Web UI, plus a /cost command for the cross-session global bill. Use it to monitor token spend across models and time windows. Caveat: unknown models show as "unconfigured" with no guessed default, and overrides must target the row by id, not name.
请帮我了解并安装插件:【dsh-cost-tracker】【https://github.com/yflmq001/dsh-cost-tracker】
把上面这条消息直接发给当前会话里的 DSH,让它帮你了解并安装。安装命令不一定准确,发给 DSH 更稳。Send this message to DSH in your current session. CLI install commands may not be accurate across systems — DSH will figure it out for you.
或使用命令行安装(适合开发者)Or use CLI install (for developers)
命令行安装CLI Install
dsh plugin --profile web add github:yflmq001/dsh-cost-tracker
把 yflmq001/dsh-cost-tracker 加入你的 DSH 配置(web profile)即可启用。
READMEREADME
dsh-cost-tracker
🇨🇳 中文说明
Token cost tracking for DeepSeek Harness, with per-model configurable pricing and peak/off-peak rates.
![]()
What it does
- Prices every finalized LLM call (
assistant/messageusage) against a per-model pricing table you configure — cache-hit / cache-miss input, output, and optional peak-window rates. - Publishes a per-session
costprojection (total / peak / off-peak / per-model), consumed by the Web UI to show a live session cost readout. - Flags calls that land in a configured peak window.
- Models without a pricing entry are surfaced as "unconfigured" with a placeholder, so you know to add them.
Installation
Install into a dsh profile straight from GitHub — the plugin ships a
dsh.bundle layer, so dsh plugin add enables it automatically:
dsh plugin --profile web add github:yflmq001/dsh-cost-tracker
Pricing starts empty (models: {}); fill in your models under the plugin's
config (see below). To override defaults, add a cost-tracker row to the
profile's own cordis.patch.yml — later layers win by row id.
⚠️ When overriding, address the row by its
id(cost-tracker), not byname. Cordis non-insert patches locate the target line byid; aname-keyed override row is silently dropped, leaving prices atmodels: {}.
The cross-session bill persists through dsh's storage domain; a profile without a storage backend keeps the bill in memory only.
Configuration
Pricing lives under the plugin's config (Schemastery-validated). All prices are currency units per million tokens; you fill them in manually (no scraping).
- id: cost-tracker
config:
models:
deepseek-v4-flash:
inputMiss: 1.0 # cache-miss input
inputHit: 0.02 # cache-hit input (omit if no cache tier)
output: 2.0
peak: # peak tier: hours + toggle + prices
hours: ["09:00-12:00", "14:00-18:00"] # Beijing time
enabled: true # false = peak off (base rates always); omit = on
inputMiss: 3.0
inputHit: 0.10
output: 9.0
gpt-4o: # any model the harness can reach
inputMiss: 2.5
output: 10.0
Session projection
The plugin registers the cost projection:
{
totalCost, peakCost, offpeakCost,
callCount, unconfiguredCalls, unconfiguredModels,
byModel: { [model]: { inputHit, inputMiss, output, total } },
}
Cache writes are priced at the miss rate (providers bill the write at the miss tier; the written tokens become cache hits on a later call).
Billing correctness
Two choices keep the numbers honest:
- Cache writes are billed at the miss rate, not the hit rate. Providers charge cache writes at the cache-miss input tier (e.g. DeepSeek $0.14/M vs $0.0028/M hit) — pricing a write as a hit undercounts by ~50x whenever a session writes fresh context. Some cost plugins fold cache writes into the hit bucket; this plugin does not.
- Unknown models are never silently priced. A model with no pricing entry is surfaced as "unconfigured" with a placeholder in the projection and UI, so a guessed default can't hide in your bill. You add the price, or you see the gap.
Known Limitations and Deferred Work
- Per-session cost is a projection over the durable log (replayed); the
cross-session global bill and
/costcommand are available. - Non-DeepSeek models need their pricing filled in manually; there is no automatic price lookup.
- Developer preview:
assistant/message.usageis absent when the adapter reports no accounting, and the session format has no compatibility promise.
MeteorNOX/DeepSeek-Balance-Whale-Widget
Han-1413141/dsh-cost-meter
zh667/TokenLedger
wssfk12138/dsh-damage-pulse
Ychris12138/dsh-usage-stats
yxxbc/dsh-balance-plugin
multica-ai/dsh-multica-runtime