dsh-api-cost
DeepSeek Harness 插件:实时显示本会话 API 用量开销,按 provider token 用量 × 可配置费率计价,输入栏上方成本条。Real-time per-session API cost meter for DeepSeek Harness: prices provider-reported token usage with configurable rates and shows a live cost chip above the composer.
安装
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:CCCq-C/dsh-api-cost说明文档
阅读完整 README ↗dsh-api-cost
English | 中文
一个 deepseek-harness(dsh)
的 Host + Web Client 插件:实时显示本会话 API 用量开销——把 provider 上报的
token 用量(未缓存输入 / 缓存命中输入 / 输出)按可配置的模型费率计价,在输入栏
上方渲染一条实时成本条。可通过 dsh plugin add 安装。
特性
apiCost会话投影(node half):对会话日志做纯函数折叠,把每个 provider 用量样本按当前模型费率计价——流式 usage chunk 实时更新成本,最终assistant/message不会重复计费。- 输入栏上方成本条(browser half):
API 开销 $0.0023 1.2K + 3.4K tok, 实时刷新;悬停显示分桶明细(输入 / 缓存命中 / 缓存写入 / 输出 + 模型 id)。 - 可配置定价:美元 / 每百万 tokens;未知模型回退默认费率表,按模型覆盖走
插件行的
config(见配置)。 - 中英双语,跟随宿主 UI 语言。
- 自包含:无需改动宿主仓库——包内
cordis.patch.yml以 bundle layer 自动 插入自己的 row。
安装
dsh plugin --profile web add dsh-api-cost
安装器会把包加入 web profile 的 dependencies 与 bundle 列表;重启 dsh web 后
loader 自动应用包内 cordis.patch.yml。然后打开任意会话发一条消息——成本条出现
在输入栏上方,并随 token 流式输出实时增长。
手动安装(同一机制,绕过安装器):编辑 $DSH_HOME/profiles/web/package.json,
在 dependencies 加 "dsh-api-cost": ""、在 dsh.profile.bundles 数组加
"dsh-api-cost",然后在该目录跑 pnpm install 并重启。
Peer 依赖为官方 @deepseek-ai/* 包(^0.1.0-rc.6)与 react,均由宿主提供。
配置
插件自带可用默认值,且没有 Config schema:通过给 profile 的
cordis.patch.yml(如 $DSH_HOME/profiles/web/cordis.patch.yml)里 api-cost
行设置 config 来覆盖定价:
- id: api-cost
config:
currency: USD
# 未知模型回退费率(美元 / 每百万 tokens)
rates:
input: 0.27
cacheRead: 0.07
cacheWrite: 0.27
output: 1.1
# 按模型覆盖(部分对象,缺失字段回退到 rates)
models:
deepseek-chat:
input: 0.27
cacheRead: 0.07
cacheWrite: 0.27
output: 1.1
deepseek-reasoner:
input: 0.55
cacheRead: 0.14
cacheWrite: 0.55
output: 2.19
deepseek-v4-pro:
input: 0.27
cacheRead: 0.07
cacheWrite: 0.27
output: 1.1
deepseek-v4-flash:
input: 0.14
cacheRead: 0.03
cacheWrite: 0.14
output: 0.55