← Catalog

@ymy88/pi-deepseek-balance

pi extension: show the official DeepSeek account balance in the status bar, only while the current model runs on api.deepseek.com

Extension

Install

Install with PiG

pig install npm:@ymy88/pi-deepseek-balance

Install with Pi

pi install npm:@ymy88/pi-deepseek-balance
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./index.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 0.1.1 (README.md). PiG does not review it.

pi-deepseek-balance

A pi extension that shows your official DeepSeek account balance in the status bar, for example 💵 DS $12.34.

When it shows

Visibility is decided by provider, the same way pi-ark-quota does it — only by where the current model actually runs:

Current modelShown
Provider whose base URL host is api.deepseek.comShown
Any other provider (OpenRouter, Volcano Ark, …)Hidden, no status bar space used
The virtual model deepseek/autoFollows the provider of the last reply on the session branch: if the previous turn went to the official DeepSeek endpoint it shows, if it went to OpenRouter it hides

deepseek/auto is a virtual model. The provider you select it under is deepseek, which does not identify the real endpoint, so this extension does not look at ctx.model.provider. It reads the provider of the last assistant message from ctx.sessionManager.getBranch() instead. Before the first reply of a turn, it falls back to the provider the virtual model is registered under.

Together with pi-openrouter-balance this means the DeepSeek balance shows during off-peak hours and the OpenRouter balance shows during peak hours — the two never appear at the same time.

The check is the host name of the provider's base URL, not the provider's name.

Data source

GET https://api.deepseek.com/user/balance, authenticated with the provider key pi already holds (ctx.modelRegistry.getApiKeyForProvider()). No extra environment variable is needed.

{"is_available":false,"balance_infos":[{"currency":"USD","total_balance":"0.00"}]}

The USD entry is preferred. When there is no USD balance, the first currency in the list is shown instead, for example ¥70.00.

Status bar colors

ConditionColor
is_available is false (DeepSeek reports this when the balance is 0, and it then rejects new requests)Red
Balance ≤ 0Red
Balance < threshold (5 by default)Yellow
OtherwiseNormal

When the query fails, the status reads a dim 💵 DS login ✗ / 💵 DS no key / 💵 DS ✗. A 401 or 403 clears the cache so a stale number is never shown.

Install

pi install npm:@ymy88/pi-deepseek-balance

You can also install from git or from a local directory:

pi install git:github.com/ymy88/pi-deepseek-balance
pi install ~/Projects/pi-deepseek-balance

Then run /reload inside pi.

The unscoped name pi-deepseek-balance on npm belongs to another author, which is why this package is published under the @ymy88 scope.

Command

CommandEffect
/deepseek-balanceRefresh immediately and report every currency balance plus whether the account is usable

Configuration (optional environment variables)

VariableDefault
DEEPSEEK_BALANCE_TTL_MS300000 (5 minute cache)
DEEPSEEK_BALANCE_LOW_USD5 (below this the number turns yellow)

Refreshes happen on session_start, model_select, and agent_settled (end of every turn), all bounded by the cache TTL.

Tests

npm test

Only the pure functions are tested — parsing, currency ordering, colors, status text, host matching, and the visibility decision for virtual models. No network requests are made.

License

MIT, see LICENSE.