Yvesgao/dsh-cost-estimate 预览 preview

Yvesgao/dsh-cost-estimate

Plugin插件 Native原生 ⭐ 2 MIT Usage & Cost用量与计费

在 DSH Web 聊天界面里,当你发送一条比较大的问题时,回答开始之前会在聊天流中插入一行内联通知,预估这次回答大概需要多少 token、折合 DeepSeek API 多少钱;回答结束后,同一行自动更新为实际的 token 用量与费用。

catalog descriptioncatalog 简介 / catalog description:DSH 插件:回答前先预估 token 用量与 DeepSeek API 费用,回答后展示实际账单(Web 聊天内嵌行)

Project Overview项目介绍

This is a native plugin built exclusively for DeepSeek Harness (DSH) that provides token usage estimation and cost reconciliation before and after a large language model generates a response. It can be installed via the DSH CLI with the command dsh plugin --profile web add dsh-cost-estimate, or desktop DSH users can find it in the official plugin market for one-click installation. After installation, you need to restart dsh web and force-refresh your browser page to load the plugin properly, and the installation process requires pnpm to be installed globally on your system.

When you send a large request, the plugin inserts an inline notification in the chat stream with an estimated range of tokens and cost before the model starts generating. After the response is complete, it updates that same line with the actual token usage and cost pulled from the DeepSeek API provider response. It only triggers when the request meets a configurable threshold, which defaults to 8000 input tokens or 0.01 yuan estimated cost, so small requests don’t get annoying notifications, and it avoids cluttering your chat interface with unnecessary alerts.

This plugin is implemented purely on the client side, with all calculations and rendering done in the DSH web client, so it does not write any custom data to session logs and can be safely installed or removed without breaking existing sessions. It is released under the open source MIT license, and the embedded pricing matches DeepSeek’s official pricing as of 2026, so if DeepSeek updates their pricing later, you will need to manually update the price constants in the plugin’s source code. All estimates are provided for reference only, and actual billing is determined by DeepSeek’s official API calculation.

这是一个专为 DeepSeek Harness(DSH)开发的原生插件,功能是在大模型回答前后提供 token 用量预估和实际费用对账。当用户发送大体积请求时,插件会在聊天流插入内联通知,先给出预估的 token 区间和费用范围,等回答结束后,同一位置自动更新为 DeepSeek API 返回的实际用量与最终费用。和其他事后统计类插件不同,它主打事前预估,帮助用户提前把握调用成本。

插件默认仅当预估输入 token 超过 8000 或预估费用超过 0.01 元时才触发提示,小请求静默不打扰,避免刷屏。它内置 DeepSeek 官方最新价目表,支持 deepseek-v4-flash 和 v4-pro 两款模型,会根据当前北京时间自动选择高峰、平峰、低谷的对应计价档位,费用计算完全贴合官方最新定价规则。

本插件为纯客户端实现,所有计算和渲染都在 DSH Web 客户端完成,不会向会话日志写入自定义数据,安装卸载都不影响已有会话,可安全装卸。它采用 MIT 许可证开源,用户可通过 DSH CLI 命令从 npm 安装,桌面端用户也可在插件市场搜索一键安装,安装后需强制刷新浏览器页面生效。

Pre-install check安装前体检Compatibility · Security兼容性 · 安全性 1 warning1 项注意
  • Only 2 stars - very few users, little community feedback星标只有 2,几乎没人在用,遇到问题缺少社区反馈
DSH walks through these 9 checksDSH 会逐条核对这 9 项

Compatibility兼容性

  • DSH, Node, OS and profile requirementsDSH 版本 / Node 版本 / 操作系统 / profile 是否满足要求
  • External dependencies and runtimes (Electron / Python / Docker, ...)外部依赖与运行时(Electron / Python / Docker 等)是否齐备
  • Conflicts with installed plugins: command names, skill / tool names, ports, duplicate MCP registration与已装插件是否冲突:命令名、skill / tool 重名、端口占用、重复 MCP 注册

Security安全性

  • Repo matches the facts registered here; archived or abandoned?仓库是否与页面登记一致,是否归档或长期停更
  • Safety of preinstall / install / postinstall and install.sh / setup.ps1preinstall / install / postinstall 与 install.sh、setup.ps1 是否安全
  • curl|bash, download-then-execute, obfuscation, unrelated domains → stop immediatelycurl|bash、下载即执行、混淆代码、无关域名 → 立刻停止
  • Typosquatting or unmaintained packages among the new dependencies新增依赖里有没有 typosquatting 或无人维护的包
  • Requested permissions vs. what the feature actually needs申请了哪些权限、是否超出功能所需(filesystem / network / shell / clipboard)
  • Any sudo / admin requirement, plus uninstall and rollback是否要求 sudo / 管理员权限,以及卸载与回滚方式

Anything uncertain must be marked unknown with a note on how to confirm it. This site's signal screen is a static snapshot, not a security audit.拿不准的必须标「未知」并说明要我怎么确认。本站的信号筛查是静态快照,不能替代安全审计。

Or use CLI install (for developers)或使用命令行安装(适合开发者)

CLI Install命令行安装

dsh plugin --profile web add dsh-cost-estimate

把 Yvesgao/dsh-cost-estimate 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

dsh-cost-estimate

DeepSeek Harness(DSH)插件 —— 回答之前先报价,回答之后看账单。

在 DSH Web 聊天界面里,当你发送一条比较大的问题时,回答开始之前会在聊天流中插入一行内联通知,预估这次回答大概需要多少 token、折合 DeepSeek API 多少钱;回答结束后,同一行自动更新为实际的 token 用量与费用。

与社区已有插件(dsh-session-cost / dsh-token-budget / dsh-usage 等)的关键区别:那些都是事后用 provider 返回的 usage 统计账单;本插件是事前预估——输出长度天然无法精确预测,因此给出区间,并用会话内历史实际值做持续校准。


✨ 特性

  • 事前预估:模型开始生成前,先显示预估的输入 token、输出 token 区间和费用区间
  • 事后对账:回答结束(拿到 provider 真实 usage)后,同一行翻转为实际 token 与费用,并展示缓存命中率
  • 阈值触发,不刷屏:默认"预估输入 ≥ 8000 token 或预估费用 ≥ ¥0.01"才显示,小问题静默、大问题必提示
  • 峰谷计价:内置 DeepSeek 官方价目(deepseek-v4-flash / v4-pro),按当前北京时间自动选择高峰/低谷档位
  • 输入侧尽量精确:优先锚定每次请求真实返回的 usage,中间穿插用 CJK 感知的启发式计数兜底
  • 输出侧持续校准:用会话内"预估中点 vs 实际输出"的滑动均值校准后续预估,越用越准
  • 纯客户端、零侵入:全部计算与渲染在 Web 客户端完成,不向会话日志写入任何自定义事件,装/卸插件不影响已有会话
  • 多步回合友好:工具调用循环会标注"多步",并累计真实费用

效果示例

发送一个大问题(例如几千字的设计文档评审请求)后:

预估:输入约 9.9K tok · 输出 2.2K–7.3K tok · 费用约 ¥0.0096–¥0.0198(v4-flash)

模型回答结束后,同一行自动翻转为:

实际:输入 9.1K tok · 输出 1.1K tok · 费用 ¥0.02(缓存命中 87% · v4-flash)

演示

dsh-cost-estimate 演示


安装

# 从 npm 安装(推荐)
dsh plugin --profile web add dsh-cost-estimate

# 本地开发 / 尝鲜(从源码目录安装)
dsh plugin --profile web add <本目录路径>

安装后重启 dsh web,并在浏览器中强制刷新(Ctrl+Shift+R)以加载新插件。桌面端用户也可以在插件市场搜索 dsh-cost-estimate 一键安装。

注意:DSH 的 dsh plugin 命令依赖 pnpm(npm install -g pnpm);Windows 上安装路径含空格时请使用无空格的路径(如 junction)避免解析错误。


配置

cordis.patch.yml 中 config 支持以下键:

键 默认值 说明
minInputTokens 8000 预估输入超过该 token 数才显示
minCostCny 0.01 或预估费用上限超过该元数才显示
defaultModel deepseek-v4-flash 首次 usage 锚定前的模型回退值
headerTokensEstimate 6000 首次 usage 锚定前,系统提示词 + 工具 schema 的启发式 token 数
defaultCacheHitRatio 0.5 首次 usage 锚定前假定的缓存命中率

示例:

- id: cost-estimate
  name: dsh-cost-estimate
  config:
    minInputTokens: 20000
    minCostCny: 0.05

定价

内置 DeepSeek 官方定价(¥/百万 token,与 api-docs.deepseek.com 对齐):

模型 缓存命中输入 未命中输入 输出
deepseek-v4-flash(2026-08-17 前) ¥0.02 ¥1 ¥2
deepseek-v4-pro(2026-08-17 前) ¥0.025 ¥3 ¥6
flash · 高峰(北京时间 9-12 / 14-18) ¥0.10 ¥3 ¥9
flash · 低谷 ¥0.05 ¥1.5 ¥4.5
pro · 高峰 ¥0.30 ¥9 ¥27
pro · 低谷 ¥0.15 ¥4.5 ¥13.5

Showing the opening section of the README — the full document lives in the repository以上为 README 开头摘要,完整文档在仓库内 · View the full README on GitHub →在 GitHub 查看完整 README →

← 上一个 Prev dsh-better 下一个 Next dsh-asc →