Introduction

After deploying model calls in DSH Web, checking the balance, daily spending, Tokens, and request counts usually requires separate queries or estimates. Estimates based on price tables cannot fully represent actual charges.

dsh-api-usage is a DSH Web plugin that consolidates DeepSeek API balance and usage at the bottom of the sidebar, making it convenient to monitor the current status on a daily basis.

What is dsh-api-usage

dsh-api-usage is maintained by chenzhexii. The repository is located at github.com/chenzhexii/dsh-api-usage and is licensed under the MIT license.

It targets the dsh web Web profile, providing a persistent widget at the bottom of the sidebar that displays the balance, daily spending, daily Tokens, request counts, and a 24-hour spending bar chart.

Key Features

  • Persistent Location: Bottom of the sidebar, above the settings button.
  • Balance Check: Queries /user/balance every 60 seconds.
  • Daily Spending: Calculates actual spending based on the difference between consecutive balance checks, with a precision of ¥0.01.
  • Usage Statistics: Daily Tokens and request counts are derived from the usage reporting of each model call.
  • Manual Refresh: Clicking “↻” forces a balance refresh and immediately calculates the difference to update daily spending.
  • Recharge Entry: The blue “Recharge” button opens the DeepSeek recharge page via window.open.
  • Fallback on Failure: When a balance query fails, it displays the last known balance and automatically retries within 10 seconds.
  • Persistence: Daily spending, Tokens, request counts, and the balance baseline are saved to $DSH_HOME/.ds-api-usage-state.json.
  • Responsive: Adapts to the sidebar’s wide/collapsed states, and simplifies automatically on narrow windows.
  • Route Protection: /ds-api-usage/snapshot is accessible only via loopback address.
  • Data Retention: Hour buckets retain data for 48h, day buckets retain for 14 days, and data is automatically rolled over and evicted.

Installation and Setup

First, ensure your environment meets the following requirements:

  • DeepSeek Harness Web profile (dsh web) and dsh plugin with pnpm available
  • Node.js ≥ 20 on the host side
  • DEEPSEEK_API_KEY credentials configured
  • curl available on the host to call the balance interface via subprocess seam

Run the installation command:

dsh plugin --profile web add github:chenzhexii/dsh-api-usage

Then restart dsh web and refresh the page. You will see the widget at the bottom of the sidebar.

Typical Usage

  1. View Real-time Panel: After refreshing the page, the bottom of the sidebar displays balance, daily spending, daily Tokens, request counts, and a 24h spending bar chart.
  2. Manual Sync: Click “↻” to force a balance refresh and immediately calculate the difference to update daily spending.
  3. Recharge: Click the “Recharge” button to open https://platform.deepseek.com/top_up.
  4. Adjust Polling Interval: Modify ctx.interval(..., 60000) in src/index.js.
  5. View State File: $DSH_HOME/.ds-api-usage-state.json saves daily spending, Tokens, request counts, and the balance baseline.
  6. Syntax Check: Run npm run check in the repository to perform syntax checks on both the host and client sides.

Use Cases and Notes

Suitable for users who have already deployed dsh web, configured DEEPSEEK_API_KEY, and wish to view balance and usage permanently in the browser sidebar.

Note the following points:

  • The plugin runs with the permissions of the current dsh process; check the source code and MIT license before installing.
  • The plugin requires no additional configuration and works out of the box, reusing existing DEEPSEEK_API_KEY credentials from the deployment.
  • Zeroing is only applied at the local 0:00 based on the “today” semantics.
  • /ds-api-usage/snapshot is accessible only via loopback address. Confirm access control boundaries before exposing it across the network.

Conclusion

The value of dsh-api-usage lies in integrating balance, spending, and usage into DSH Web’s daily view, reducing the need to frequently switch interfaces or rely on price estimates.

GitHub: https://github.com/chenzhexii/dsh-api-usage
Directory Page: https://www.skillhub.cn/plugins/chenzhexii/dsh-api-usage