Real-time DeepSeek API balance (official endpoint) and today-spend estimate (this DSH instance session-log usage x per-model price table) for the DSH web: composer dock strip, always-on floating badge, full settings dashboard (7-day trend, per-model cost, editable price table and polling, history rescan). The API key never leaves the host.
Install
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:xtd1145/dsh-deepseek-cost-live
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
A DeepSeek Harness (DSH) Web plugin showing real-time DeepSeek API account balance (official endpoint) and today's spend (local estimate). Community open-source plugin built on the official
@deepseek-ai/*runtime APIs; it never modifies DSH sources.
Features
- Real-time balance (official): calls
GET https://api.deepseek.com/user/balanceon a configurable interval; on failure it keeps the last good snapshot and marks the UI stale. The API key is resolved only inside the host process — never logged, never sent to the browser, never accepted from request parameters. - Today's spend (estimate): listens to this DSH instance's session log, folds each model request's exact usage (cache-hit input / cache-miss input / output / reasoning tokens) through a per-model price table (CNY per 1M tokens). DeepSeek has no billing-history API, so daily spend is a local estimate, not a bill.
- Three surfaces (all enabled):
- composer dock strip under the input: balance + today spend + manual refresh;
- bottom-right always-on floating badge (collapsible, remembered in localStorage);
- a full settings dashboard: balance detail, today / last-7-days tokens and cost, cost by model, price table / timezone / polling config, history rescan.
- Bilingual zh/en. Only the official DeepSeek route is counted by default (provider
deepseek-official; extend in config and hit "Rescan history" to backfill).
Install
dsh plugin --profile web add <this repo path or dsh-deepseek-cost-live.tgz>
or manually: copy lib/ cordis.patch.yml package.json into $DSH_HOME/profiles/web/node_modules/dsh-deepseek-cost-live, add "dsh-deepseek-cost-live" to dsh.profile.bundles in the profile's package.json, then restart the web service and check:
powershell -NoProfile -ExecutionPolicy Bypass -File $env:USERPROFILE.dsh
estart-dsh-web.ps1
Invoke-WebRequest -Uri 'http://127.0.0.1:3080/dsh-deepseek-cost-live/stats' -UseBasicParsing
Open the Web UI (hard-refresh once) — floating badge and dock strip appear; Settings → "Usage & Balance" opens the dashboard.
API key resolution (priority)
apiKeyin the plugin config file$DSH_HOME/dsh-deepseek-cost-live/config.json(admin-written, never sent to the browser);- environment variable (default
DEEPSEEK_API_KEY, override withapiKeyEnv); - DSH credentials file
$DSH_HOME/.credentials.yaml→refs.<apiKeyEnv>; - the official
ctx.credentialsservice (dynamic import).
Spend semantics & price table
- cost per request = cacheHit×hit + cacheMiss×miss + (output+reasoning)×output (CNY per 1M tokens).
- Defaults mirror DeepSeek's published list prices (
lib/core/pricing.js); verify per model on the pricing page — models without a row usedefault. - On first install, past sessions are background-scanned a few seconds after boot; live requests are folded in near-real-time (~15 s persist cadence; a crash loses at most a small delta, rebuilt by the next scan).
Files under $DSH_HOME
| Path | Purpose |
|---|---|
dsh-deepseek-cost-live/ledger.json |
folded usage rows (dedup by sessionId:seq, keep keepDays) |
dsh-deepseek-cost-live/config.json |
timezone/providers/polling/price table |
dsh-deepseek-cost-live/balance.json |
last successful balance snapshot (survives restarts) |
HTTP routes (loopback-trusted only)
GET /dsh-deepseek-cost-live/stats, POST /dsh-deepseek-cost-live/refresh, GET|POST /dsh-deepseek-cost-live/config, POST /dsh-deepseek-cost-live/scan. The API key is never accepted or returned over any route.
Development
node testsday.test.mjs ; node testsold-stats.test.mjs
License
MIT
Links
More in this category
bowenliang123/dsh-context★ 3724
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★ 556
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★ 276
Tracks DeepSeek token usage, per-call and session costs, and account balance with cache-aware charge animations in the DSH Web UI.
zh667/TokenLedger★ 199
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★ 186
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, 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.