Tracks DeepSeek Harness LLM token usage and cost (CNY, peak/off-peak pricing) with a settings dashboard, agent tools, HTTP API and persistent storage.
Install
# from npm (prebuilt)
dsh plugin --profile web add @angelyeye/dsh-cost-tracker
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:Angelyeye/dsh-cost-tracker
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
DSH Cost Tracker
LLM usage and cost tracking for DeepSeek Harness
Track every LLM call in DSH: tokens, estimated cost, subscription usage and account balances. Explore the data in a dashboard, ask an Agent in chat, or optionally aggregate several machines through your own cloud service.
Quick start · Screenshots · Changelog
What you get
| Capability | What it does |
|---|---|
| Automatic accounting | Records input, output, cache tokens and request counts, grouped by day, model, device and Agent. |
| Price matching | Supports peak/off-peak pricing, subscription equivalents, official price sync and a multi-vendor catalog. |
| Dashboard | Shows overview cards, cost charts, model details and a token-usage heatmap. |
| Plans and balances | Tracks Kimi Coding Plan, Volcengine Coding Plan and supported account balances. |
| Agent and API access | Ask about cost, prices, peak periods, imports or sync status in chat, or call the local HTTP API. |
| Multi-machine and privacy | Stores data locally by default, with optional self-hosted sync and credentials usually managed by DSH. |
Screenshots
The UI can vary with the DSH host and plugin version. These screenshots show the main information layout.
Quick start
You need an existing dsh web setup. The package declares dsh >= 0.1.0-rc.1; if your host does not expose the plugin marketplace, use the manual installation method in the expandable section below.
1. Install
dsh plugin --profile web add @angelyeye/dsh-cost-tracker
You can also open Settings → Plugin Marketplace in DSH and search for dsh-cost-tracker.
2. Restart and refresh
Restart dsh web when prompted, then refresh the browser page.
3. Verify
- Open Settings → Cost Tracker and confirm the dashboard is visible.
- Confirm that the cost status bar appears below the chat input.
- Ask the Agent, “How much did I spend today?” and verify that it returns a result.
Manual installation:
mkdir -p ~/.dsh/profiles/node_modules/@angelyeye
git clone https://github.com/Angelyeye/dsh-cost-tracker.git ~/.dsh/profiles/node_modules/@angelyeye/dsh-cost-tracker
Append this entry to the top-level array in ~/.dsh/profiles/web/cordis.patch.yml:
- insert:
- id: dsh-cost-tracker
name: "@angelyeye/dsh-cost-tracker"
Then restart:
dsh web
For development, use the official link workflow so the profile does not reinstall an older package on the next startup:
dsh plugin --profile web add link:/path/to/dsh-cost-tracker
When migrating from the old unscoped package dsh-cost-tracker, remove its loader entry and old directory before installing @angelyeye/dsh-cost-tracker. If the source version is v1.7.0, upgrade directly to v1.7.1 or later; reinstalling v1.7.0 does not fix its client registration defect. Usage data lives in a separate storage file and is not removed by changing the installation method.
How it works
- Capture calls: read model, token and subscription information from DSH LLM calls.
- Match prices: apply provider, model, time-window, subscription and custom-catalog rules.
- Store and aggregate: write local details and daily rollups by default; optionally upload idempotent batches to your own cloud service.
Common tasks
Dashboard
Open Settings → Cost Tracker. The dashboard has a time-range selector (today / last 7 days / last 14 days / last 30 days / all); cost, request counts and tokens on the cards follow the selected range, with the all-time total shown separately beneath them. Charts and detail tables use the same range. Today's and month-to-date cost, balance, model details and the token heatmap are shown as well. The dashboard supports local / local + cloud / cloud only scopes.
Ask in chat
The plugin exposes these Agent tools:
| Tool | Example |
|---|---|
cost_stats |
“How much did I spend today?” “What is the total across all machines?” |
cost_prices |
“What price is being used for this model?” |
cost_peak |
“Is it peak or off-peak right now?” |
cost_recompute |
“Recheck historical records with the current pricing rules.” |
cost_import |
“Import usage from sessions before the plugin was installed.” |
cost_sync |
“Is cloud sync healthy? Sync now.” |
cost_reset |
“Clear all usage statistics.” |
Export
Use Data and display in the settings page to export CSV files containing detail records and daily rollups for Excel, Numbers or other analysis tools.
How data is stored
- Default data file:
~/.dsh/storages/cost-tracker-records.json. - Override the storage location with
DSH_HOMEorDSH_COST_TRACKER_STORE. - Detailed records are retained for 180 days; older data is folded into permanent daily rollups so all-time totals remain accurate.
- Cloud sync is optional. When enabled, the plugin uploads the token, cost, timestamp and identifier fields needed for aggregation, with optional session-id masking.
- Cloud tokens and Volcengine
SecretAccessKeyvalues are normally stored through DSH credentials; older hosts or a read-only credential store may retain an existing configured value and report that state. - The local HTTP API listens on loopback. Do not expose the DSH service port directly to the public internet.
Open Settings → Cost Tracker → the gear button in the page header.
Available settings include:
- Peak/off-peak timeline, transition reminders, system notifications and display switches.
- Kimi Coding Plan, Volcengine Coding Plan and supported subscription quotas.
- Self-hosted cloud URL, device name, shared token, sync interval, session masking and default scope.
- Official price checks, the multi-vendor catalog, exchange rates, matching mode and manual overrides.
- History import, cost recomputation, data reset and CSV export.
docs/provider-pricing.json contains the multi-vendor catalog shipped with the package. Pricing and billing eras change over time; use the settings page and cost_prices for the active rules.
The API is local POST + JSON. Common endpoints include:
/api/cost-tracker/summary
/api/cost-tracker/dashboard
/api/cost-tracker/usage
/api/cost-tracker/peak
/api/cost-tracker/sync
/api/cost-tracker/sync-now
/api/cost-tracker/sync-test
/api/cost-tracker/cloud
/api/cost-tracker/balance
/api/cost-tracker/prices
/api/cost-tracker/recompute
/api/cost-tracker/import-status
/api/cost-tracker/import-run
/api/cost-tracker/export
Example:
curl -X POST http://127.0.0.1:3080/api/cost-tracker/summary -d '{}'
The 3080 value above is only an example. Replace it with the port used by your dsh web instance.
Multi-machine aggregation uses the separate self-hosted dsh-cost-cloud service; its ingest contract is documented in INGEST-API.md. The plugin works without it for local tracking; once configured, several devices can share local, local-plus-cloud or cloud-only views, with device and Agent breakdowns.
Configure it at Settings → Cost Tracker → the gear button → Multi-machine aggregation (cloud sync).
FAQ
No. Records are persisted locally and restored on startup. Temporary Windows file locks are retried automatically. If the problem persists, check that only one DSH instance is running.
No. It estimates what those calls would have cost at usage-based rates and helps evaluate a plan. The provider’s bill remains authoritative.
The plugin calculates locally from its price catalog and each record timestamp. Provider price changes, tiered pricing or different billing scopes can create differences. Use the official bill for exact charges.
For marketplace installs, use Settings → Plugin Marketplace. For manual installs, remove the dsh-cost-tracker loader entry and then delete the plugin directory if needed. A client-only update usually needs a hard browser refresh; host-side changes require restarting dsh web.
Development
npm install
npm test
The test suite covers storage, pricing, plans, cloud sync, import, configuration and client rendering.
Related files
CHANGELOG.md: complete release history.docs/provider-pricing.json: bundled multi-vendor pricing catalog.docs/THIRD-PARTY-NOTICES.md: third-party works and data sources.package.json: package metadata, host compatibility and scripts.
License
Links
More in this category
bowenliang123/dsh-context★ 5566
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★ 765
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★ 291
Tracks DeepSeek token usage, per-call and session costs, and account balance with cache-aware charge animations in the DSH Web UI.
zh667/TokenLedger★ 206
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★ 192
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★ 114
Personal center for DeepSeek Harness: cross-session usage statistics with per-provider and per-model breakdown (auto-discovers configured models), per-model cost estimation, global custom instructions, 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.