dsh-deepseek-budget: Local DeepSeek Usage and Budget Meter

Introduction

The plugin ecosystem of DeepSeek Harness (DSH) aims to solve development and operational issues in specific scenarios. In team collaboration or shared environments, tracking actual DeepSeek consumption and costs often relies on API calls or manual statistics, which are not intuitive enough. This plugin calculates usage by reading local logs, thereby answering two questions: “What has this machine consumed?” and “How much of the company budget remains?”

Plugin Positioning

dsh-deepseek-budget is a DeepSeek cost meter. It reads token usage from local session logs and bills according to DeepSeek list prices. It does not directly call APIs, so it can use shared API keys.

Core Capabilities

Local Log Parsing and Content Discovery

The plugin reads usage from local logs (./.l) without requiring API keys. It uses content discovery to detect all harnesses on the local machine, including not only DSH but also DeepSeek calls from other tools (such as Pi, Claude Code, etc.). DSH uses a dedicated adapter to handle its zstd-compressed logs, while other harnesses are parsed via a generic record reader.

Duplicate Record Handling

The same call may be recorded multiple times (e.g., sub-agent transcriptions and parent session logs). The plugin globally folds duplicate records based on DeepSeek response IDs or fingerprints (time, routing, token count). For example, on a test machine, this removed 593 records, avoiding a 72% overestimation of spending caused by duplicate records.

Pricing and Billing

The plugin uses DeepSeek’s list prices to calculate costs, not invoice amounts. It supports cache hit/miss statistics as well as peak and off-peak pricing (UTC time).
* Peak hours: UTC 01:00-04:00 and 06:00-10:00, Monday to Friday (excluding Chinese public holidays).
* Cache writes: Billed at the miss rate.
* Supported models: deepseek-flash, deepseek-v4-pro, etc.

Company Account Budget

Local logs can only describe the local machine. To view the overall progress of the company account, you need to configure DEEPSEEK_USER_TOKEN (platform requirement). The GET /deepseek-budget/account API provides account balance, monthly spending, and budget progress.

Installation and Activation

Link the plugin to the web profile:

dsh plugin --profile web add link:$(pwd)

Restart DSH after installation.

Typical Usage

  • View dashboard: Navigate to the DeepSeek Budget page in DSH settings to view the budget table, window selector (Today/7 days/30 days/All), costs by model/by day, etc.
  • Local report: Use GET /deepseek-budget/report?window=all to get JSON of local usage.
  • Set budget: Set the environment variable DEEPSEEK_BUDGET_EUR (default 50).
  • Company account: Set the environment variable DEEPSEEK_USER_TOKEN to view company account spending.

Use Cases and Notes

  • Local machine only: The plugin runs with the permissions of the current DSH process and can only count calls in local logs. It cannot see database logs or unrecorded calls, nor can it see consumption from other machines.
  • Permission requirements: The company account section requires DEEPSEEK_USER_TOKEN, which only the account owner can obtain.
  • Configuration flexibility: Supports customizing log root directories via DEEPSEEK_BUDGET_ROOTS or DEEPSEEK_BUDGET_HOME.

Resources

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

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

Xiaoye