跳到正文

LaoYueHanNi/dsh-token-usage

51最近提交 2026年8月15日

dsh-token-usage DSH 插件

安装后,在设置中找到 Token Usage 页面,包含摘要卡片、每日图表、按模型细分和定价对话框。它通过实时钩子记录每次请求的 token 使用,并支持历史数据回填。成本根据模型费率实时计算,支持自动云定价和手动覆盖。

如何安装 dsh-token-usage DSH 插件

dsh plugin --profile web add github:LaoYueHanNi/dsh-token-usage

复制不会执行命令。安装 dsh-token-usage DSH 插件前请核对仓库和版本。

dsh-token-usage DSH 插件数据来源

dsh-token-usage DSH 插件快照日期:2026年8月16日

discovered

dsh-token-usage DSH 插件能做什么

  • 实时钩子:将每次成功的模型请求记录到每日 JSONL 文件中(请求 ID、模型、token 数、时间、会话 ID)。
  • Web 统计页面:支持日期范围和模型筛选、1d/7d/30d 快捷按钮、摘要卡片、每日趋势图、带成本列的按模型表格。
  • 成本计算:根据模型费率计算每次请求的成本,显示总成本卡片,对未定价模型显示警告。
  • 历史回填:首次启动时同步安装前的请求。
  • 模型定价对话框:显示每个模型的完整费率表,包括上下文层级、高峰时段和时间规则。

dsh-token-usage DSH 插件适合哪些场景

  • 实时监控不同模型的 API token 消耗和成本。
  • 分析每日 token 使用趋势,优化模型选择或预算。
  • 查看按模型划分的 token 使用和成本,用于分配或计费。
  • 为云定价源未覆盖的模型手动设置定价覆盖。
  • 在插件安装后回填历史 token 使用数据。

dsh-token-usage DSH 插件适合谁

  • 关注 API token 消耗和成本的 DSH 用户。
  • 管理多个模型并需要优化开支的开发者或团队。

dsh-token-usage DSH 插件的限制

  • 仅适用于 DSH 的 web profile(安装命令指定了 --profile web)。
  • 定价依赖于云定价源;若不可用,模型可能显示为未定价,成本计为 ¥0。
  • 数据文件存储在 ~/.dsh/token-usage/ 目录下,如需删除需手动清理。

dsh-token-usage DSH 插件的仓库 README 摘录

以下文字摘自 dsh-token-usage DSH 插件的上游仓库 LaoYueHanNi/dsh-token-usage 的 README,版权归原作者,仅作引用。

A dsh usage plugin that displays model token usage right in the Web UI. After installation, open **Settings** (the gear icon in the sidebar) and you'll find the **Token Usage** page — summary cards (with cost), a daily total-token line chart, a per-model breakdown, and per-model pricing dialogs, all filterable by date range and model, exactly as shown in the screenshot above. [dsh]: https://github.com/cordiverse/dsh Repo: <https://github.com/LaoYueHanNi/dsh-token-usage> ## Features - **Live hook**: every successful model request is appended to per-day JSONL files (request id, model, input / output / cache-read / cache-write tokens, time, session id). - **Web stats page**: filters (date range + model + `1d`/`7d`/`30d` shortcuts), summary cards, daily trend chart (hover a day for its total), per-model table. - **Cost figures & model pricing**: per-request cost is computed live from per-model rates (¥ per million tokens) — a highlighted total-cost card, a cost column in the per-model table, and a warning strip for unpriced models (their cost counts as ¥0). Every priced model's name carries a small **rates button** that opens a dialog with that model's full price table: **each row

阅读完整 README仓库未声明许可,使用前请先与作者确认。

dsh-token-usage DSH 插件常见问题

如何安装这个插件?

在终端中执行 `dsh plugin --profile web add github:LaoYueHanNi/dsh-token-usage`。该包声明了 `dsh.bundle`,因此会自动集成到 profile 中,无需手动配置。

如何更新插件?

使用 `dsh plugin --profile web update dsh-token-usage` 命令即可。它会从 GitHub 拉取最新版本并应用到你的 web profile。

token 使用数据存储在哪里?

默认存储在 `~/.dsh/token-usage/` 目录下。你可以在插件设置中通过 `path` 配置路径。数据包括每日的 JSONL 文件和定价文件。

如何为模型设置自定义定价?

编辑数据目录下的 `pricing.json` 文件。为模型添加条目,包含 `inputPerMillion` 和 `outputPerMillion`(可选 `cacheReadPerMillion` 和 `cacheWritePerMillion`)。保存后刷新统计页面即可生效。

如何完全移除插件?

执行 `dsh plugin --profile web remove dsh-token-usage` 可从 profile 中移除插件。`~/.dsh/token-usage/` 下的数据文件会保留,如需删除请手动清理。