dsh-token-cost
by gdy01
DSH 插件:按模型标准价统计各项目的 LLM token 用量与人民币成本(输入 / 缓存命中 / 输出)
DSH plugin: per-project LLM token usage and RMB cost (input / cache-hit / output) based on model standard prices.
安装
dsh plugin --profile web add github:gdy01/dsh-token-costGitHub 源码安装:首次需按提示配置 allowBuilds 构建授权后重试
安装与环境配置指引、插件开发教程见 DSH 中文社区文档 ↗
安装即在你的机器上以你的权限运行第三方代码——它可读写文件、使用凭据、访问网络,DSH 的工具审批不会为插件代码加沙箱。「检测到 manifest」仅代表发现 dsh.bundle / dsh.plugin 清单,不构成兼容性或安全审查;安装前请审阅源码,不熟悉的插件先在不含密钥的环境试用。
README
一个 DSH 插件:按项目展示 LLM Token 用量,并按模型标准价格自动换算成人民币花费,分为:
- 输入(未命中) —— 未命中缓存的输入 token
- 命中 —— 缓存命中的输入 token(
cacheReadTokens) - 输出 —— 输出 token
未知模型会照常列出 token 数,但费用显示为「—」,方便你直接补充价格,无需改代码。
功能
- 读取本地 DSH 会话日志(
~/.dsh/sessions或$DSH_HOME/sessions)。 - 按项目(会话
cwd)和模型聚合统计。 - 在 DSH Web 侧边栏底部增加 💰 按钮;面板展示项目汇总和可展开的模型明细。
- 零运行时 npm 依赖:使用 Node 自带的
node:zlibZstandard 解码。 - HTTP API 仅允许回环访问(
/dsh-token-cost/*)。
安装
请安装子目录 dsh-token-cost,不要安装上一级的 dsh plugin 目录。上一级目录没有 package.json,装错不会出现侧边栏按钮。
推荐使用绝对路径(路径里有空格,必须加引号):
dsh plugin --profile web add "file:/Users/dg/Documents/dsh plugin/dsh-token-cost"
或在该目录内执行:
cd /Users/dg/Documents/dsh plugin/dsh-token-cost
dsh plugin --profile web add "file:$PWD"
如果之前装错了 dsh plugin 目录,先卸载再重装:
dsh plugin --profile web remove "dsh plugin"
dsh plugin --profile web add "file:/Users/dg/Documents/dsh plugin/dsh-token-cost"
安装后重启 dsh web 并刷新页面,侧边栏底部会出现 💰 按钮。
也可以直接运行仓库里的安装脚本:
./scripts/install.sh
原理
宿主插件扫描 DSH sessions 目录下的每个 session.jsonl.zstd / session.jsonl,重放:
session.cwd→ 项目request/header→ 当前模型assistant/chunk { type: 'usage' }与assistant/message.usage→ 输入 / 命中 / 输出 token
同一 (turn, step) 的用量会去重(后面的 assistant/message 会替换之前的 usage chunk),与 DSH 自身 token-meter 的口径一致。
价格表
内置 DeepSeek 官方人民币价格(元 / 百万 tokens):
| 模型 | 输入(未命中) | 命中 | 输出 |
|---|---|---|---|
deepseek-chat / deepseek-v4-flash |
2 | 0.5 | 8 |
deepseek-reasoner / deepseek-v4-pro |
4 | 1 | 16 |
可在 profile 的 cordis.patch.yml 中覆盖(patch 行会替换整个 config,所以需要保留的价格都要写全):
- id: token-cost
config:
prices:
deepseek-chat:
input: 2
hit: 0.5
output: 8
deepseek-reasoner:
input: 4
hit: 1
output: 16
deepseek-v4-flash:
input: 2
hit: 0.5
output: 8
deepseek-v4-pro:
input: 4
hit: 1
output: 16
API
GET /dsh-token-cost/api/stats—— 完整的按项目/按模型 JSONGET /dsh-token-cost/api/prices—— 当前价格表GET /dsh-token-cost/healthz—— 存活检查
License
MIT
原始 README: https://github.com/gdy01/dsh-token-cost/blob/main/README.zh.md ↗
同类插件
查看全部 →
agent-vision-toolkit
为纯文本模型"看图“设计更好的视觉工具箱和技能,支持多图理解,图片问答,前端UI还原、GUI 自动化等,并可选无缝接入多个主流agent,直接识别粘贴图片| A vision toolkit and skill designed for text-only llms — image Q&A, long-screenshot OCR, frontend UI restoration, and GUI automation, with optional seamless integration for Codex, Claude Code, Pi, Oh My Pi, and OpenCode

api-relay-audit
从 DeepSeek Harness 对 AI API 中转站和 LLM 代理运行本地安全审计,生成 Markdown 报告,覆盖提示词注入、模型替换信号、工具调用改写、错误泄漏、流完整性和按 profile 启用的 Web3 风险。

OpenStory
✨ OpenStory 现已支持 DeepSeek Harness 插件! 现在可以通过 dsh-openstory 将 OpenStory 多智能体推演接入 DeepSeek Harness,让 agent 直接启动模拟、查看角色、下达指令并逐回合推进故事。查看 DSH 插件配置与使用指南。

phi
pi的编码代理 ∞ 提供者、子代理、hashline编辑和权限门

anysearch-dsh
DeepSeek Harness(DSH)的 AnySearch 网络搜索提供方与高级搜索工具。

codex-switch
Codex Switch 是一个 macOS 工具,一键配置 Codex 的自定义 API,同时保留官方 OpenAI 登录。保存后 Codex 的模型选择器里只会出现你选的那个 provider 的模型。也支持 Claude Code 的官方 / 自定义 API 切换。Codex Switch is a lightweight helper for configuring multiple coding-agent API routes. For Codex, it keeps Official OpenAI and a custom API provider configured in parallel, registers the custom model in Codex's mod