Bundle
dsh-quota-meter
DSH web plugin: show the DeepSeek API key's remaining balance, estimate usable tokens per model (peak/off-peak pricing + measured cache-hit ratio), and chart the real cost of every turn.
- Source
- huolianJiao
- stars
- 1 stars
- License
- MIT
- Updated
- Updated 14 days ago
Readme
# dsh-quota-meter
DSH Web 插件:在侧边栏底部实时显示 **DeepSeek API 剩余额度**,并按「当前模型 × 低峰/高峰计价」估算**可用 token 数**,附每轮实际花费图。
## 功能
- **余额徽章**:收缩侧边栏时是带状态圆点的图标;展开时显示「余额 · 估算 token · 时段」一行。
- **详情面板**:总余额 / 赠送余额 / 充值余额、可用状态、按模型 × 低峰/高峰的**混合估算**与**缓存区间**(0%–100% 命中边界,当前时段高亮)。
- **实测用量**:缓存命中率、输入/输出占比、**每轮实际花费柱状图**(按每轮自己的时间戳计价,悬浮显示明细)。
- **可视化配置**:设置页直接编辑计价表、高峰时段、回退占比等,保存即生效,无需重启。
- **安全**:API key 只在本地 host 进程解析,绝不下发浏览器;余额接口仅回环地址可访问。
## 安装
> Requires [dsh](https://github.com/deepseek-ai/deepseek-harness) ≥ 0.1.0-rc.6 and a configured DeepSeek API key.
```sh
# Install from GitHub (recommended)
dsh plugin --profile web add github:huolianJiao/dsh-quota-meter
# Or install from a local checkout
dsh plugin --profile web add link:./dsh-quota-meter
```
装好后**重启 web profile**(重新执行 `dsh web`),刷新页面即可。
## 配置 API Key
插件默认读取凭据引用 `DEEPSEEK_API_KEY`(可在设置页切换)。任选其一:
- 环境变量:`DEEPSEEK_API_KEY=sk-...`
- 或写入 DSH 凭据文件 `$DSH_HOME/.credentials.yaml`:
```yaml
DEEPSEEK_API_KEY: sk-...
```
## 配置
- **设置页(推荐)**:Settings → 「DS API 计费 / DS API Billing」,可视化编辑计价表、高峰时段、回退占比等,保存立即生效。
- **补丁文件(固化默认值)**:在 profile 的 `cordis.patch.yml` 按 id 覆盖,重启生效:
```yaml
- id: dsh-quota-meter
config:
apiKeyEnv: DEEPSEEK_API_KEY
baseURL: https://api.deepseek.com
pollIntervalMs: 60000
summaryModel: deepseek-v4-pro
peakWindows:
- { start: "09:00", end: "12:00" } # 北京时间,[start, end)
- { start: "14:00", end: "18:00" }
pricing: # 元 / 百万 token
- model: deepseek-v4-flash
offPeak: { input: 1.5, cacheHit: 0.05, output: 4.5 }
peak: { input: 3.0, cacheHit: 0.10, output: 9.0 }
- model: deepseek-v4-pro
offPeak: { input: 4.5, cacheHit: 0.15, output: 13.5 }
peak: { input: 9.0, cacheHit: 0.30, output: 27.0 }
```
## 开发
零构建,改完即用:
- `lib/client.js`(浏览器端):刷新页面即可生效;
- `lib/index.js`(host 端):重启 web profile 生效。
```sh
npm test # 运行 smoke 测试
```
## License
[MIT](./LICENSE)
Install
dsh plugin --profile web add github:huolianJiao/dsh-quota-meter
Profile: web
With the hub plugin installed, ask your agent to install it by name — it resolves the same plan shown here.
dsh plugin --profile web add github:stvlynn/dsh.fish#path:packages/dsh-plugin-hub
install dsh-quota-meter from the hub
- This source has no pinned commit, so a later push upstream changes what installs. Prefer pinning a commit.