dsh-usage-cost

August 15, 2026 · View on GitHub

English · 中文 · 日本語 · Русский · Español · Français

Token usage & cost monitor for DeepSeek Harness. Aggregates token usage across all session logs, computes per-model cost (USD / approx. RMB), and renders a native panel inside Settings — no URL hunting needed.

Usage & Cost panel (English)

Features

  • Cross-session aggregation — scans every session log via ctx.sessionPersistence, tallies per-model input (cache-miss / cache-hit), output, reasoning tokens and call counts.
  • Cost calculation — official DeepSeek pricing page (with built-in fallback table) × usage → cost; live USD→CNY exchange rate.
  • Editable prices — per-model price overrides right in the panel (persisted via settings); every row has save/delete icon buttons.
  • Time windows — all / last 24h / today / last 7d / last 30d.
  • Auto-refresh — selectable interval: off / 1m / 5m / 30m / 1h / 12h (background silent refresh, never blocks).
  • Hit-rate color grading — <60% red · 60–80% yellow · ≥80% green.
  • Localized — the panel follows DSH's own UI language (Chinese / English), no separate switch.
  • Instant reopen — data cached at module level, reopening Settings shows content immediately.

Install

# from npm
dsh plugin --profile web add dsh-usage-cost

# or directly from this repository
dsh plugin --profile web add github:lin-nanxing/dsh-usage-cost

# or local (pnpm required, no dsh CLI needed)
bash scripts/install.sh

Restart dsh web, then open Settings → 用量与费用 in the UI. A standalone page also stays available at http://127.0.0.1:<port>/usage-cost.

Metrics

Six summary cards on top of the panel:

CardMeaning
Total (USD)Billed cost of all calls in USD
Total (≈CNY)USD × live exchange rate
Total tokensInput + cache-hit + cache-miss + output + reasoning
Sessions / CallsSessions with usage / total call count
Avg token priceTotal cost (CNY) ÷ total tokens per 1M (¥/M)
Reasoning shareReasoning ÷ (output + reasoning), share of thinking

Billing formula: miss = input-miss + cache-write; hit = cache-read; out = output + reasoning; cost = miss×miss-price + hit×hit-price + out×out-price.

License

MIT