dshbase

插件目录 / Developer / dsh-api-cost

dsh-api-cost

已验证 · 实测可装 CCCq-C

✓ 持续维护 基于 5 个官方 DSH 包

查看 GitHub ↗ ← 返回插件目录

0Stars
0Forks
0未关闭 issue
—语言
2026-08-15最近推送
跨平台平台

功能简介

DeepSeek Harness 插件:实时显示本会话 API 用量开销 / Real-time per-session API cost meter for DeepSeek Harness

✅
我们的评价
可用 — 实测通过,早期项目

DeepSeek Harness 插件:实时显示本会话 API 用量开销 / Real-time per-session API cost meter for DeepSeek Harness 实测能干净安装、正常启动。早期项目,但功能可用。

「已验证」表示我们的自动化 CI 在干净 profile 里实际执行了 dsh plugin add 并启动成功——仅此而已。功能描述与版本兼容性均为作者声明。这不是安全审计,也不代表对第三方代码的背书。

README

dsh-api-cost

English | 中文

A Host + Web Client plugin for deepseek-harness
(dsh): shows the real-time per-session API cost — the provider-reported
token usage (uncached input / cache-hit input / output) priced with a
configurable per-model rate table, rendered as a live chip above the composer.
Installable via dsh plugin add.

Features

  • apiCost session projection (host half): a pure fold over the session
    log that prices each provider usage sample at the model's rate, so streaming
    usage chunks update the cost live and the finalized assistant/message never
    double-counts.
  • Composer-dock chip (browser half): API cost $0.0023 1.2K + 3.4K tok,
    updating in real time; hover shows a per-bucket breakdown (input / cache hit /
    cache write / output, plus the model id).
  • Configurable pricing: USD per one million tokens; unknown models fall back
    to a default rate table, and per-model overrides ride the plugin row's
    config (see Configuration).
  • Bilingual UI (中文 / English), following the host locale.
  • Self-contained: no host-repository changes — the in-package
    cordis.patch.yml inserts its own row as a bundle layer.

Installation

dsh plugin --profile web add dsh-api-cost

The installer adds the package to the web profile's dependencies and bundle
list; after restarting dsh web, the loader applies the in-package
cordis.patch.yml automatically. Then open any session and send a message —
the cost chip appears above the composer and ticks up as tokens stream.

Manual install (same mechanism, bypassing the installer): edit
$DSH_HOME/profiles/web/package.json — add "dsh-api-cost": "<version>" to
dependencies and "dsh-api-cost" to the dsh.profile.bundles array — then
run pnpm install in that directory and restart.

Peer dependencies are the official @deepseek-ai/* packages (^0.1.0-rc.6)
plus react, all provided by the host.

Configuration

The plugin ships usable defaults and has no Config schema: override pricing by
setting config on the api-cost row in the profile's cordis.patch.yml
(e.g. $DSH_HOME/profiles/web/cordis.patch.yml):

- id: api-cost
  config:
    currency: USD
    # fallback rates for unknown models (USD per 1M tokens)
    rates:
      input: 0.27
      cacheRead: 0.07
      cacheWrite: 0.27
      output: 1.1
    # per-model overrides (partial objects merge over `rates`)
    models:
      deepseek-chat:
        input: 0.27
        cacheRead: 0.07
        cacheWrite: 0.27
        output: 1.1
      deepseek-reasoner:
        input: 0.55
        cacheRead: 0.14
        cacheWrite: 0.55
        output: 2.19
      deepseek-v4-pro:
        input: 0.27
        cacheRead: 0.07
        cacheWrite: 0.27
        output: 1.1
      deepseek-v4-flash:
        input: 0.14
        cacheRead: 0.03
        cacheWrite: 0.14
        output: 0.55

Billing buckets follow the harness TokenUsage convention (disjoint counts):
DeepSeek's prompt_tokens already includes cache hits, and the official
adapter subtracts cacheReadTokens out of inputTokens, so:

bucket meaning rate
inputTokens cache-miss input input
cacheReadTokens cache-hit input cacheRead
cacheWriteTokens cache write (not reported by DeepSeek) cacheWrite
outputTokens output output

deepseek-v4-pro / deepseek-v4-flash defaults are placeholders — update
them once official pricing is published.

Projection

The apiCost session projection exposes:

field meaning
cost total cost (currency units)
inputCost / cacheReadCost / cacheWriteCost / outputCost per-bucket cost
inputTokens / cacheReadTokens / cacheWriteTokens / outputTokens per-bucket tokens
model / provider current route (last-wins)
currency currency code

Known Limitations

  • Estimate, not a bill: cost is computed from the local session log and may
    differ from the official invoice (provider-side caching, price changes,
    model renames). The rate table is the single source of truth — keep it
    current.
  • Model-switch granularity: each usage sample is priced at the route that
    was current when it was reported, so switching models mid-session prices
    later steps at the new model's rate.
  • Subagents have their own session ids and are not aggregated into the
    parent session's chip.

License

MIT

安装

🧩 让 Agent 自动装(推荐)

装一次目录插件,之后本站所有插件都能让 DeepSeek Harness 自动找、自动装:

dsh plugin add dshbase-catalog

然后对 agent 说「帮我装 dsh-api-cost」,它会在目录里找到并自动安装。文档:dshbase-catalog · 已验证场景包。

该插件是 GitHub 源码(未发 npm)——直接从仓库装:

Web profile:

dsh plugin --profile web add github:CCCq-C/dsh-api-cost

Headless(CLI)profile:

dsh plugin --profile headless add github:CCCq-C/dsh-api-cost

实测报告

验证通过:从 GitHub 源码完成 L1 安装 + L2 加载 + L3 运行(dsh 0.1.0-rc.6)。

安全:尚未扫描——我们的每日静态扫描将很快覆盖它。

分享徽章

Developer 里更多

浏览全部 7819 个插件 →