DSH Cost Banner

August 23, 2026 · View on GitHub

Live DeepSeek API cost + peak/off-peak phase with a live countdown to the next price change, in a single banner in the DSH web UI.

license

dsh-cost-banner in the DSH web UI

Live capture from the DSH web UI. Values are illustrative — the banner reflects your own usage.

Why

If you run DeepSeek in the DeepSeek Harness (DSH), you have no idea what an interactive session actually costs — until the invoice lands. This plugin puts a tiny banner at the top of the DSH web UI that shows:

  • Today / 7d / 30d / last week / last month cost (USD),
  • the current peak / off-peak phase,
  • a live 1-second countdown to the next price change (clock shown in your timezone, default IST),
  • tokens in / out, and your DeepSeek API balance.

It reads DSH's own per-request token logs and prices them with DeepSeek's published peak/off-peak rates, so the numbers update as you work.

DeepSeek API cost · Today \$2.74 · 7d \$3.57 · 30d \$3.57 · Last wk \$0.00 · Last mo \$0.00 · ⏱ Off-peak → Peak at 06:30 IST · in 4h 12m 08s · In 2.1M / 66M cache · Out 1.2M · src: DSH (est.) · clock IST · APA bal USD 14.91

Install

The plugin runs as a DSH host-plane cordis plugin. Add it to your profile's patch file (~/.dsh/profiles/web/cordis.patch.yml) as an id-targeted override (insert would create a duplicate plugin id and fail to boot):

# ~/.dsh/profiles/web/cordis.patch.yml
- id: cost-banner
  name: ./src/plugin.mjs
  config:
    endpoint: /api/dsh-cost
    # sessionsRoot: /path/to/your/dsh/sessions
    # pricingFile:  /path/to/cost-pricing.json
    # apiKeyEnv:    DEEPSEEK_API_KEY
    # displayTimezone: IST

Then restart dsh web. The banner appears on the next page load.

Requires zstd on the host to decompress session logs (brew install zstd).

Configuration

OptionDefaultPurpose
endpoint/api/dsh-costURL that serves the cost JSON, and the banner taps the HTML for it
sessionsRoot~/.dsh/sessionsWhere DSH writes session.jsonl.zstd logs
pricingFile~/.dsh/cost-pricing.jsonDeepSeek rates (see below)
apiKeyEnvDEEPSEEK_API_KEYEnv var holding the DeepSeek key (for balance chip). Never hardcoded.
displayTimezoneISTClock timezone for the countdown target
darkautoAdd the dark class for dark themes

How it works

  1. Cost = per-request token usage (inputTokens, cacheReadTokens, cacheWriteTokens, outputTokens) from DSH session logs, priced with DeepSeek's peak/off-peak rates from cost-pricing.json. The 7d/30d/prev-week/ prev-month windows overlap, so a request can appear in several.
  2. Peak/off-peak classification uses DeepSeek's actual billing windows (01:00–04:00 & 06:00–10:00 UTC, plus weekend-whole-day off-peak in Beijing time). Only the display clock is converted to your timezone — the classification is never shifted, so the cost stays aligned with your real bill.
  3. The countdown scans forward to the first minute the phase flips (robust across daily windows and the weekend rule) and ticks locally every second.

Disclaimer

This is an estimate, not an invoice. DeepSeek's public API exposes only GET /user/balance — there is no per-period usage endpoint — so the figures are a good-faith token-based estimate from your session logs. Treat them as a close guide, not a billing statement. If it ever looks off, update the rates in cost-pricing.json.

Pricing

Rates are copied from DeepSeek's pricing page and are user-editable (cost-pricing.json). They can drift — update them when DeepSeek changes rates (there's a fetched date at the top of the file).

License

MIT — free to use, modify and redistribute. If it saves you money, a star is the only thanks that costs you nothing.

Support

Built and tested against DSH as of 2026-08. DSH internals can change; the plugin isolates the DSH-specific surfaces in one module (src/pricing.mjs) so a version bump is usually a one-liner. If a DSH update breaks it, open an issue — or better, a PR.


⭐ If this saved you API spend, drop a star.