JonyChan8394/dsh-llm-balance
在聊天输入框下方显示LLM API余额:DeepSeek、OpenRouter、SiliconFlow以及任何带有余额端点的自定义提供商。DSH插件。
项目介绍Project Overview
dsh-llm-balance 是 DSH 插件,在聊天输入框下方显示已配置 LLM 服务商余额,按 dsh 配置自动列出、定时刷新,点击可打开充值页。适用于想随时查看 DeepSeek、OpenRouter 等额度并快速充值时。无公开余额接口的服务商仅显示“未开放查询API”。
dsh-llm-balance is a DSH plugin that shows balances for your configured LLM providers beneath the chat input. It follows dsh’s provider list, refreshes automatically, and opens recharge pages on click. Use it to monitor credit for providers such as DeepSeek, OpenRouter, and SiliconFlow. Providers without a public balance API show “no balance API” instead of an amount.
请帮我了解并安装插件:【dsh-llm-balance】【https://github.com/JonyChan8394/dsh-llm-balance】
把上面这条消息直接发给当前会话里的 DSH,让它帮你了解并安装。安装命令不一定准确,发给 DSH 更稳。Send this message to DSH in your current session. CLI install commands may not be accurate across systems — DSH will figure it out for you.
或使用命令行安装(适合开发者)Or use CLI install (for developers)
命令行安装CLI Install
dsh plugin --profile web add github:JonyChan8394/dsh-llm-balance
把 JonyChan8394/dsh-llm-balance 加入你的 DSH 配置(web profile)即可启用。
READMEREADME
dsh-llm-balance
Show the balances of exactly the LLM providers you have configured in dsh, right below the chat input box.
- Below the chat input — a compact readout in the composer's footer band (the seat under the input card, where the stats line lives) that refreshes automatically (default every 60 s) with a manual refresh link.
- Click to recharge — click any provider's balance (or "未开放查询API" label) to open its recharge/top-up page in a new browser tab.
- Driven by your dsh configuration — the strip shows exactly the providers registered in dsh (the Models page /
llm-pi-aisettings + the built-in adapters you use). Configure a new LLM in dsh and it appears on the next refresh; remove it and it disappears. No restart, no config editing. - No public balance API? — providers like Qwen/DashScope, OpenAI and Anthropic have a public API key but no public balance endpoint. When such a provider is configured with a key, the strip shows "未开放查询API / no balance API" instead of hiding it.
- 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 readout appears under the chat input as soon as at least one configured provider has a key.
Configure
Nothing to configure — the plugin follows the providers you already set up in dsh. Balance endpoints are known for these routes:
| Provider route | Balance API |
|---|---|
DeepSeek (deepseek, deepseek-official) |
✅ |
OpenRouter (openrouter) |
✅ |
SiliconFlow (siliconflow) |
✅ |
Moonshot / Kimi (moonshotai-cn, moonshotai) |
✅ |
MiniMax (minimax) |
✅ |
StepFun (stepfun) |
✅ |
Zhipu / GLM (zhipu) |
✅ |
| Any other configured provider | ❌ shows "未开放查询API" |
Each preset also ships a rechargeUrl — the provider's top-up page — opened in a new tab when you click the balance in the strip. To add a balance endpoint for a provider not in the list (e.g. an aggregator route with its own balance endpoint), override the plugin config in your 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
A provider without a configured key is hidden from the strip; a provider whose request fails shows "获取失败 / fetch failed".
How it works
- Host half (
lib/index.js) readsctx.llm.listProviders()— the exact set of LLM routes configured in dsh — on every request. For each provider with a known balance endpoint it resolves the key throughctx.credentialsand calls the endpoint; for a configured provider with a key but no endpoint it reportserror: 'no-api'. Results are served asGET /llm-balanceJSON through the webserver route registry. - Browser half (
lib/client.js) registers aconversation.composer.dockentry (order 10) that polls/llm-balanceand renders the readout under the input card.
License
MIT
nexu-io/open-design
freestylefly/awesome-gpt-image-2
anywhere-labs/dsh-desktop
walkinglabs/learn-harness-engineering
awesome-dsh-plugin/awesome-dsh-plugin
MemTensor/MemOS