JonyChan8394/dsh-llm-balance ↗★ 0
dsh-llm-balance
Show LLM API balances under the chat input: DeepSeek, OpenRouter, SiliconFlow and any custom provider with a balance endpoint.
安装
$
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