Introduction

When developing or interacting with DeepSeek Harness (DSH) in daily use, it is crucial to keep real-time track of account balance and model call consumption. This plugin aims to provide that information by displaying balance, model usage, and official peak/off-peak pricing, helping users control costs.

What It Is

dsh-balance-and-cost is a standard client plugin for DeepSeek Harness (DSH).

  • Maintainer: boooooooer
  • Category: Client
  • License: MIT
  • Core value: Displays DeepSeek account balance, model usage, and official time-based pricing.

Core Features

The plugin provides the following capabilities:

  1. Balance lookup
    Queries the balance through the api.deepseek.com/user/balance endpoint and displays total balance / top-ups / free credits / availability status. The endpoint has a 60-second cache.

  2. Usage statistics
    Listens for llm/stream events and accumulates DeepSeek model calls in real time. Statistics are calculated using the official three-category basis (input · cache miss / cache hit / output), distinguishing total usage from current-session usage. Numbers are abbreviated with M/K.

  3. Model-based pricing
    Matches official pricing tables according to the models actually invoked (supports version-suffixed names via prefix matching, e.g., deepseek-v4-pro-0813); models not covered are estimated using deepseek-v4-flash.

  4. Time-based pricing
    Distinguishes peak-hour pricing from off-peak pricing. Peak hours are 9:00-12:00 and 14:00-18:00 Beijing Time; all other hours are off-peak (prices are approximately half of peak pricing).

  5. Session details
    In the Plugin Center, view statistics by model and by session. Each session shows its actual title, total row, and per-model rows.

  6. Three-category hover
    On the homepage summary bar, hover over token numbers to view the three-category breakdown (including the cost for each category); hover over a model name to compare actual consumption for the two main models (flash/pro).

  7. Export details
    Supports one-click CSV export (by model + by session, three-category basis, with BOM so it can be opened directly in Excel).

  8. Reset records
    One-click clearing of all statistics, the balance baseline, and caches, with persistence to disk supported.

  9. Persistence
    Statistics are stored in $DSH_HOME/dsh-balance-and-cost.json and automatically restored after a process restart.

  10. Real-time updates
    SSE is used to push usage changes in real time, refreshing the browser immediately; a 15-second polling interval serves as a fallback for disconnections.

Installation and Enablement

Install the plugin via the command line:

dsh plugin --profile web add github:boooooooer/dsh-balance-and-cost

After installation, restart dsh to load the plugin.

Usage Examples

  • Homepage summary bar: Displayed below the input box: DeepSeek Balance ¥xx.xx CNY · Current Session (model) xx.xM tok ≈¥x.xxx · Total xx.xM tok ≈¥x.xxx · [Peak/Off-Peak]. The model name follows the session’s most recent call, and costs are calculated from plugin installation or record reset.
  • Hover to view: Hover the mouse over token numbers to display the three-category breakdown for input · cache miss / cache hit / output.
  • Plugin Center: Go to “Settings → Plugins” and open the “DeepSeek Usage” tab to view balance details, per-model/per-session statistics, and export CSV.

Notes

  1. Statistics scope: The plugin only counts model calls where the provider contains deepseek (for example, the deepseek-official route).
  2. Cost estimation: Displayed costs are estimates (official unit price × token usage); actual charges are based on DeepSeek billing.
  3. Replay calls: Replayed model calls may be counted multiple times.
  4. Session model display: A session displays the name of the most recently called model, not the currently selected model that has not been called.

Ecosystem Background

DeepSeek Harness (DSH) follows the “everything is a plugin” philosophy. This plugin is maintained by community developers and has no official affiliation with DeepSeek / Huanfang.