dsh-deepseek-balance: View DeepSeek account balance under the DSH input box

Introduction

When running conversations with DSH (DeepSeek Harness), model calls utilize the DeepSeek API Key configured in Settings → Models. Issues like insufficient balance or invalid keys are often discovered only after a request fails. Checking the balance on the console or official website requires switching away from the current interface.

dsh-deepseek-balance is a client-side DSH plugin published by community maintainer CowB0ySpike. It adds a roughly 12px entry in the composer dock below the Web GUI input box, in the same row as activity and usage. It displays the account balance corresponding to the current key in real-time; clicking the refresh icon on the right triggers an immediate re-query. The API Key remains solely within the Host process; the browser only receives the balance and status.

What is this

  • Repository: CowB0ySpike/dsh-deepseek-balance
  • Directory Page: skillhub.cn plugin entry
  • License: MIT (package.json version 1.0.0)
  • Positioning: A DSH plugin that displays DeepSeek API Key account balances in the composer dock. It reads the configured DEEPSEEK_API_KEY from the DSH credentials service; no separate key entry is required within the plugin.

Interface schematic (from README):

Balance ¥123.45 ↻

Core Features

The following capabilities are derived from the project README and can be used as needed.

Credentials & Privacy

  • Out of the box: Uses the DEEPSEEK_API_KEY written on the Models page.
  • Host calls GET https://api.deepseek.com/user/balance; the browser only requests the same-origin read-only route GET /deepseek-balance. The response contains only the balance and status; the key is never sent to the client.

Experience & Performance

  • Successful results are cached for 60 seconds; failed results for 5 seconds. Concurrent requests are coalesced into a single upstream call.
  • The refresh button can bypass the cache using ?refresh=1.
  • Corresponding text and colors are provided for cases such as unconfigured key, invalid key, network timeout, and insufficient balance. The UI language follows DSH (Chinese/English bilingual).

Implementation Form

  • Pure ESM. client.js registers via window.__ModuleLoader__ with no bundling or extra dependencies.
  • See “How it works” below for the division of labor between the Host half (index.js) and the Client half (client.js).

Installation & Activation

The plugin is installed into the DSH profile as a local linked package (link:) and does not rely on npm publishing. The README does not provide a dsh plugin add github:... command, so please follow these steps.

  1. Clone the repository to any directory (replace the path based on your environment):
git clone https://github.com/CowB0ySpike/dsh-deepseek-balance.git
  1. Open the DSH profile directory (environment variable DSH_PROFILE_DIR, usually ~/.dsh/profiles/<name>) and edit the package.json within it. Add link: pointing to the clone path in dependencies and add the package name to dsh.profile.bundles.
{
  "dependencies": {
    "dsh-deepseek-balance": "link:D:/path/to/dsh-deepseek-balance"
  },
  "dsh": {
    "profile": {
      "bundles": [
        "@deepseek-ai/dsh-base",
        "@deepseek-ai/dsh-web-app",
        "dsh-deepseek-balance"
      ]
    }
  }
}

Replace D:/path/to/dsh-deepseek-balance with the actual path (Windows supports both forward and escaped backslashes).

  1. Run an installation in the profile directory to activate the link in node_modules:
pnpm install
  1. Restart DSH. If “Balance …” appears below the input box, the plugin is loaded; if “API Key not configured” appears, go to Settings → Models to fill in the DeepSeek API Key.

The dsh.bundle.patch in package.json points to cordis.patch.yml, inserting the plugin line (id deepseek-balance) into the profile. generally, manual patch writing is unnecessary as long as it is added to bundles.

Configuration (Optional)

All adjustable items have default values and work without configuration. If needed, append config for deepseek-balance in the profile’s cordis.patch.yml:

- id: deepseek-balance
  name: dsh-deepseek-balance
  config:
    apiKeyEnv: DEEPSEEK_API_KEY   # Credential reference name
    baseURL: https://api.deepseek.com
    cacheTtlMs: 60000             # Success result cache (ms)
    timeoutMs: 10000              # Single upstream request timeout (ms)
Option Default Description
apiKeyEnv DEEPSEEK_API_KEY Reference name resolved by ctx.credentials, not the Key itself
baseURL https://api.deepseek.com Upstream address, usable for self-hosted or proxy gateways
cacheTtlMs 60000 Cache duration for successful results
timeoutMs 10000 Upstream request timeout

If an entry with the same id already exists in cordis.patch.yml (only declaring the name), the syntax above will overwrite its config without duplicating the entry.

Typical Usage

Daily Check

After starting DSH and configuring the API Key, view the balance in the dock below the conversation input box; it defaults to using the cache within the last 60 seconds.

Force Refresh

Click the refresh button on the right side of the entry, or let the Client request the same-origin route with refresh=1:

GET /deepseek-balance?refresh=1

Local Host Route Debugging

Directly accessible on the DSH local loopback web service (port depends on your current DSH):

GET /deepseek-balance

Returns JSON on success, for example:

{
  "status": "ok",
  "ref": "DEEPSEEK_API_KEY",
  "isAvailable": true,
  "balances": [
    { "currency": "CNY", "total": "123.45", "granted": "0.00", "toppedUp": "123.45" }
  ],
  "fetchedAt": 1790000000000
}

When the Key is not configured, status is unconfigured; on failure, status is error, and code may be CREDENTIALS, UNAUTHORIZED, NETWORK, TIMEOUT, HTTP, RESPONSE, INTERNAL, etc. Non-GET requests return 405; the route does not set CORS and is only accessible from the same origin as the DSH page.

How it works (Brief Summary)

File Role
index.js Host: Resolve credentials → Request /user/balance → In-memory cache → Register GET /deepseek-balance
client.js Browser: Register component in conversation.composer.dock, fetch same-origin route and render
cordis.patch.yml Insert plugin bundle patch into profile
locale/*.json Chinese/English names and descriptions for settings and marketplace
icon.svg Plugin icon

The Host obtains credentials and the web carrier via inject = ['credentials', 'webServer']; the Client registers slots and dictionaries via inject = ['slots', 'locale']. After modifying index.js / client.js, you can reload the plugin in DSH or restart DSH to take effect; no separate build step is required.

Scenarios & Notes

Who it is for

  • Those who frequently debug and converse in the DSH Web GUI and want to confirm at a glance if the current Key balance is sufficient.
  • Developers already using DSH profiles + link: methods to manage local plugins.

Security & Runtime Environment

  • The plugin runs with the permissions of the current DSH process; please read the source code and MIT license yourself before installation to ensure the behavior complies with your environment policy.
  • The API Key is resolved and used only within the Host; if you expose DSH to the public network, you should add authentication yourself in front of it. This project is unrelated to DeepSeek officially and is solely a third-party DSH plugin.
  • The community directory skillhub.cn is an independent site and has no official affiliation with DeepSeek or High-Flyer.

Conclusion

dsh-deepseek-balance brings DeepSeek account balances into the composer dock, keeping credentials in the Host and showing only a same-origin read-only interface to the browser. It is suitable as a lightweight client plugin for daily DSH usage. See the GitHub Repository and SkillHub Directory Page for details and updates.

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

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

Xiaoye