dsh-budget
花费门禁:在 llm/stream 瀑布上于计费前拒绝超预算调用,超软阈值自动降级模型
frozo-ai
@frozo-ai
⬇ 2
★ 0
master
安装
dsh plugin --profile web add github:frozo-ai/dsh-budget
需要可复现安装时,可在仓库后追加 #commit 固定提交。
花费门禁:在 llm/stream 瀑布上于计费前拒绝超预算调用,超软阈值自动降级模型
该插件未提供要点说明,请参考仓库 README。
cost-managementdeepseek-harnessdshdsh-pluginfinops
- 安装并启动 DeepSeek Harness:
npx @deepseek-ai/dsh web - 在终端执行上面的安装命令(CLI 会解析插件并核验来源)
- 用 dsh plugins list 确认已安装,必要时重启 Harness 生效
插件以当前 dsh 进程的权限运行,安装时可能执行代码。请先通读仓库源码与许可证,确认无破坏性命令与越权访问;本站只做索引,不对第三方插件安全性作担保。
| 代码仓库 | github.com/frozo-ai/dsh-budget |
| 许可证 | 未标注(见仓库) |
| 主要语言 | master |
| 下载量 | 2 |
| GitHub 星标 | 0 |
| 最近推送 | 2026-08-18 |
| 收录日期 | 2026-09-19 |
| 分类 | 工具与能力 |
事实信息来自公开插件目录快照(2026-10-03),介绍文案由本站再加工。
以下为插件仓库 README 全文(原始内容,由公开目录抓取整理)。
# dsh-cost-gate
**Spend enforcement for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) — not another dashboard.**
The dsh ecosystem has plenty of cost plugins. Every one of them *measures*:
ledgers, statistics, heatmaps, balance widgets. They tell you what you spent
**after you spent it**.
This one **stops the call**.
```
┌─ over budget? ──> throw, before a single token is billed
llm/stream waterfall ─┼─ past 80%? ────> silently route to the cheap model
└─ fine? ────────> pass through, then meter the usage chunk
```
`llm/stream` is a cordis **waterfall** — the decision happens *before* `next()`
runs, which is the only place enforcement can actually work.
## Install
```sh
dsh plugin --profile web add github:frozo-ai/dsh-budget # npm: dsh-cost-gate
```
```yaml
- insert:
- id: budget
name: 'dsh-cost-gate/plugin'
config:
limitUsd: 50
period: monthly # daily | monthly | total
softFraction: 0.8 # start downgrading at 80%
downgradeModel: 'deepseek/deepseek-chat'
storePath: '~/.dsh/spend.json'
rates: # USD per MILLION tokens
'deepseek/deepseek-chat': { input: 0.28, output: 0.42 }
'anthropic/claude-3.5-sonnet': { input: 3, output: 15 }
```
Set `dryRun: true` to log decisions without blocking — roll out safely, then
turn it on.
## Design notes
**Integer micro-dollars.** Costs accumulate as integers, never floats. A test
runs 10,000 calls and asserts zero drift, because this decides whether people
get blocked.
**Cache tokens are disjoint.** Per dsh's `TokenUsage` contract, `cacheRead` and
`cacheWrite` are *not* included in `inputTokens`, so they're added at their own
rates rather than folded in.
**Atomic ledger writes.** Temp file plus rename — a torn write must not lose
budget state.
**UTC period boundaries**, so a daily budget resets at a time everyone agrees on.
**Fails open, deliberately.** No `limitUsd` means metering only. Enforcement is
opt-in: a budget plugin that accidentally blocks your whole team is worse than
one that doesn't block at all.
## Related work
[`PerryLink/dsh-budget`](https://github.com/PerryLink/dsh-budget) covers similar
ground — metering, caps, alerts, carbon estimates, a Settings tab. If you want
dashboards and reporting, look there first. This plugin is narrower on purpose:
it gates the `llm/stream` waterfall so an over-budget call is refused *before*
it is billed, and does little else.
## Known limitations
- **Scope is the whole deployment, not per-user.** Per-user attribution needs
identity plumbed from the gateway down to the llm layer; dsh has no user
concept at that seam yet. One budget per deployment still prevents the
surprise bill, which is the thing people actually get hurt by.
- **Unknown models price as $0** rather than crashing. Add them to `rates`.
- Pricing tables are yours to maintain; providers change rates.
## Test
```sh
npm test # 17 checks: pricing, drift, periods, durability, decisions
```
MIT. Not affiliated with DeepSeek AI.
数据来源:公开的 DeepSeek Harness 插件目录与各插件 GitHub 仓库。本站为独立第三方目录,与 DeepSeek、幻方(High-Flyer)及插件作者均无隶属或背书关系。