Foreword

DeepSeek Harness (DSH) decouples host capabilities into plugins, with the community directory operating as an independent site. It has no official affiliation with DeepSeek or High-Flyer and is not an official app store.

When using the DeepSeek API, balance and usage details typically need to be checked on the official platform. Sev7een/ds-api-usage is a DeepSeek Harness plugin that displays DeepSeek API balance, estimated consumption, token count, and API request count on DSH’s settings page. It reuses the existing DEEPSEEK_API_KEY and does not require configuring an additional set of keys.

What This Is

  • Plugin name: Sev7een/ds-api-usage
  • Package name: dsh-plugin-ds-api-usage
  • Maintainer: Sev7een
  • License: MIT
  • Runtime requirement: Node >=20

The plugin’s purpose is straightforward: to view DeepSeek API balance and usage timeline on the DeepSeek Harness Settings → API Usage page.

It can be loaded as a dynamic plugin per session or as a persistent composition plugin written into the profile’s cordis.patch.yml.

Core Features

1. Balance Card

Displays:

  • Total balance
  • Breakdown of gifted/recharged amounts
  • API-reported currency code: CNY or USD
  • Availability badge

Data is sourced from the official GET /user/balance endpoint.

2. Metrics Card

Displays within 24 hours:

  • Estimated consumption: CNY
  • Input/output token count
  • API request count

3. Timeline Chart

Supports two granularities:

  • Hourly bar chart for the last 24 hours
  • Daily bar chart for 14 days

Allows switching between the following metrics:

  • Cost
  • Token count
  • Request count

4. Real-Time Refresh

  • Host refreshes balance every 60 seconds
  • Page polls every 30 seconds
  • Page provides a manual refresh button

5. Credential Reuse

The plugin does not require additional key configuration; it reuses the existing DEEPSEEK_API_KEY in the deployment, resolved via the harness credentials service.

6. Client Localization

Follows the active language via the harness locale service, providing:

  • zh
  • en
  • pt-BR

Falls back to zh when translations are missing.

7. Persistent Aggregation

The plugin writes aggregated data to:

$DSH_HOME/storages/ds-api-usage.json

Retention policy:

  • Hour buckets retained for 48 hours
  • Day buckets retained for 14 days

Deleting this file resets the plugin’s persistent data.

8. Settings Page Registration

The plugin injects a localized settings page into the host settings.section slot and exposes:

/ds-api-usage/snapshot

This endpoint provides JSON data for client display.

Installation and Enabling

First, ensure the environment meets the following conditions:

  • DeepSeek Harness is configured with the DeepSeek LLM adapter
  • DEEPSEEK_API_KEY can be resolved via the harness credentials service
  • The host has curl available to call the balance endpoint

curl is required because web.fetch cannot send the Authorization header.

Install from GitHub:

dsh plugin --profile web add github:Sev7een/ds-api-usage

After installation, open in DeepSeek Harness:

Settings → API Usage

to view balance, estimated consumption, token count, and API request count.

The documentation also includes an npm command:

dsh plugin --profile web add dsh-plugin-ds-api-usage

The README indicates this command corresponds to once published to npm. Until the npm package is confirmed to be published, prioritize using the above GitHub installation command.

Dynamic Plugin Method

The original form is a dynamic Cordis plugin created per session, using:

  • cordis_define
  • cordis_run

Corresponding files:

  • code.host: src/index.js
  • code.client: client/index.js

The dynamic form uses the harness.handle / host.call channel.

Persistent Composition Plugin Method

Add the following to the profile’s cordis.patch.yml:

- insert:
    - id: ds-api-usage
      name: 'dsh-plugin-ds-api-usage'

This will add the plugin to the host composition, loaded by the host.

Typical Usage

Viewing Balance and Usage

After installation, open:

Settings → API Usage

to see:

  • DeepSeek API balance
  • 24-hour estimated consumption
  • Input/output token count
  • API request count
  • 24-hour hourly or 14-day daily timeline

Local Development Checks

Run syntax checks:

npm run check

Run offline tests:

npm test

Updating Price Table

Locally re-parse the DeepSeek official pricing page and generate the PRICING table:

npm run update:pricing

The price table is located between the markers:

__PRICING_BEGIN__
__PRICING_END__

The generated block should only be updated via the script.

Resetting Persistent Data

Delete:

$DSH_HOME/storages/ds-api-usage.json

to reset the aggregated data saved by the plugin.

Use Cases and Notes

Suitable for:

  • Calling DeepSeek API within DSH and wanting to view balance and usage directly on the settings page
  • Needing 24-hour hourly or 14-day daily timelines
  • Wanting to reuse the existing DEEPSEEK_API_KEY without additional key configuration

Notes before use:

  • Costs are estimated, based on DeepSeek’s public pricing calculated by model and UTC time period
  • Token counts come from the usage data of model calls
  • The plugin runs with the current dsh process permissions; before installation, check the source code, license, and dependencies to ensure they are suitable for your deployment
  • Dynamic form uses the harness.handle / host.call channel
  • Static bundles use HTTP route /ds-api-usage/snapshot
  • When modifying the protocol, both sides need to be kept in sync
  • Repository CI requires GitHub Actions enabled but does not need secrets or API keys

Related Links

  • GitHub: https://github.com/Sev7een/ds-api-usage
  • Community directory page: https://www.skillhub.cn/plugins/Sev7een/ds-api-usage