npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dsh-api-ledger

v0.2.2

Published

API token usage and estimated cost reports for DeepSeek Harness, with per-route pricing, session totals and CNY/USD display.

Readme

DSH API 账本

English / 中英双语

功能概览:演示数据

功能示意图,使用演示数据,不是真实账户截图。

不用离开会话,就能查看本次对话花了多少钱。

API 账本把 Token 用量和 API 估算费用放进 DSH:会话完整报告、设置页总览、输入框下方的会话金额,以及左下角的一行今日金额。

哪些地方用起来方便?

  • 随手查看费用:不用频繁打开独立报表;会话费用放在输入框下面,今日费用放在侧边栏,点击即可打开设置中的账本。
  • 相同模型可以按不同接口计价:价格按「路由 + 模型」配置,官方接口和企业网关互不混用。
  • 分组由使用者决定:默认按路由分别统计,需要时再设置相同账单分组。不会因为共用凭据引用就自动合并,也不会把展示分组当作共用余额。
  • 四处展示同步切换币种:CNY/USD 选择会保存并同步,避免不同页面各用一种显示币种。
  • 能看懂费用怎么来的:最近调用标明计价来源,未配置单价显示未计价,历史记录保留当时使用的单价。
  • 无需部署额外服务:用量与配置保存在本机,不读取 API Key 的值,也不上传到插件自建的统计服务。

这些是插件的具体使用价值,不代表其他用量插件都不具备相同能力。这里统计的是已记录用量与估算费用,不是供应商账单或账户余额。

四处展示

| 位置 | 用途 | | --- | --- | | 会话 → API 账本 | 本会话费用、最近调用、模型分布、Token 构成和用量趋势 | | 设置 → API 账本 | 跨会话报表、周期筛选、今日/昨日对比、账户与计价 | | 会话输入框下方 | 本会话已用金额 | | 侧边栏左下角 | 单行今日费用,点击打开账本设置 |

安装

需要 Node.js 20+ 和兼容的 DSH。已在 DSH Desktop 2.0.13/内置 DSH 0.1.5-rc.2 验证;插件无需构建,没有运行时 npm 依赖。

DSH Desktop:从 GitHub 安装

git clone https://github.com/LAwLi3tCoding/dsh-api-ledger.git
cd dsh-api-ledger
node scripts/install.mjs

重启 DSH 后,打开「设置 → API 账本」或会话的「API 账本」Tab。安装使用本地链接,请保留克隆目录。更新时执行 git pull 后重启;卸载该链接安装时执行 node scripts/install.mjs --uninstall。

DSH CLI:安装到 CLI 管理的 profile

# GitHub 安装
dsh plugin --profile web add github:LAwLi3tCoding/dsh-api-ledger

# npm 版本发布后可使用
dsh plugin --profile web add dsh-api-ledger

将 web 换成自己的 CLI profile。DSH 0.1.5-rc.2 的 desktop profile 由 Electron 专管,不能直接使用 dsh plugin --profile desktop add ...。桌面端请使用上面的安装脚本,或在市场收录完成后通过桌面市场安装;提交 PR 不等于已经上架。

配置计价

打开「设置 → API 账本 → 账户与计价」,选择路由和模型。每个模型单独保存,切换前先保存当前修改。

| 方式 | 含义 | | --- | --- | | 官方价表估算 | 已识别的 DeepSeek 官方直连在没有显式配置时默认使用,按内置 USD 价表及峰谷规则估算 | | 参考价估算 | 手动选择固定的官方非高峰 USD 快照,不判断时间和节假日 | | 自定义单价 | 按每百万 Token 填写非缓存输入、输出、缓存读和缓存写价格及币种;允许零价格 | | 仅记录用量 | 不猜测费用;其他接口的默认方式 |

官方接口按实际 URL 识别,并考虑 DeepSeek 适配器的启动环境覆盖;名称包含 DeepSeek 不代表官方直连。内置官方价表核验日期为 2026-09-21,支持 deepseek-flash、deepseek-v4-flash、deepseek-v4-flash-vision-exp 和 deepseek-v4-pro。按请求开始时间及 2026 年中国节假日判断峰谷;未知模型或其他日历年份仅记录用量。价表随插件版本更新,并非实时拉取。

名称与分组调整会更新历史报表的展示,修改单价只影响后续调用。已有自定义配置不会被升级覆盖。重置/删除账本配置保留 DSH 模型配置与历史调用。历史及停用路由单独折叠展示;只有账本配置、没有历史和当前模型配置的路由,删除后会从列表消失。

统计边界与本地数据

  • CNY/USD 是展示折算,固定使用 1 CNY = 0.14 USD,不是实时汇率,也不是供应商的币种结算比例。
  • 调用结束并上报用量后计入;页面可见时每 10 秒刷新。「今日」按客户端本地日历计算。
  • 金额是估算费用,不是官方账单、余额、预算或订阅扣费。部分调用未计价时,只汇总已知费用。
  • 历史金额和原始单价不变。疑似将 USD 数字标成 CNY 的旧记录会显示提示,不自动重算。
  • 非缓存输入与缓存 Token 分开计价,推理 Token 不重复累加;适配器需要提供兼容的标准化用量。
  • 安装前的调用不补录。缺失用量无法恢复,当前进程会显示缺失次数。嵌套调用会去重,但一个外层调用扇出多个上游流仍可能漏计。
  • 配置位于 $DSH_HOME/api-ledger/config.json;逐次记录保存在 records.jsonl,rollup.json 为派生汇总。未设置 DSH_HOME 时使用 ~/.dsh/api-ledger/。这些本地数据及凭据不随插件分发。内存最多保留最近 200,000 条记录。

开发与反馈

npm run check
npm test
npm pack --dry-run

测试覆盖计价边界、官方接口识别、历史金额不变、配置冲突、同源写入、流式捕获、报表周期、双语与四处展示。问题请提交到 Issues,使用匿名示例,不要上传 API Key 或私人会话日志。

许可证:MIT。