DamonKoy/dsh-plugins--packages-dsh-usage-cost ↗★ 0
dsh-usage-cost
Usage and cost tracking for DeepSeek Harness: accumulates LLM token usage and estimated USD cost from the llm/stream waterfall, settles per-turn deltas into a daily stats file, warns when configured budgets are exceeded, and exposes a usage_report tool plus a usage-cost/status RPC. · DSH 用量与成本统计插件:统计 llm/stream 流式调用的 token 用量与估算费用,按轮次结算到当日统计文件,超出预算阈值时告警。
安装
$
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:DamonKoy/dsh-plugins#fd97e01fb1c26454f27310dd42a6f8d7b66e8e29&path:packages/dsh-usage-cost说明文档
阅读完整 README ↗dsh-usage-cost
DeepSeek Harness(DSH)的用量与成本统计插件,对标 Codex 0.144 的 "usage limit" credits 提醒:实时监控每一次模型调用,维护 token 与 费用累计,并在预算被突破之前给出告警。
English | 中文
功能
- 流式用量统计:挂钩
llm/streamwaterfall,从每个usagechunk 累计inputTokens、outputTokens、cacheReadTokens、cacheWriteTokens、reasoningTokens,不缓存、不改变 chunk 流。 即使一次调用发出多个 usage chunk,也只按一次调用计数。 - 按模型估算费用:每次调用按内置价格表折算 USD(DeepSeek 系输入
$0.28/M、输出 $0.42/M、缓存读 $0.028/M、缓存写 $0.42/M;其他模型
输入 $2/M、输出 $8/M),可在配置中按
provider/model键覆盖。 - 按轮次结算:在
agent/turn-stopping时,把自上次结算以来的新增 用量(仅增量)追加写入~/.dsh/dsh-usage-cost/stats.json,按日期与 按模型分别归档。 - 预算告警:配置了
dailyBudgetUsd/sessionBudgetUsd后,累计 费用跨过阈值时输出一次告警(每日期、每会话各一次):[dsh-usage-cost] 今日用量超预算/本次会话用量超预算。 usage_report模型工具:只读报告今日用量、当前会话用量、按模型 分解以及预算状态(dailyExceeded/sessionExceeded标志)。- 包内私有 RPC:
usage-cost/status返回同样的报告。
安装
dsh plugin --profile web add link:~/dsh-plugins/packages/dsh-usage-cost
重启 dsh web 后生效。默认开启,无配置即可记录用量。
配置
可选配置文件 ~/.dsh/dsh-usage-cost.json:
{
"prices": {
"deepseek-official/deepseek-v4-flash": {
"inputPerM": 0.28,
"outputPerM": 0.42,
"cacheReadPerM": 0.028,
"cacheWritePerM": 0.42
}
},
"dailyBudgetUsd": 2,
"sessionBudgetUsd": 0.5
}
| 字段 | 默认值 | 含义 |
|---|---|---|
prices | {} | 按 provider/model 键覆盖的价格,单位 USD / 每百万 token |
dailyBudgetUsd |