linshufan21/dsh-Api-monitor
DeepSeek Harness API 余额监测
项目介绍Project Overview
dsh-api-balance 是 DSH 设置面板的 API 余额检测插件。它通过后端回环路由调用 DeepSeek 官方 /user/balance 接口读取账户余额与可用状态,并聚合本地会话日志中的真实 token 用量(输入/输出/缓存/推理),前端在「API 余额」分区展示大额度数字、状态徽章与用量卡片。适用于需要监控 DeepSeek 额度与实际消耗的 DSH 用户。需注意:Key 仅存于后端,浏览器只接收余额数据。
dsh-api-balance is a DSH plugin that adds an API Balance section to the Settings panel. It registers backend loopback routes to query the official DeepSeek /user/balance endpoint and aggregates real token usage (input, output, cache, reasoning) from local session logs, displaying balance, status, and usage cards in the UI. Use it to monitor DeepSeek quotas and actual consumption. Caveat: the API key stays on the backend; the browser only receives balance data, and only DeepSeek accounts are supported.
请帮我了解并安装插件:【dsh-Api-monitor】【https://github.com/linshufan21/dsh-Api-monitor】
把上面这条消息直接发给当前会话里的 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:gaozhiwei521/Deepseek-Harness-Api-monitor
把 linshufan21/dsh-Api-monitor 加入你的 DSH 配置(web profile)即可启用。
READMEREADME
dsh-api-balance — API 余额检测插件
在 DSH「设置」面板新增 API 余额 模块:实时查询已配置供应商(DeepSeek)的账户余额、可用状态与真实 Token 用量,支持手动刷新。API Key 只存在于后端,浏览器只会拿到余额数据。
快捷安装(推荐,DSH 原生插件指令)
插件已声明为 DSH bundle,一条命令即可从 GitHub 安装到 web profile:
dsh plugin --profile web add github:gaozhiwei521/Deepseek-Harness-Api-monitor
装完重启 DSH(退出「DSH 对话」再打开),在「设置 → API 余额」即可看到界面。
⚠️ 迁移注意:若之前用过下方的手动 Copy-Item 安装,请先移除
cordis.patch.yml中的api-balanceinsert 块,并删除~\.dsh\profiles\node_modules\dsh-api-balance\,避免与 bundle 双份注册。
安装位置
- 源码(本目录):
E:\deepseekwork1\dsh-api-balance\ - GitHub:
gaozhiwei521/Deepseek-Harness-Api-monitor - bundle 补丁:
extensions/dsh/cordis.patch.yml(dsh plugin add自动应用) - 手动装载补丁(旧方式):
~\.dsh\profiles\web\cordis.patch.yml
工作原理
| 层 | 实现 |
|---|---|
后端 lib/index.js |
注册两条回环路由:GET /dsh-balance/query(通过 credentials.resolve() 读取 DEEPSEEK_API_KEY,调用 {baseURL}/user/balance)和 GET /dsh-balance/usage(聚合本地会话日志中的真实 token 用量,60s 缓存)。baseURL / apiKeyEnv 跟随「设置 → 模型」里 llm-deepseek 配置段的覆盖。 |
前端 lib/client.js |
注册 settings.section 槽位(id=api-balance,label=「API 余额」):可用额度大数字 + 可用状态徽章 + 用量卡片(累计/今日 Tokens、会话数、用量记录)。样式全部使用全局 --dsw-alias-* 主题令牌,与暗色主题一致。 |
手动安装(旧方式,DSH 升级后插件可能丢失时备用)
# 1) 把包放到 profiles\node_modules
Copy-Item 'E:\deepseekwork1\dsh-api-balance\package.json' "$env:USERPROFILE\.dsh\profiles\node_modules\dsh-api-balance\" -Force
Copy-Item 'E:\deepseekwork1\dsh-api-balance\lib' "$env:USERPROFILE\.dsh\profiles\node_modules\dsh-api-balance\lib" -Recurse -Force
# 2) 确认 cordis.patch.yml 末尾有 api-balance insert 块(升级若覆盖则重新追加)
# 3) 重启 DSH(退出「DSH 对话」再打开;或杀掉后端进程由桌面壳看门狗自动拉起)
卸载
dsh plugin --profile web remove dsh-api-balance
(旧手动安装方式:1. 删除 cordis.patch.yml 中 api-balance 的 insert 块;2. 删除 ~\.dsh\profiles\node_modules\dsh-api-balance\;3. 重启 DSH。)
测试
node 'E:\deepseekwork1\dsh-api-balance\test\unit.test.mjs' # 后端逻辑(13 项)
node 'E:\deepseekwork1\dsh-api-balance\test\client-load.test.cjs' # 前端模块结构
已知说明
- 用量为真实数据:DeepSeek 无公开用量 API(
/user/usage实测 404),因此消耗数据来自本地会话日志中每次调用的真实 token usage(输入/输出/缓存/推理),非估算。 - 赠送余额:账户无赠送余额(0)时自动隐藏该项。
- 默认读取
DEEPSEEK_API_KEY;若模型设置在「设置 → 模型」中改过 Key 引用或 baseURL,插件自动跟随。 - 仅支持 DeepSeek 官方账户余额接口;其他供应商的余额接口暂未接入。
MeteorNOX/DeepSeek-Balance-Whale-Widget
Han-1413141/dsh-cost-meter
zh667/TokenLedger
wssfk12138/dsh-damage-pulse
Ychris12138/dsh-usage-stats
yxxbc/dsh-balance-plugin
multica-ai/dsh-multica-runtime