DeepSHPlugins
deepseek-cost-usage-status-plugin 项目预览
GITHUB / COMMUNITY PROJECT

deepseek-cost-usage-status-plugin

安全与运维TypeScriptMIT

在 DSH 会话统计行下方新增彩色状态行,实时显示 DeepSeek API 费用、用量与账户余额,并带高峰/错峰计费指示。

2 StarsZenjibad 更新时间 2026-08-28
访问 GitHub 仓库
deepseek-cost-usage-status-plugin 项目预览

项目介绍

中文

在 DSH 会话统计行下方新增彩色状态行,实时显示 DeepSeek API 费用、用量与账户余额,并带高峰/错峰计费指示。

English

Adds a colored status line under the DSH conversation stats showing live DeepSeek API cost, usage and account balance, with on/off-peak pricing indicators.

项目信息与收录信号

快照 2026-09-11
作者 / 组织
Zenjibad
仓库
Zenjibad/deepseek-cost-usage-status-plugin
GitHub Stars
2
Forks
0
开发语言
TypeScript
许可证
MIT
最近推送
2026-08-28
Manifest
数据中检测到声明

公开仓库不自动等于可商用;许可证与当前兼容性以原项目文档为准。Manifest 和数据评分不构成安装安全认证。

数据评分

55/ 100
维护活跃
91
文档与实用信息
100
生态关注度
14
安装便捷信号
55
项目声明信号
100

近 14 天仍在更新;README 含完整安装与使用说明;关注度尚低(2)。

评分来自已有数据快照的五维模型,仅作浏览参考,不是实际使用评测或安全检测结论。

安装与使用

所有项目资料与许可均以对应 GitHub 仓库为准。

dsh plugin --profile web add github:Zenjibad/deepseek-cost-usage-status-plugin

复制命令不会自动执行。请先阅读仓库文档,确认环境要求与许可证。

项目截图

仓库 README

GitHub 原文

已保存的仓库文档快照;文档抓取时间未记录,可能与上方目录介绍处于不同版本。安装前请核对当前仓库说明。

DeepSeek Cost / Usage / Status Plugin for DeepSeek Harness

A packaged Cordis plugin for DeepSeek Harness (DSH) that adds a second, colored status line under the shipped conversation stats line, showing live DeepSeek API cost, usage, and account balance.

● Off-peak 00:47 · −50%  ·  Cost ¥0.0412  ·  ~¥1.23/min  ·  Balance ¥12.42  ·  Model deepseek-v4-flash   ← CNY account
● Off-peak 00:47 · −50%  ·  Cost $0.0057  ·  ~$0.17/min  ·  Balance $1.73  ·  Model deepseek-v4-flash   ← USD account (cost auto-converted from CNY)

Features

  • On / off-peak indicator — green when off-peak (idle), red when peak, using DeepSeek's official Beijing-time peak windows (09:00–12:00, 14:00–18:00). The clock shows your local timezone; the decision is Beijing-time so the color matches what DeepSeek actually bills.
  • Session cost — real per-session token usage accumulated from the llm/stream waterfall, priced with official CNY rates including the 50% off-peak discount, then converted into your account's currency (from the balance API) so cost and balance are directly comparable.
  • Burn rate — ~/min in the same display currency, i.e. session cost ÷ elapsed minutes since the session's first model call.
  • Account balance — polled from DeepSeek's /user/balance every 60s using DSH's own DEEPSEEK_API_KEY; degrades to Balance — if the key is unavailable/network fails.
  • Current model + reasoning effort.
  • Font-matched to the shipped stats line (12px/20px, muted tertiary color, centered) so it reads as the same family.

Quick start

This is a packaged profile plugin — install once with the official CLI, it loads on every DSH boot and survives restarts (no cordis_define):

dsh plugin --profile web add deepseek-cost-usage-status-plugin
# or from a local checkout:
dsh plugin --profile web add ./deepseek-cost-usage-status-plugin

Then restart DSH. The plugin renders its line in the conversation.composer.dock slot (a new cell beside the shipped stats cell), fed by GET /deepseek-cost/api.

Requirements

  • DSH 0.1.0-rc.6+ with the web UI and a configured DeepSeek provider.
  • A DeepSeek API key stored as DEEPSEEK_API_KEY in ~/.dsh/.credentials.yaml (reused for the balance read). Without it, balance shows —; the rest still works.

How it works

  • Host half (source of truth): wraps the llm/stream waterfall, forwards every chunk untouched, reads the terminal usage chunk per completed call, accumulates per-session token/model/timing, computes cost from the PRICING table (official CNY, peak-class; idle = 50%) with the Beijing-time peak decision, and polls balance via curl.exe + subprocess. Serves the snapshot over GET /deepseek-cost/api (a webServer route — the packaged-plugin replacement for the dynamic harness.handle RPC seam).
  • Client half: registers in conversation.composer.dock, polls /deepseek-cost/api every 2s, and renders the font-matched line with a green/red peak chip.

User-currency cost display

Cost and burn rate are computed in CNY (the pricing table's basis) and then displayed in your account's currency — the one returned by GET /user/balance (usually USD). That way Cost and Balance share the same unit. The conversion uses a hybrid FX rate:

  1. Live — fetched from open.er-api.com (/v6/latest/CNY, free, no key) through the same curl.exe + subprocess path as the balance poll, refreshed hourly by default (fxRefreshMs).
  2. Fallback — a configured fixed rate (fallbackFxRate, CNY per 1 unit of the display currency, e.g. 7.2 for USD), used only when the live fetch fails.

If neither a live rate nor a fallback is available — or the balance is unknown (no API key / network failure) — cost simply stays in CNY. No wrong numbers are ever shown.

Configuration

Set from a patch layer, e.g. $DSH_HOME/cordis.patch.yml:

deepseek-cost-usage-status-plugin:
  config:
    fallbackFxRate: 7.2   # CNY per 1 USD — used when the live FX fetch fails
    fxRefreshMs: 3600000  # live FX refresh interval (default 1 h)
optiondefaultmeaning
fallbackFxRateunsetFixed CNY→display-currency rate used when the live FX fetch fails
fxRefreshMs3600000How often to refresh the live FX rate (min 60 000)

The currency symbol follows the account currency (¥, $, €, £, …); unmapped ISO codes render as their 3-letter code.

Pricing table (official DeepSeek CNY, per 1M tokens, effective 2026-08-17)

modelcache-hit incache-miss inoutput
deepseek-v4-flashidle¥0.05¥1.5¥4.5
deepseek-v4-proidle¥0.15¥4.5¥13.5

Update PRICING in src/index.ts (single place) when rates change.

FAQ

  • The line shows Cost … / Balance —? The host route is unreachable, the balance key is missing (~/.dsh/.credentials.yaml → DEEPSEEK_API_KEY), or the balance call failed (network / non-200). Cost/peak still work without balance; the line self-recovers on the next poll.
  • Why does the balance read put the API key on a curl command line? The key travels as an Authorization header argument to curl.exe (visible to other processes on this machine) — an accepted tradeoff for this readout tool. No key is stored or logged by the plugin itself.
  • Why is cost shown in my account's currency? The plugin converts the CNY price into the currency your balance API returns (usually USD), so cost and balance are comparable. The rate is fetched live (hourly) and falls back to your configured fallbackFxRate when the fetch fails; without any rate, cost stays in CNY.

Layout

  • src/index.ts — the host half (waterfall wrap, pricing, balance poll, /deepseek-cost/api route).
  • src/client/index.tsx — the client bundle (2s poller, dock line).
  • cordis.patch.yml — dsh.bundle.patch: mounts the plugin row at boot.
  • tsdown.config.ts — builds host (node ESM) + client (CJS ModuleLoader closure).
  • tests/fixtures/balance.json — real-shape /user/balance response sample.
  • AGENTS.md — guide for AI agents / maintainers.
  • README.zh.md — 中文文档.

License

MIT — see LICENSE.

使用前核对

安装步骤、兼容版本与授权范围以原项目当前文档为准。Stars 和评分是快照中的导航信号。

安装与排错 · 项目问题反馈

同类项目