Preface

If you connect multiple LLM providers in DSH at the same time—such as DeepSeek official, OpenRouter, and SiliconFlow—checking balances becomes a tedious task: you have to log into each provider’s console one by one, or manually curl each provider’s balance endpoint. When the balance runs out is often only discovered when a call results in an error.

dsh-llm-balance brings this into the chat interface: it directly displays the API balances of configured providers below the chat input box. Clicking on the balance opens the corresponding recharge page. Below, we introduce the plugin’s features, installation, and configuration methods.

What is this?

dsh-llm-balance is a DSH plugin maintained by JonyChan8394, licensed under MIT, with the current version 0.5.0. DSH’s philosophy is “everything is a plugin”; this plugin solves a specific problem: making the balance appear where you are already looking—the area below the input box.

It is not an aggregation panel; it displays the provider routes you have registered in dsh. Adding a new provider in dsh will appear in the balance bar on the next refresh; removing it disappears with it, without requiring a restart or configuration changes.

Core Features

  • Compact readings below the input box: Balance is displayed at the bottom of the composer (below the input card, where the stats row is located). It auto-refreshes every 60 seconds by default and provides a manual refresh link.
  • Click to recharge: Clicking on any provider’s balance (or the “No balance API” tag) opens the provider’s recharge page in a new browser tab; each preset comes with a rechargeUrl.
  • Follows dsh configuration: The balance bar shows the provider routes registered in dsh. Adding or removing providers requires no restart or configuration changes.
  • Built-in known balance endpoints: DeepSeek (deepseek, deepseek-official), OpenRouter, SiliconFlow, Moonshot/Kimi (moonshotai-cn, moonshotai), MiniMax, StepFun, Zhipu/GLM (zhipu).
  • Providers without a public balance API: For providers without a public balance API (e.g., Qwen/DashScope, OpenAI, Anthropic), when a key is configured, it displays “No balance API / no balance API” rather than hiding it.
  • Keys stay on the host: The API key is parsed from DSH credentials (or environment variables) on the host side; the browser only sees the fetched balance.

Implementation

The plugin consists of two parts: the host and the browser. On the host side (lib/index.js), it reads ctx.llm.listProviders() on every request—the set of LLM routes configured in dsh. For each provider with a known balance endpoint, it parses the key via ctx.credentials and calls the balance endpoint. The result is provided via the webserver routing table in JSON format via GET /llm-balance. On the browser side (lib/client.js), it registers a conversation.composer.dock entry (order 10), polls /llm-balance, and renders the readings below the input card.

Regarding dependencies, the plugin declares three peerDependencies: @deepseek-ai/cordis ^4.0.1, @deepseek-ai/schemastery ^4.0.1, @deepseek-ai/dsh-credentials ^0.1.0-rc.6; the client side is injected via @deepseek-ai/dsh-client-runtime and @deepseek-ai/dsh-client-locale (see the dsh.client config in package.json).

Installation and Enablement

First, run the installation command, then restart dsh web:

dsh plugin --profile web add github:JonyChan8394/dsh-llm-balance

After restarting, as long as at least one configured provider has a key, a balance reading will appear below the input box. Aside from this, no configuration is needed—the plugin follows the providers you have already set up in dsh.

Two boundary states (from README):

  • Providers without a configured key will not appear in the balance bar;
  • Providers whose balance requests fail display “Failed to fetch / fetch failed”.

Custom Balance Endpoints

After the installation steps above, the plugin is ready to work. If a provider outside the list also has its own balance endpoint (e.g., a self-built aggregation route), you can override the plugin configuration in the profile’s cordis.patch.yml:

- id: llm-balance
  config:
    refreshMs: 30000
    endpoints:
      - id: myprovider
        name: MyProvider
        apiKeyEnv: MYPROVIDER_API_KEY
        url: https://api.example.com/v1/balance
        balancePath: data.remaining
        currencyPath: data.currency
        rechargeUrl: https://console.example.com/recharge

Meaning of each field:

  • refreshMs: Refresh interval (milliseconds), 30000 in the example means refreshing every 30 seconds;
  • id / name: Provider identifier and display name;
  • apiKeyEnv: Environment variable name used by the host side to parse the key;
  • url: Balance endpoint address;
  • balancePath / currencyPath: Path to extract the balance and currency from the response;
  • rechargeUrl: The recharge page to open when the balance is clicked.

Suitable Scenarios and Notes

Suitable scenarios: Using multiple providers with balance endpoints in dsh simultaneously and wanting to keep track of balances without leaving the chat interface to avoid tasks being interrupted due to insufficient funds.

Two points to note before using:

  1. The plugin runs with the permissions of the current dsh process. The host side will read your DSH credentials and call each provider’s balance endpoint using your keys. Please check the source code and license before installing.
  2. The built-in endpoints only cover the routes listed in the README; other providers (including those without a public balance API like OpenAI and Anthropic) can only display “No balance API” and will redirect to their recharge page when clicked.

Summary

dsh-llm-balance does a small thing, but in the right place: turning “checking balance” from opening a separate console into a quick glance at the area below the input box, and it completely follows your existing dsh configuration—install and use.

  • Community Directory Page: https://www.skillhub.cn/plugins/JonyChan8394/dsh-llm-balance (The community directory is an independent site with no official affiliation to DeepSeek / Hypersphere)
  • GitHub Repository: https://github.com/JonyChan8394/dsh-llm-balance