DeepSeek Harness Fee and Balance Plugin

Introduction

When running multi-turn conversations with DeepSeek Harness, you often need to know the token consumption of a single reply, the cumulative cost, and your account balance. This is especially true in time-tiered billing scenarios (peak/off-peak), where it’s hard to grasp the real cost without manual calculation. Below we introduce dsh-burn, a plugin for the DeepSeek Harness Web UI that provides session-level token consumption tracking, peak/off-peak pricing, and balance queries.

Plugin Overview

  • Plugin name: dsh-burn
  • Maintainer: yishan
  • Type: Client
  • GitHub: https://github.com/yishan/dsh-burn
  • Directory page: https://www.skillhub.cn/plugins/yishan/dsh-burn

The plugin folds session logs via the host service, buckets tokens by model and billing tier, and displays real-time costs and balance in the conversation header and the action bar of each reply through the Web client — no manual calculation required.

Core Features

  1. Per-reply real-time cost

Each settled assistant message displays ↑in · ↓out ¥cost to the right of the action bar (Copy / Like / Share). The cost is calculated based on the billing tier corresponding to the reply’s generation time and the real-time price table.

  1. Cumulative cost and balance in the conversation header

In Standard mode, the right side of the conversation header displays Cumulative ¥xx · Balance ¥xx. The cumulative amount is folded from the session snapshot in real time (updated on each reply settle); the balance is fetched by calling the DeepSeek /user/balance endpoint (60-second cache by default, deduplicated by timestamp).

  1. Settings panel (Cost)
  • Modify prices for each model (official price table built in by default)
  • Select display tier: auto / peak / offPeak / average
  • Load the official price table or define custom peak/off-peak windows
  • After switching tiers, the entire conversation history is re-priced under the new tier

Billing rules follow DeepSeek’s per-reply-generation-time model: weekdays 09:00–12:00 and 14:00–18:00 are peak; all other times are off-peak (half price); weekends are off-peak all day (2026-08-23 rule). auto and average compute a time-weighted cost based on the actual tier breakdown, while peak / offPeak lock to a fixed tier for manual verification.

Installation & Activation

The plugin is a bundle: dsh plugin add mounts it automatically — no manual patching required.

Install from GitHub:

dsh plugin --profile web add github:yishan/dsh-burn
dsh web   # Restart the Web service to apply the configuration

Install from npm (available after publication):

dsh plugin --profile web add dsh-burn
dsh web

Install from a local directory:

dsh plugin --profile web add /path/to/dsh-burn
dsh web

Configuration

Zero-config by default: on startup, the built-in official price table is auto-populated (deepseek-v4-flash / deepseek-v4-pro). All settings can be edited in real time under Settings → Cost and are persisted to the per-profile config file (<profileDir>/plugins/dsh-burn/settings.json). The balance reading requires credentials resolved from DEEPSEEK_API_KEY to call the DeepSeek API.

Advanced: override via profile patch:

# $DSH_HOME/profiles/web/cordis.patch.yml
- id: dsh-burn
  config:
    displayMode: auto          # auto | peak | offPeak | average
    tierSchedule: default      # default | custom
    customWindows: []          # [{ start: 540, end: 720, tier: 'peak' }, ...]
    defaultTier: offPeak       # Default tier for uncovered windows
    prices:
      deepseek-v4-flash:
        peak:    { input: 3.0, cacheRead: 0.1,  cacheWrite: 3.0, output: 9.0 }
        offPeak: { input: 1.5, cacheRead: 0.05, cacheWrite: 1.5, output: 4.5 }
      deepseek-v4-pro:
        peak:    { input: 9.0, cacheRead: 0.3,  cacheWrite: 9.0, output: 27.0 }
        offPeak: { input: 4.5, cacheRead: 0.15, cacheWrite: 4.5, output: 13.5 }
    defaultPrice:
      peak:    { input: 3.0, cacheRead: 0.1,  cacheWrite: 3.0, output: 9.0 }
      offPeak: { input: 1.5, cacheRead: 0.05, cacheWrite: 1.5, output: 4.5 }
    apiKeyEnv: DEEPSEEK_API_KEY
    balanceRefreshMs: 60000
    balanceBaseURL: 'https://api.deepseek.com'

Price units are CNY per million tokens. cacheWrite is used to mirror providers that do not bill cache writes separately.

How It Works

  • Host (src/index.ts, src/projection.ts): The CostMeter service folds session logs, buckets tokens by model and billing tier, provides GET/POST /api/cost/settings endpoints, and proxies GET /api/cost/balance (credential seam, 401/502 handling, 60s cache). The projected totalCost is computed in real time based on the current price table and display tier; switching tiers re-prices the entire history.
  • Client (src/client/): Injects display in three slots — cumulative cost and balance in the conversation header, per-reply cost in the action bar, and the settings page. Prices and tiers are computed at render time against the current price table; no restart needed. Session folding is incrementally appended (O(Δ)), and each message is queried in O(1) via an index.
  • Configuration is persisted to the per-profile settings file and overrides profile config on startup; models not in the price table are auto-filled from the official price table.

Development & Compatibility

Development environment:

pnpm install
pnpm run typecheck   # tsc --noEmit
pnpm run test        # vitest
pnpm run build       # esbuild: lib/index.js + lib/client.js

The client is a classic script, registered via window.__ModuleLoader__, and imports only from the platform module table.

Compatibility declaration (package.json):

Target Declared range Verification
Node.js ^22.19.0 || >=24.0.0 Verified on Node 22.22.2 (macOS arm64)
DSH version 0.1.1-rc.2: compatible Disposable-profile install/uninstall + live web-profile startup + HTTP 200

Compatible with DSH 0.1.0-rc.7 and above; other DSH versions require per-version verification.

Use Cases & Notes

Ideal for DSH Web UI users who need fine-grained cost control and balance monitoring, especially in time-tiered billing scenarios. The plugin runs inside the DSH process; the host reads and writes its own config file; the client uses no browser storage; network calls are limited to the balance endpoint. It is recommended to review the source code and license before installing.

Conclusion

dsh-burn surfaces cost and balance information directly in the DeepSeek Harness Web UI through session-level token projection and real-time price tables, making it easy to audit costs by tier and time window. Directory page: https://www.skillhub.cn/plugins/yishan/dsh-burn; GitHub: https://github.com/yishan/dsh-burn.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye