dsh-session-cost
开发工具 活跃维护

dsh-session-cost

geecraft23/dsh-session-cost

自动统计每轮对话与整场会话的接口调用费用,基于上下文消耗

0
Stars 标星
0
Forks 分支
0
Watchers 关注
0
Open Issues
TypeScript
主要语言
MIT
开源协议
113 KB
仓库大小
2 个月前
最后推送
一键安装扩展 / 插件指令
dsh plugin --profile web add github:geecraft23/dsh-session-cost
git clone https://github.com/geecraft23/dsh-session-cost.git
git clone git@github.com:geecraft23/dsh-session-cost.git
README.md main

DSH Session Cost

English | 简体中文

@geecraft23/dsh-session-cost adds estimated DeepSeek API cost to DeepSeek Harness Web. Every completed model Turn shows its own cost, and the composer footer shows the estimate for the complete durable Session. Open a Turn cost to inspect uncached input, cache-read input, optional cache-write input, output, model route, and price-book id.

The plugin uses the same compact typography, spacing, colors, disclosure behavior, dark theme, and responsive rules as Harness Chat. It does not alter prompts, model requests, cache behavior, or Session data.

Install

Requires Node.js ^22.19.0 or >=24.0.0 and DeepSeek Harness 0.1.2-alpha.5 or newer.

dsh plugin --profile web add @geecraft23/dsh-session-cost@0.1.2
dsh web

On Harness versions with the dedicated Turn-metric and trailing-statistic slots, the values appear exactly after Turn usage and at the end of the native Session statistics line. On 0.1.2-alpha.5, the compatibility presentation keeps the Turn cost in the action row and adds the Session total as the next footer statistic.

Use your existing Harness installation for upgrades. Version 0.1.2 supports both legacy chunk events and compact Assistant settlements used by current Harness, including failed or retried attempts. Restart Web after upgrading the Bundle.

The development type baseline remains 0.1.2-alpha.4 for older-host compatibility; release integration is also checked with the installed 0.1.5-rc.1 host (Session format 3).

Remove the Bundle and restart Web:

dsh plugin --profile web remove @geecraft23/dsh-session-cost

Price calculation

The included Bundle selects deepseek-cny-2026-09-10, an immutable snapshot containing both historical and current official tariffs. Each request uses its logged start time, not the date you open the conversation. Rates are currency units per one million tokens.

Model Period Cache read Uncached input Output
deepseek-flash (V4.1 Flash) Off-peak / peak ¥0.02 / ¥0.04 ¥1.00 / ¥2.00 ¥4.00 / ¥8.00
V4 Flash / Vision before the September 10 switch Off-peak / peak ¥0.05 / ¥0.10 ¥1.50 / ¥3.00 ¥4.50 / ¥9.00
V4 Pro before the September 14 switch Off-peak / peak ¥0.15 / ¥0.30 ¥4.50 / ¥9.00 ¥13.50 / ¥27.00

Peak periods are 09:00–12:00 and 14:00–18:00 Beijing time, Monday through Friday. Every other minute is off-peak. The price book starts at 2026-08-17 00:00 Beijing time; the Vision rule starts conservatively at 2026-08-22 00:00 Beijing time.

  • From September 10, 2026 at 12:00 Beijing time, deepseek-flash, deepseek-v4-flash, and deepseek-v4-flash-vision-exp use V4.1 Flash prices. Earlier requests to the old names retain V4 prices.
  • From September 14, 2026 at 12:00 Beijing time, deepseek-v4-pro also uses V4.1 Flash prices under the announced temporary redirect. Earlier Pro requests retain Pro prices. The eventual V4.1 Pro launch will require another price-book update.
  • A conversation spanning either switch sums the individually priced attempts. An attempt crossing a boundary is estimated using its logged start time; the provider's billing clock may differ.

One request attempt is calculated without intermediate rounding:

amount = (uncached_tokens × uncached_rate
        + cache_read_tokens × cache_read_rate
        + cache_write_tokens × cache_write_rate
        + output_tokens × output_rate) / 1,000,000

Reasoning tokens are already included in provider output tokens and are never charged twice. The implementation accumulates integer fixed-point amounts and rounds only for display. If a required usage bucket, model route, or matching tariff is missing, the affected Turn and Session total are shown as unavailable instead of inventing a price.

Official sources: CNY prices, USD prices, V4.1 Flash and tariff switch announcement, V4 price announcement, and Vision launch announcement.

Currency and custom tariffs

deepseek-usd-2026-09-10 uses the official USD tariff, independently of currency conversion: V4.1 Flash cache reads cost $0.003 / $0.006, uncached input $0.15 / $0.30, and output $0.60 / $1.20 per million tokens (off-peak / peak). It preserves historical USD tariffs and the same dated redirects.

The original deepseek-cny-2026-08-17 and deepseek-usd-2026-08-17 snapshots remain unchanged for explicitly pinned configurations. If your Profile overrides priceBook, change that override to the September book to adopt the update; custom tariffs remain caller-owned. Gateways, resellers, and discounts should use explicit custom rules. See the exported Config type for validated fields.

Limitations

  • This is a list-price estimate, not an invoice. Provider-side discounts, taxes, credits, hidden retries, billing-time rounding, paid tools, and external services are outside the estimate.
  • The built-in books price the deepseek-official route. Redirecting that route to a gateway does not prove the public tariff applies.
  • Auxiliary title generation and child Sessions are separate Sessions; open them to see their own estimates.
  • Built-in price books are immutable snapshots. A future DeepSeek price change requires a new price-book id.

Development

pnpm install
pnpm run check
pnpm pack --dry-run

The npm package is a DSH Bundle: cordis.patch.yml inserts the Host plugin, while the dsh.client manifest loads its Web presentation.

License

MIT