Introduction

When running DeepSeek-related tasks in DeepSeek Harness, you will typically encounter two direct issues: whether the account balance is sufficient and how many tokens have been consumed in the current session.

dsh-deepseek-usage is a DSH plugin for DeepSeek Harness that encapsulates these two tasks into callable tools for the model: deepseek_balance for querying the DeepSeek account balance, and usage_summary for summarizing the token usage of the current live session.

What is this

The plugin is named dsh-deepseek-usage, maintained by ben7am1n, and is licensed under MIT.

Its positioning is as a usage monitoring plugin for DeepSeek Harness, providing two tools:

  • deepseek_balance: Queries the DeepSeek account balance.
  • usage_summary: Summarizes the token usage of the current live session.

Core Features

deepseek_balance

deepseek_balance queries:

GET https://api.deepseek.com/user/balance

The returned content includes account availability and balance fields by currency: total, granted, and topped-up.

If lowBalanceThreshold is configured, when the balance of the primary currency falls below this threshold, the tool appends a low-balance warning to the result.

usage_summary

usage_summary aggregates the per-session token usage of the current live session from Harness’s token meter and sorts them in descending order by total tokens.

This tool can be used to estimate context usage and facilitate the discovery of sessions with abnormally high token consumption.

Installation and Activation

The plugin requires a DeepSeek API key, and this key must be readable from the environment (env) or credentials as DEEPSEEK_API_KEY.

The installation command is as follows:

dsh plugin --profile <name> add dsh-deepseek-usage

The <name> in the command is a profile placeholder that needs to be replaced with the name of the profile to install the plugin on.

Peer dependencies requirements are as follows:

  • @deepseek-ai/cordis ^4.0.1
  • @deepseek-ai/dsh-session ^0.1.0-rc.6
  • @deepseek-ai/dsh-token-meter ^0.1.0-rc.6
  • @deepseek-ai/dsh-tools ^0.1.0-rc.6

Configuration

Plugin configuration includes the following fields:

Field Default Description
apiKeyEnv DEEPSEEK_API_KEY The env var or credential reference corresponding to the API key
baseURL https://api.deepseek.com DeepSeek API base URL
lowBalanceThreshold Optional low-balance warning threshold

Below is a profile example, enabling deepseek-usage and setting the low-balance threshold to 20:

# profile cordis.patch.yml
- id: deepseek-usage
  config:
    apiKeyEnv: DEEPSEEK_API_KEY
    lowBalanceThreshold: 20

Typical Usage

After installation and activation, you can call the following tools in Harness:

  1. Call deepseek_balance to obtain account availability and balances for each currency.
  2. Call usage_summary to view the token usage of the current live session sorted by total tokens.

If lowBalanceThreshold is configured, deepseek_balance will include a warning when the balance of the primary currency is below the threshold.

Applicable Scenarios and Notes

Suitable for scenarios where you are using the DeepSeek API within DeepSeek Harness and wish to include balance checks and token usage summaries in your daily checks.

Pre-use notes:

  • The plugin runs with the permissions of the current dsh process; you should check the source code and license before installing.
  • DEEPSEEK_API_KEY can be used to query account information; it is recommended to place it only in a trusted environment.
  • lowBalanceThreshold is an optional configuration; if not configured, the low-balance warning will not be triggered.

Links

  • Community Directory Page: https://www.skillhub.cn/plugins/ben7am1n/dsh-deepseek-usage
  • GitHub: https://github.com/ben7am1n/dsh-deepseek-usage