READMESource: main@10633e34
dsh-deepseek-usage
DeepSeek 平台用量面板(DeepSeek Harness Web GUI 客户端插件):
- 💳 账户余额:
api.deepseek.com/user/balance(官方公开接口,Bearer API Key) - 📊 平台用量:镜像
platform.deepseek.com/usage页面的数据 —— 今日/本月 token 与花费、请求数、缓存命中/未命中/输出分类、Top 模型、每日用量热力图、 按月翻页与单日明细(平台私有 dashboard 接口,Bearer userToken) - 🧩 位置:侧边栏底部「DeepSeek 用量」入口(
sidebar.footer.action), 徽标上直接显示当前余额;点击打开浮动面板,收起侧边栏时变为圆形图标按钮 - 🔒 安全:服务端两个接口仅接受本机回环 GET;userToken 默认从
~/.dsh/.credentials.yaml的DEEPSEEK_PLATFORM_TOKEN读取,也可以在面板里 粘贴(只存浏览器 localStorage,仅随请求头发给本机 dsh 服务,绝不落盘)
安装
dsh plugin --profile web add "file:/绝对路径/dsh-deepseek-usage"
# 或者发布到 npm 后:dsh plugin --profile web add dsh-deepseek-usage
重启 dsh web 并在浏览器里硬刷新,侧边栏底部会出现入口。
凭据
| 数据 | 凭据 | 说明 |
|---|---|---|
| 余额 | DEEPSEEK_API_KEY(默认 ref,可配 apiKeyRef) |
通常已配置在 ~/.dsh/.credentials.yaml |
| 平台用量 | DEEPSEEK_PLATFORM_TOKEN(默认 ref,可配 platformTokenRef) |
平台登录会话 token,见下 |
获取 userToken
- 浏览器登录
https://platform.deepseek.com - 打开 F12 → Application(应用)→ Local Storage →
platform.deepseek.com - 复制
userToken的值
两种配置方式任选其一:
- 面板内「配置会话 token」粘贴(推荐,即时生效)
- 写入
~/.dsh/.credentials.yaml:
refs:
DEEPSEEK_PLATFORM_TOKEN: <userToken>
未配置 userToken 时面板仍显示余额,用量区会给出配置引导。
可选配置
cordis.patch.yml 的 insert 条目可加 config:
- insert:
- id: deepseek-usage
name: dsh-deepseek-usage
config:
apiKeyRef: DEEPSEEK_API_KEY # 默认
platformTokenRef: DEEPSEEK_PLATFORM_TOKEN # 默认
refreshMs: 300000 # 服务端缓存 TTL,默认 5 分钟
timeoutMs: 15000 # 上游请求超时,默认 15s
接口
| 端点 | 说明 |
|---|---|
GET /api/deepseek-usage/summary?month=&year= |
余额 + 指定月份用量聚合(带缓存) |
GET /api/deepseek-usage/refresh?month=&year= |
同上,强制刷新 |
搭配 Codex 用量插件
本面板专注 DeepSeek 平台的余额与用量展示;如果你想看 Codex (ChatGPT 订阅) 的配额——
5h / 7d / month 滚动窗口用了多少、多久重置——配套 host 插件
dsh-codex-usage 会把
Codex 配额 + DeepSeek 余额聚合成 GET /api/dsh-usage/overview,本面板的「Codex 订阅」
区块直接消费它(缺端时静默隐藏)。
💡 有 ChatGPT Plus 账号? 搭配 DSH 的 Codex 子代理,日常写码、查资料、跑测试 可以交给 Codex 分担 DeepSeek 的 token 压力;面板在 Codex 干活的同时帮你盯着订阅 额度,真正做到"物尽其用"。
数据源与致谢
- 平台接口(
/api/v0/usage/amount、/api/v0/usage/cost、/api/v0/users/get_user_summary) 及其响应结构、聚合口径参考 CodexBar 的 DeepSeek provider 文档 与DeepSeekUsageCostParser.swift(MIT)。这些是 platform.deepseek.com 的私有 dashboard 接口,非公开 API,可能随上游变化。 - DSH 插件骨架与回环护栏借鉴
@ychris12138/dsh-usage-stats
(MIT):
dsh.bundle.patch+dsh.client+window.__ModuleLoader__.load打包方式、sidebar.footer.action插槽注册、webServer.register精确路由与 loopback 判定。 - 官方文档:client-modules、 ui-sidebar(slot 契约)。
License
MIT
No comments yet. Be the first to write one.