zhou-yihang/dsh-usage-blance0

dsh-usage-blance

DSH Web 插件:在对话框下方显示 DeepSeek API 用量与余额(本月消费 / 本月日均 / 昨日消费 / 今日消费 / 账户余额),点击账单行打开控制面板配置 userToken。Billing strip below the chat dialog for the DeepSeek Harness web GUI.

包名
dsh-usage-blance
版本
1.0.1
许可证
MIT
最近更新
2026年8月18日

安装

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:zhou-yihang/dsh-usage-blance

dsh-usage-blance

A plugin for the DeepSeek Harness (DSH) web GUI that monitors your DeepSeek API usage and balance in a billing strip pinned directly below the chat dialog (the conversation.input.dock slot, above the input box).

中文说明见下文。

Features

  • Shows five figures in order: 本月消费 · 本月日均 · 昨日消费 · 今日消费 · 账户余额.
  • Click any billing row to open the control panel: a userToken input with save / clear, the current token status, and step-by-step instructions for finding the token.
  • Balance comes from the official public endpoint GET https://api.deepseek.com/user/balance (authenticated with DEEPSEEK_API_KEY); usage comes from the platform dashboard endpoint https://platform.deepseek.com/api/v0/usage/cost (authenticated with the platform userToken — the official API does not expose usage queries).
  • Auto-refreshes every 60 s plus a manual refresh button; per-row error states (missing key, missing/expired token, network failure) with hover hints.
  • Follows the app's light/dark theme (--dsw-* tokens).
  • Secrets never leave your machine: the browser only talks to local routes registered by the host half.

Install

Requires the DSH CLI and pnpm.

From GitHub


## Configuration

### userToken (usage figures)

The four usage figures need the platform session token. Click any billing row to open the control panel, then:

1. Sign in to [platform.deepseek.com](https://platform.deepseek.com).
2. Press `F12` to open DevTools → **Console**, paste and run:

   ```js
   JSON.parse(localStorage.getItem('userToken')).value

Copy the printed string.

  1. Or: ApplicationLocal Storage → click https://platform.deepseek.com → find the userToken entry and copy its value field.
  2. Paste it into the control panel input and click 保存.

The token is validated immediately and saved to $DSH_HOME/storages/dsh-usage-blance.json (local machine only). When the token expires (e.g. after signing out), the usage rows show the error and you can renew it from the same panel.

DEEPSEEK_API_KEY (balance)

The plugin reads the same API key the harness already uses: DEEPSEEK_API_KEY, resolved from the launching environment or ~/.dsh/.credentials.yaml (set it on the Settings → Models page). No API key → the balance row shows the missing-key hint; the usage figures still work with a valid userToken.

userToken (usage figures)

The four usage figures need the platform session token. Click any billing row to open the control panel, then:

  1. Sign in to platform.deepseek.com.

  2. Press F12 to open DevTools → Console, paste and run:

    JSON.parse(localStorage.getItem('userToken')).value
    

    Copy the printed string.

  3. Or: ApplicationLocal Storage → click https://platform.deepseek.com → find the userToken entry and copy its value field.

  4. Paste it into the control panel input and click 保存.

The token is validated immediately and saved to $DSH_HOME/storages/dsh-usage-blance.json (local machine only). When the token expires (e.g. after signing out), the usage rows show the error and you can renew it from the same panel.

配置

userToken(四项用量)

四项用量需要平台会话令牌。点击任意账单行打开控制面板,然后:

  1. 登录 platform.deepseek.com

  2. F12 打开开发者工具 → Console(控制台),粘贴执行:

    JSON.parse(localStorage.getItem('userToken')).value
    

    复制输出的字符串。

  3. 或者:Application(应用)Local Storage → 点击 https://platform.deepseek.com → 找到 userToken 一项,复制其 value 字段。

  4. 粘贴到控制面板输入框,点击保存

保存时会立即验证 token,并存储到本机 $DSH_HOME/storages/dsh-usage-blance.json。token 过期(如退出登录)后,用量行会显示错误,在同一面板重新获取即可。

DEEPSEEK_API_KEY(余额)

插件读取的正是 harness 自己在用的那个 Key:DEEPSEEK_API_KEY(从启动环境或 ~/.dsh/.credentials.yaml 解析;在设置 → 模型页面填写)。未配置时余额行显示提示,四项用量在 userToken 有效时仍可正常显示。