dsh-deepseek-usage: Sidebar DeepSeek Balance and Local Usage Estimation

Preface

When running DeepSeek models in DSH, you usually have to switch to a browser and open platform.deepseek.com to check how much money is left in your account, how many tokens you’ve used in the last few days, and roughly how much you’ve spent. The official API only exposes a balance endpoint — there’s no publicly available usage API; the platform’s usage page depends on a browser login session, so you can’t use an API Key to pull full bills directly.

The community plugin dsh-Deepseek-usage addresses this: it displays your DeepSeek balance in the bottom of the DSH web sidebar (above the Settings row), and clicking it opens a popup showing balance details, charts aggregated from local DSH session logs, and a cost breakdown by model. The balance comes from the official endpoint; usage and cost figures are local estimates, and the plugin clearly indicates the scope and limitations in the UI.

What Is This

dsh-deepseek-usage is maintained by The-five-stooges and categorized as a client-side plugin (dsh.client.platform: web). It renders under the DSH shell theme tokens and works with both light and dark themes.

In one line: a single sidebar row showing balance + refresh button; clicking opens a popup with a balance card, 7/30-day token line charts, estimated-cost bar charts, and a per-model table, along with a link to jump to the official usage page.

Core Features

One Row at the Bottom of the Sidebar

  • Text like DeepSeek Balance ¥85.66, with a refresh button.
  • When the sidebar collapses to the 56px rail, only the icon is shown; the number moves into the tooltip.
Area Content
Balance card Total balance, topped-up, granted, currency, availability, fetch time, source, etc.
Charts Daily token line chart; daily estimated-cost bar chart (7-day or 30-day window)
Table Usage and cost broken down by model
Actions A button to open platform.deepseek.com/usage (cannot be embedded in an iframe — see limitations below)

Where the Numbers Come From

Metric Source Authoritative?
Balance GET https://api.deepseek.com/user/balance, server-side request, cached for 60 seconds Yes, official endpoint
Usage / Cost Local DSH session logs (assistant/message, usage in assistant/attempt), priced according to the official peak/off-peak price list No, local estimate

DeepSeek does not provide a public usage API: api.deepseek.com only exposes /user/balance; the platform usage page requires a browser login token, not an API Key. The plugin explains the estimation scope in the panel; a more detailed source explanation is available in the repo at docs/usage-data-sources.md.

Security and Keys

The API Key does not enter the browser bundle. The key is resolved per-operation via the host credential store and is used only to send the Authorization header to api.deepseek.com. When no key is configured, the sidebar shows a clear “not configured” state instead of crashing with an error.

Installation and Activation

The plugin integrates into the DSH profile as an npm package. dsh plugin delegates to pnpm inside the profile directory and reconciles dsh.profile.bundles; the package declares dsh.bundle, so no local build is needed (lib/client.js and lib/index.js are committed as build artifacts, there is no prepare script, and git installations generally do not require allowBuilds).

Method 1: GitHub source

dsh plugin add github:The-five-stooges/dsh-Deepseek-usage

Method 2: Release pre-built package

dsh plugin add https://github.com/The-five-stooges/dsh-Deepseek-usage/releases/latest/download/dsh-Deepseek-usage.tgz

After installation, restart the host process once (the host half is assembled at startup), then refresh the page.

Configure DEEPSEEK_API_KEY in the harness credential store or the launch environment; without a key, only the “not configured” state is shown.

Engine requirement: dsh >= 0.1.5-rc.1 (see dsh.engines in package.json).

Optional Configuration

You can write this in the profile plugin entry:

- id: dsh-Deepseek-usage
  config:
    timeoutMs: 10000   # Upstream balance request timeout, default 10000
    ttlMs: 60000       # Cache TTL for successful snapshots, default 60000; force=1 bypasses it

Typical Usage and HTTP Interfaces

The host half serves routes on the same origin as the current session, making it easy for the front end to fetch balance and usage summaries.

Route On success On failure
GET /api/dsh-Deepseek-usage/balance[?force=1] { ok:true, currency, totalBalance, grantedBalance, toppedUpBalance, isAvailable, fetchedAt, cached } { ok:false, error:{ code, message, httpStatus? } }
GET /api/dsh-Deepseek-usage/usage[?days=N] { ok:true, requestedDays, days, generatedAt, truncated, totals } Same envelope as above
GET /api/dsh-Deepseek-usage/health (alias /healthz) Plugin name, version, ledger availability —

Sidebar refresh triggers a balance fetch; force=1 skips the success cache. The popup charts fetch local aggregated results via usage?days=N. The response shape is governed by the repo’s tests/contract.test.mjs.

For everyday operations you don’t need to call the API directly: after installing and configuring the key, just look at the balance in the sidebar and click the row to open the popup.

Use Cases and Caveats

Who it’s for

  • Users who primarily use DeepSeek in local DSH and want to quickly check the official balance inside the IDE.
  • Users who need token trends and cost estimates (based on local session logs and the official price list) as a reference, not as a replacement for platform invoices.

Limitations you should be aware of

  1. Estimates only cover local DSH session logs (across all local workspaces). Consumption from the same account on other machines, the Web UI, or other tools will not appear here, so the numbers may be lower than the platform bill. The README provides a real-world comparison example (partially logged periods vs. fully logged days).
  2. The official usage page cannot be embedded: platform.deepseek.com/usage has a CSP of frame-ancestors 'none', so the popup can only open it as an external link.
  3. The bar-chart costs are estimates based on the price list; the platform bill remains the final authority.
  4. The plugin runs under the permissions of the current dsh process, reading session logs and making balance requests on your behalf. Before installing, please review the GitHub source and the MIT license yourself; the plugin is not affiliated with DeepSeek.

The DSH ecosystem emphasizes “everything is a plugin”; the SkillHub directory page is a community site with no official affiliation with DeepSeek or High-Flyer.

Conclusion

dsh-Deepseek-usage hooks the official balance into the sidebar and turns local DSH usage into readable charts and a per-model table, adding a local perspective in the absence of a usage API. If your consumption is almost entirely within local DSH, the estimates will be closer to the bill; if multiple entry points share the same API Key, rely on the platform usage page and invoices.

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

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

Xiaoye