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

iamfitzwu-dsh-session-cost

v0.1.1-rc.1

Published

Whole-session DeepSeek cost projection, browser cost tab, and Settings mapping page for local-model developers

Downloads

39

Readme

iamfitzwu-dsh-session-cost

English | 中文

面向本地部署模型开发者的会话级 DeepSeek 费用估算。这个插件注册 sessionCost 投影单元,提供一个展示预计费用的浏览器页,并提供一个用于配置本地模型映射的 Settings 页;它使用当前官方 DeepSeek 费率把日志中的 usage 采样折算成 CNY 费用,方便开发者快速参考本地模型如果按官方服务计费会花多少钱。目前只支持 deepseek-v4-flash 和 deepseek-v4-pro 这两个官方档位,后续还会继续扩展。本地或旧版模型 id 可以通过插件配置里的 aliases 映射到这两个档位,也可以在 Settings 页里编辑。

同一份 aliases 也会出现在 Settings 页里的 session-cost 配置栏中;如果你的部署带了设置页,就可以直接在那里改本地模型映射,而不必手改 cordis.yml。页面会从 Settings 里已经配置好的模型目录读取可选的本地模型 id,因此大多数时候只要下拉选择,不用手写 JSON。保存的数据也会保留提供方路由,方便页面回显;但投影计费仍然只看官方档位。

aliases 变化后,插件会重建投影,所以当前会话的快照会直接按新的映射重新计算,而不只是影响后续请求。Settings 页在保存成功后还会自动刷新当前会话,这样费用页不用手动整页刷新也能看到新结果。

配置

type SessionCostConfig = {
  aliases?: Record<string, 'deepseek-v4-flash' | 'deepseek-v4-pro'>
}

aliases 把请求头里的 config.model 映射到官方费率档位。若模型 id 本身就是官方键,就不需要映射。对于本地部署,这里就是把你的本地模型名映射到官方计费档位。未映射的 id 在投影读取到它们时会直接报错;Settings 页只能提供已经出现在模型目录里的 id 选项。

投影约定

sessionCost 输出整段会话当前的纳元总额,以及按 token 桶拆分的结果:

  • totalNanoyuan
  • inputCacheHitNanoyuan
  • inputCacheMissNanoyuan
  • outputNanoyuan

浏览器侧的 ./client 导出会重新导出这套共享投影词汇,所以 UI 插件可以直接按 useProjection('sessionCost') 取类型,不必导入 host 侧实现。

这个折算会读取持久化的 assistant/chunk 和 assistant/message usage 采样,对同一 step 的重复采样做替换,并用它前面的 request header 选择费率档位。request/header 同时决定该请求是否落在 DeepSeek 北京时间的高峰窗口(9:00-12:00 和 14:00-18:00)。cacheWriteTokens 按 input cache-miss 费率计费,因为当前官方价格页只给出了 cache-hit input、cache-miss input 和 output 三档。

组合

- id: session-projection
  name: '@deepseek-ai/dsh-session-projection'
- id: session-cost
  name: 'iamfitzwu-dsh-session-cost'

session-projection 注册表必须存在。本插件不会自己单独挂载。

Model Experience

None, as the plugin only computes a client-facing read model of already-logged session events and touches no prompt, message, schema, stream, or tool result.

KV Cache effect

None; the plugin never assembles or sends provider requests.

Known Limitations and Deferred Work

  • 只对带 usage 采样的会话计费——如果本地部署没有记录 assistant/chunk 或 assistant/message usage,单靠会话日志无法推回可计费 token。
  • 目前只支持两个官方档位——插件现在只认识 deepseek-v4-flash 和 deepseek-v4-pro,后续还会继续扩展。
  • 未知模型 id 需要别名——本地或旧版模型 id 需要映射到这两个支持的官方档位。
  • 高峰/低峰按请求头时间判断——费率档位看的是请求开始时间,不是回答结束时间。