Token usage and cost tracking with daily/session budget alerts and a usage_report tool.
Install
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:DamonKoy/dsh-plugins#path:/packages/dsh-usage-cost
Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).
README
Usage and cost tracking plugin for DeepSeek Harness, inspired by Codex 0.144's "usage limit" credits reminder: watch every model call and keep a running token/cost tally, with warnings before the budget runs out.
English | 中文
What it does
- Stream-level usage accounting: hooks the
llm/streamwaterfall and accumulatesinputTokens,outputTokens,cacheReadTokens,cacheWriteTokens,reasoningTokensfrom everyusagechunk without buffering or altering the stream; one call counts once. - Per-model cost estimation: prices each call in USD from a built-in
table (DeepSeek: $0.28/M in, $0.42/M out, $0.028/M cache read, $0.42/M
cache write; others: $2/M in, $8/M out), overridable per
provider/modelkey in the config. - Per-turn settlement: on
agent/turn-stopping, usage accumulated since the last settlement is appended (deltas only) to~/.dsh/dsh-usage-cost/stats.json, bucketed by date and by model. - Budget warnings: with
dailyBudgetUsd/sessionBudgetUsdset, crossing the threshold logs once per date and once per session:[dsh-usage-cost] 今日用量超预算/本次会话用量超预算. usage_reportmodel tool: read-only report of today, the current session, the per-model breakdown and the budget state (dailyExceeded/sessionExceededflags).- Package-private RPC:
usage-cost/statusreturns the same report.
Install
dsh plugin --profile web add github:DamonKoy/dsh-plugins#path:/packages/dsh-usage-cost
Restart dsh web. Active by default, records usage with no config.
Config
Optional file ~/.dsh/dsh-usage-cost.json:
{
"prices": {
"deepseek-official/deepseek-v4-flash": {
"inputPerM": 0.28,
"outputPerM": 0.42,
"cacheReadPerM": 0.028,
"cacheWritePerM": 0.42
}
},
"dailyBudgetUsd": 2,
"sessionBudgetUsd": 0.5
}
| Field | Default | Meaning |
|---|---|---|
prices |
{} |
Per-model overrides in USD per 1M tokens, keyed by provider/model |
dailyBudgetUsd |
unset | Warn when today's cost exceeds this |
sessionBudgetUsd |
unset | Warn when this process's cost exceeds this |
Config is re-read on every use, so edits apply without a restart.
Stats file
Written synchronously at every turn settlement (small file, no races); costs are estimates from the price table, not provider invoices:
{
"byDate": {
"2026-08-16": { "calls": 3, "inputTokens": 1200, "outputTokens": 800, "costUsd": 0.00068 }
},
"byModel": {
"deepseek-official/deepseek-v4-flash": { "calls": 3, "inputTokens": 1200, "outputTokens": 800, "costUsd": 0.00068 }
}
}
Notes
- Session tally is in-memory for the process lifetime; the daily file is the durable record.
- The
llm/streamlistener callsnext()first and only reads chunk fields; stream, options and chunks are never modified. - Warnings fire once per date and once per session to avoid log spam.
- Prices and budgets are user-side estimates; adjust them to your billing.
License
MIT
Links
More in this category
bowenliang123/dsh-context★ 1791
DSH context insight panel: Context dashboard + /context command + Context browser — one-stop context lifecycle management with categorized composition, content details, evolution trends, compaction/injection events, and stats.
Han-1413141/dsh-cost-meter★ 361
Per-session and daily API cost, budget with usage %, official balance, history dashboard, and one-click official price sync with peak/off-peak pricing.
wssfk12138/dsh-damage-pulse★ 237
Tracks DeepSeek token usage, per-call and session costs, and account balance with cache-aware charge animations in the DSH Web UI.
zh667/TokenLedger★ 202
Sidebar usage panel that attributes tokens to the relay site that served each request, read from your existing provider config: today/month/all-time totals, per-site and per-model breakdowns, a year activity heatmap, and New API / Sub2API / DeepSeek balances.
Ychris12138/dsh-usage-stats★ 167
Multi-provider usage dashboard with provider/model token breakdowns, calendar drill-downs, account balances, and OpenCode Go / Z.ai subscription quota tracking.
PolinniZhong/dsh-personal-center★ 118
Personal center for DeepSeek Harness: cross-session usage statistics, per-model cost estimation, global custom instructions, a global font-size adjuster, a data-driven desktop pet with bitmap & vector skins, and a conversation status overview, all local and offline.
Community comments
Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.