dsh-api-cost: API Cost Tracking Plugin for DeepSeek Harness

Introduction

DeepSeek Harness (DSH) is an “everything is a plugin” agent development framework. During usage, token consumption generated by API calls often lacks intuitive statistics and budget control. Existing approaches typically involve manual logging or relying on third-party tools, which are neither real-time nor tied to conversation context. The dsh-api-cost plugin described below reads the usage data reported by the provider directly from DSH session events, converts token consumption per conversation into a concrete monetary cost, and provides visualized statistics on a daily and per-conversation basis.

Plugin Positioning

dsh-api-cost is a DeepSeek Harness plugin designed to track real API token consumption costs. It is maintained by OrstedOshua and categorized under admin-security. The plugin listens to assistant/message events, reads the usage field returned by the provider, accumulates costs per conversation, and provides a daily spending chart along with per-session breakdown statistics.

Core Features

  1. Per-conversation cost tracking: The plugin listens to session events, reads the usage data reported by the provider, and accumulates token consumption and corresponding costs separately for each conversation. Costs are locked to the pricing in effect at the time; subsequent price changes will not recalculate already-consumed amounts (price freeze).

  2. Session header indicator: Displays the current conversation’s cost amount next to the context indicator in the session interface. Clicking it opens a quick menu to view the total cost of the current conversation, clear the current conversation’s statistics, or toggle whether this conversation is included in the tally.

  3. Daily spending chart: The interface includes a 20-day bar chart that automatically fills with data as consumption grows, providing an intuitive view of daily spending.

  4. Session naming and renaming: Session names use the DSH-format display name to avoid raw UUIDs, and support inline renaming.

  5. Flexible pricing: Supports setting prices per 1M tokens for three token categories: input, output, and cache.

  6. Multi-language and multi-currency: Supports Russian and English UI, selectable in settings. Supports four currencies — RUB, USD, EUR, and CNY — with exchange rates automatically loaded hourly from the open API at open.er-api.com.

Installation and Activation

This plugin is distributed as a standard DSH bundle. Enable the plugin manager in DSH, then follow these steps:

  1. Install dsh-api-cost via the DSH plugin manager or the /plugin-manager command.
  2. Enable the dsh-api-cost plugin in settings.
  3. Open Settings → API Cost, select language and currency, set the per-1M-token prices for each token category, and save.

After installation, the state file is stored at $DSH_HOME/token-cost-state.json (or ~/.dsh/token-cost-state.json).

Typical Usage

Once the plugin is enabled, every API call within a session is automatically counted toward the cost. On the right side of the session interface, the amount consumed in the current conversation is displayed next to the context indicator. Clicking the amount opens a quick menu to view the cumulative cost of this conversation or clear the current conversation’s statistics. The main interface renders a bar chart across 20 days, showing daily spending. After adjusting exchange rates and pricing in settings, newly consumed tokens are calculated at the new price while historically consumed amounts remain unchanged.

Use Cases and Notes

This plugin is suitable for DSH users who need precise control over API call costs and wish to view spending on both a per-conversation and per-day basis. The plugin runs with the permissions of the current DSH process; it is recommended to review the source code and license (MIT) before installation. The plugin depends on open.er-api.com for real-time exchange rates, so network access must be available.

Conclusion

dsh-api-cost provides DeepSeek Harness with cost-tracking capabilities at both the conversation and daily levels, helping developers gain a more intuitive grasp of API consumption during development and debugging. See the links below for the plugin directory page and source repository.

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

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

Xiaoye