dshbase

插件目录 / Developer / dsh-calculator

dsh-calculator

已验证 · 实测可装 bobcat848

✓ 持续维护 2 位贡献者 基于 2 个官方 DSH 包

查看 GitHub ↗ ← 返回插件目录

4Stars
0Forks
1未关闭 issue
JavaScript语言
2026-08-14最近推送
跨平台平台

功能简介

计算DeepSeek API调用的实时成本

✅
我们的评价
可用 — 实测通过,早期项目

计算DeepSeek API调用的实时成本 实测能干净安装、正常启动。早期项目,但功能可用。

「已验证」表示我们的自动化 CI 在干净 profile 里实际执行了 dsh plugin add 并启动成功——仅此而已。功能描述与版本兼容性均为作者声明。这不是安全审计,也不代表对第三方代码的背书。

README

dsh-calculator

A DeepSeek Harness (DSH) web plugin that shows your DeepSeek API spend and
account balance in a top-right floating card of the DSH web GUI
(collapsible to a pill).

  • 当前会话费用 — the cost of the session you are looking at (per model)
  • 当天全部会话累计 — today's total spend across all sessions (per model,
    in your local timezone; resets at local midnight)
  • 账户余额 — live balance from the DeepSeek API (GET /user/balance)
  • 第三方模型不计费 — only deepseek-official routes are billed; any other
    provider/model is listed as unbilled
  • 峰谷计价 — after 2026-08-17 the plugin automatically prices events by the
    Beijing peak/off-peak schedule (peak 09:00–12:00 & 14:00–18:00, off-peak =
    half price); before that date it uses the current flat rates
  • 中英文界面 — the panel follows your browser language (zh / en)

安装

DSH is a Cordis application. The plugin has a host half (event accounting +
balance fetching) and a browser half (top-right overlay card). Install it into
the web profile:

一条命令在线安装(推荐,无需克隆仓库)

直接在你的机器上执行(脚本会从 GitHub 下载插件文件并完成安装):

# macOS / Linux
curl -fsSL https://raw.githubusercontent.com/bobcat848/dsh-calculator/main/install.sh | bash

# Windows PowerShell
irm https://raw.githubusercontent.com/bobcat848/dsh-calculator/main/install.ps1 | iex

本地克隆安装

或者克隆仓库后运行脚本(安装脚本会自动识别本地模式,从仓库内复制文件):

git clone https://github.com/bobcat848/dsh-calculator.git
cd dsh-calculator

# macOS / Linux
bash install.sh

# Windows PowerShell
.\install.ps1

两种方式等价:都会把插件装进
~/.dsh/profiles/node_modules/dsh-calculator 并在
~/.dsh/profiles/web/cordis.patch.yml 追加 loader 行(幂等:重复执行安全,
已有行不会重复添加)。

手动安装

# 1. copy the package into the profile's hoisted node_modules
mkdir -p ~/.dsh/profiles/node_modules/dsh-calculator
cp -r lib package.json ~/.dsh/profiles/node_modules/dsh-calculator/

# 2. append the loader row to the web profile patch (once)
#    edit ~/.dsh/profiles/web/cordis.patch.yml and add:
#    - insert:
#        - id: dsh-calculator
#          name: 'dsh-calculator'
#          config: {}

重启生效

Plugins are discovered at boot, so restart DSH web after installing
(cordis.patch.yml 改动也会被 DSH 的用户层 HMR 热更新,通常无需重启):

dsh web --port 3080

Open (or refresh) http://127.0.0.1:3080, and you should see the
DeepSeek API 费用 card in the top-right corner; click × to collapse it
into a pill, click the pill to expand it again.

v1.2.0 适配说明:DSH 0.1.0-rc.6 的布局不再提供 aside 插槽(右侧栏),
浏览器半改为注入框架级 shell.overlay 插槽(右上角浮层卡片),并移除了
不存在的 ctx.layout.closeAside()。host 半(记账 + 余额端点
/dsh-calculator)保持不变。


配置

The plugin needs no configuration beyond your DeepSeek API key, which DSH
already stores through its credentials service (the Models page writes it to
~/.dsh/.credentials.yaml as DEEPSEEK_API_KEY, or you can export it in the
launching environment). The balance feature reads that same credential.

If the key is missing, the balance card shows a friendly error and the cost
panel keeps working.

计价口径

Rates are the official DeepSeek prices (CNY per 1M tokens):

模型 缓存命中输入 缓存未命中输入 输出
deepseek-v4-flash(当前价) ¥0.02 ¥1.0 ¥2.0
deepseek-v4-pro(当前价) ¥0.025 ¥3.0 ¥6.0
2026-08-17 起(峰谷) 高峰半价 高峰价 高峰价
  • 输出 token 包含推理 token,与普通输出同价
  • 费用为估算值,与官方账单可能存在差异(缓存命中 token 量大时尤其明显)

数据来源

  • 费用:host 半订阅 DSH 会话事件(assistant/message 的 usage +
    message.source),按 (provider, model) 记账;fork 子会话的拷贝事件按
    message.id 全局去重,避免重复计费
  • 余额:GET https://api.deepseek.com/user/balance(30 秒缓存)

卸载

rm -rf ~/.dsh/profiles/node_modules/dsh-calculator
# 并从 ~/.dsh/profiles/web/cordis.patch.yml 删除对应 insert 行

免责声明

本项目与 DeepSeek 官方无任何关联,价格与余额为接口实时数据,费用为估算。

安装

🧩 让 Agent 自动装(推荐)

装一次目录插件,之后本站所有插件都能让 DeepSeek Harness 自动找、自动装:

dsh plugin add dshbase-catalog

然后对 agent 说「帮我装 dsh-calculator」,它会在目录里找到并自动安装。文档:dshbase-catalog · 已验证场景包。

该插件是 GitHub 源码(未发 npm)——直接从仓库装:

Web profile:

dsh plugin --profile web add github:bobcat848/dsh-calculator

Headless(CLI)profile:

dsh plugin --profile headless add github:bobcat848/dsh-calculator

实测报告

验证通过:从 GitHub 源码完成 L1 安装 + L2 加载 + L3 运行(dsh 0.1.0-rc.6)。

使用场景

扩展 agent 的编码能力面——给它一个新工具、工作流或集成,让它接手以前做不了的开发任务。

适合谁

想让 dsh 在真实代码库上像队友一样干活的开发者——能改、能跑、能验证,而不只是回答问题。

二次开发建议

工具/命令面就是缝:暴露更多 SDK 能力、加更聪明的上下文接线,或收紧改代码与验证之间的循环。

安全:尚未扫描——我们的每日静态扫描将很快覆盖它。

分享徽章

Developer 里更多

浏览全部 7797 个插件 →