Rainronin/dsh-balance-monitor ↗★ 2
@rainronin/dsh-balance-monitor
实时监测 DeepSeek API 余额与单会话费用 适合需要实时监控 API 余额、估算单次会话费用并掌握峰谷计价状态的用户。
安裝
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:Rainronin/dsh-balance-monitor說明文件
閱讀完整 README ↗Usage
In-session query — just ask the agent:
查一下 DeepSeek 余额 / check my DeepSeek balance
Sidebar badge — at the sidebar footer next to Settings: 刷新 force-refreshes
past the cache; polling follows the host-configured interval (30s by default);
the collapsed (rail) state shows a single status lamp (green = 连接正常,
amber = degraded). The badge follows the dsh native theme. When a conversation is
selected, the badge also shows 本会话 ¥xx.xx — the estimated cumulative cost of
that conversation, calculated from official DeepSeek V4 peak/off-peak pricing;
switching conversations switches the cost automatically.
Configuration
| Key | Default | Meaning |
|---|---|---|
apiKeyEnv | DEEPSEEK_API_KEY | Credential reference (env var name); change for a different account |
cacheTtlMs | 30000 | Cache lifetime in ms |
pollIntervalMs | 30000 | Background polling interval in ms |
injectEveryTurn | false | Whether to inject the balance into context every turn (opt-in; the badge and ds_balance tool are on by default) |
requestTimeoutMs | 5000 | Official-API request timeout in ms |
Override in the profile's cordis.patch.yml:
- id: balance-monitor
config:
cacheTtlMs: 10000
pollIntervalMs: 10000
使用
会话内查询——直接让 agent 查:
帮我查一下 DeepSeek 余额
侧边栏徽章——侧边栏底部(Settings 旁):刷新 按钮穿透缓存立即刷新;
轮询间隔跟随 host 配置(默认 30s);折叠态(rail)显示单色状态灯(绿 = 连接正常,
琥珀 = 异常)。徽章跟随 dsh 原生主题。选中某个会话时,徽章还会显示 本会话 ¥xx.xx——
按 DeepSeek 官方 V4 峰谷价格估算的当前会话累计费用;切换会话时会自动跟随当前会话。
配置
| 键 | 默认值 | 说明 |
|---|---|---|
apiKeyEnv | DEEPSEEK_API_KEY | 凭证引用名(环境变量名),多账号时改这里 |
cacheTtlMs | 30000 | 缓存有效期(毫秒) |
pollIntervalMs | 30000 | 后台轮询间隔(毫秒) |
injectEveryTurn | false | 是否每轮注入余额到模型上下文(默认关闭,按需开启) |
requestTimeoutMs | 5000 | 官方接口请求超时(毫秒) |
覆盖示例(profile 的 cordis.patch.yml):
- id: balance-monitor
config:
cacheTtlMs: 10000
pollIntervalMs: 10000