@playhard.pro/pi-deepseek-balance0.1.2
Pi extension that shows your DeepSeek account balance in the footer status bar.
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
@playhard.pro/pi-deepseek-balance
A Pi extension that shows your DeepSeek account balance in the footer status bar and keeps it up to date as you work.
It reuses the DeepSeek API key that Pi is already configured with — from the DEEPSEEK_API_KEY
environment variable or Pi's stored credentials — so there is no extra secret to manage.
DeepSeek ¥12.34
Features
- 💰 Balance shown in the persistent footer status line.
- 🔄 Automatic refresh after every agent run (
agent_settled), throttled to once per 30s. - ⌨️ Manual refresh with the
/deepseek-balancecommand. - 🔐 Reuses Pi's existing DeepSeek credentials — no extra configuration.
- 🌍 Renders every
balance_infosentry (e.g. CNY and USD) on one line. - 🛡️ Graceful handling of missing keys, HTTP failures, timeouts, and unavailable accounts.
Requirements
- Pi
>= 0.79(any recent release). - A configured DeepSeek provider with a valid API key.
Installation
From npm (recommended)
pi install npm:@playhard.pro/pi-deepseek-balance
Pin a version if you prefer:
pi install npm:@playhard.pro/pi-deepseek-balance@0.1.0
From git
pi install git:github.com/playhard-pro/pi-extensions
As a local path
pi install /absolute/path/to/pi-extensions/packages/pi-deepseek-balance
# or a relative path
pi install ./packages/pi-deepseek-balance
Try without installing
pi -e ./packages/pi-deepseek-balance/extensions/index.ts
After installation, restart Pi (or run /reload).
Usage
Once loaded, the extension registers itself automatically:
| Trigger | Behavior |
|---|---|
| Session start | Fetches the balance and writes it to the footer. |
| Agent run settles | Refreshes the balance, throttled to once per 30 seconds. |
/deepseek-balance |
Forces a refresh and shows a notification. |
| Session shutdown | Clears the footer entry. |
The footer text reflects the account state:
| Status | Meaning |
|---|---|
DeepSeek ¥12.34 |
Balance fetched successfully. |
DeepSeek ¥12.34 (unavailable) |
The API reports is_available: false. |
DeepSeek: no API key |
No DeepSeek key is configured for Pi. |
DeepSeek: HTTP 401 ... |
The request failed (auth, network, timeout, …). |
API key resolution
The extension calls ctx.modelRegistry.getApiKeyForProvider("deepseek"), so it transparently uses
whichever key Pi already resolves:
DEEPSEEK_API_KEYenvironment variable.- Credentials stored by Pi (e.g. via
pilogin/provider setup).
No new secret configuration is required.
How it works
The extension calls GET https://api.deepseek.com/user/balance with
Authorization: Bearer <apiKey> and renders the returned balance_infos in the footer using
ctx.ui.setStatus. Requests are throttled and de-duplicated so the endpoint is never hammered, and
each request has a 10 second timeout.
Development
This package lives in the pi-extensions
monorepo. From the repository root:
npm install
npm run typecheck
npm run lint
npm test
Run only this package's tests:
npm test --workspace @playhard.pro/pi-deepseek-balance
Smoke test in Pi
pi -e ./packages/pi-deepseek-balance/extensions/index.ts
With DEEPSEEK_API_KEY set, confirm the footer shows the balance and that /deepseek-balance
forces a refresh.
License
MIT © playhard.pro