JonyChan8394/dsh-llm-balance ↗★ 0
dsh-llm-balance
LLM 余额显示插件:在聊天输入框下方显示 DeepSeek、OpenRouter、SiliconFlow 及自定义服务商的 API 账户余额。
AI 分析
核心用途是多平台 API 额度监控。适合频繁使用多种大模型 API、需要实时在聊天界面掌握账户余额消耗情况的用户。
安裝
$
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:JonyChan8394/dsh-llm-balance說明文件
閱讀完整 README ↗dsh-llm-balance
Show the balances of all your LLM API accounts right under the chat input box.
- Under the chat input — a compact strip in the composer dock that refreshes automatically (default every 60 s) with a manual refresh link.
- Any LLM API — providers are config-driven. Presets ship for DeepSeek, OpenRouter and SiliconFlow; add any provider that exposes a balance endpoint via a dotted JSON path.
- Keys stay on the host — API keys are resolved from DSH credentials (or environment) host-side; the browser only ever sees the fetched balances.
Install
dsh plugin --profile web add github:JonyChan8394/dsh-llm-balance
Restart dsh web. The balance strip appears under the chat input as soon as at least one configured provider has a key.
Configure
Add API keys to DSH credentials (or your environment):
| Provider | Credential ref |
|---|---|
| DeepSeek | DEEPSEEK_API_KEY |
| OpenRouter | OPENROUTER_API_KEY |
| SiliconFlow | SILICONFLOW_API_KEY |
To add or customize providers, override the plugin config in your profile's cordis.patch.yml:
- id: llm-balance
config:
refreshMs: 30000
providers:
- id: deepseek
name: DeepSeek
apiKeyRef: DEEPSEEK_API_KEY
url: https://api.deepseek.com/user/balance
balancePath: balance_infos.0.total_balance
currencyPath: balance_infos.0.currency
- id: myprovider
name: MyProvider
apiKeyRef: MYPROVIDER_API_KEY
url: https://api.example.com/v1/balance
balancePath: data.remaining
currencyPath: data.currency
A provider whose key is missing shows "未配置 / not configured"; a provider whose request fails shows "获取失败 / fetch failed". The whole strip hides when every provider lacks a key.
How it works
- Host half (
lib/index.js) resolves each provider's key throughctx.credentials, calls its balance endpoint, and servesGET /llm-balanceas JSON through the webserver route registry. - Browser half (
lib/client.js) registers aconversation.input.dockentry (order 30) that polls/llm-balanceand renders the strip.
License
MIT