DSH Plugins Marketplace

DSH Plugins

Plugins

/

Tools & Capabilities

/

dsh-mistral-spend

d

dsh-mistral-spend

Identified

Shows real-time Mistral Vibe and API budget usage in the sidebar, with per-model token cost tracking, cached-token spend, and API-key management. Requires a Mistral API key (MISTRAL_API_KEY by default

dsh-mistral-spend

Mistral spend for DeepSeek Harness.

A DSH plugin whose bottom-left sidebar foot holds an orange usage bar tracking your real monthly Mistral allowance. 100% is the allowance the API reports (for an EDU plan, €127.50), not a guess. Click the bar to open a panel with the plan, both budgets, cached-token spend and per-model cost; the plugin registers no sidebar.panellist entry, so the panel list is left untouched.

What the bar tracks

The bar lives in the sidebar.footer.action seat: a full-width row with the amount when the sidebar is expanded, a compact centered bar in the 56px rail when collapsed, both clickable to open the panel (layout.selectPanel).

It fills with the percentage the billing API reports, in Mistral brand orange (#FF8205 → #F04405), capped at 100%, with role="meter" ARIA values and a tooltip stating the exact amount. The Client polls the Host bridge every 30 s and updates the bar in place.

  • barBudget: vibe (default) tracks the Vibe allowance; api tracks the API budget.
  • barMax is only the fallback ceiling used when no budget is reported.

Where the account figures come from

The account card and the bar read Mistral's public billing API — the same two endpoints Vibe itself uses (mistralai/mistral-vibe, vibe/app_server/_billing.py):

EndpointReturns
GET /v1/billing/subscriptionplan_name (e.g. EDU), payg_enabled, vibe_payg_enabled, enterprise
GET /v1/billing/budgetvibe_budget and api_budget, each with initial_budget, usage_percentage, currency, reset_at

Both answer to an ordinary API key — no Admin API and no Enterprise plan needed. (The Admin API at /v1/admin/usage is a different, Enterprise-only surface; a standard key gets 401 there.)

A key without the see_org_inference_usage permission gets 403 on the budget read; the plan still comes through and the bar falls back to the estimate.

What the panel shows

  • Usage bar (wide) with the amount, the barMax ceiling, the percentage, and which source the figure comes from.
  • Account spend — the plan and both budgets, straight from the billing API.
  • This Harness — the tokens and estimated cost of every Mistral request routed through this Harness, priced per model, with the price source named for each model (config, pi-ai catalog, Mistral price list, or default). Cached prompt tokens are billed at their own rate and tracked as a separate cached spend figure (with its share of the total), both overall and per model.
  • API key — whether MISTRAL_API_KEY is configured, where it came from, and a field to replace or remove it through the Harness credential service.

The same facts are available to the agent as the mistral_spend tool.

The estimate

Independently of billing, the plugin prices the token usage of every Mistral request this Harness routed — useful because it attributes spend to this tool rather than the whole organization, and it works even when the billing endpoints are unavailable.

Where the number comes from

The figure covers every session in this Harness, across restarts — not just the current session. Two sources feed one ledger:

  1. History, rebuilt from the durable session log. On activation the plugin scans ~/.dsh/sessions/*/*/session.v4.jsonl.zstd and folds the usage of every assistant/message event whose provider starts with mistral. These logs are concatenated zstd frames, which Node's own decompressor stops after the first frame of, so the zstd CLI is used (a Node fallback returns the first frame if the CLI is missing). A scan of 71 logs takes about half a second.
  2. Live calls, counted by an llm/stream listener as they stream.

The two never overlap: the scan only counts events whose envelope time is older than the activation instant, and the listener only sees calls after it.

Per-file folds are cached in ~/.dsh/mistral-spend-ledger-cache.json, keyed by size and mtime, so a restart re-reads only the logs that changed. A file holding events newer than the cutoff is deliberately not cached, because its fold is partial and reusing it later would under-count.

How the cost is computed

The Host half registers a listener on the llm/stream waterfall. For every request whose provider starts with mistral, it passes the chunks through untouched and folds each usage chunk into a ledger:

cacheCost = (cacheRead × price.cacheRead + cacheWrite × price.cacheWrite) / 1_000_000
cost      = (input × price.input + output × price.output) / 1_000_000 + cacheCost

cacheCost is kept apart from cost so the panel can show how much of the total is cache traffic; it is always included in the total.

Prices are USD per million tokens, resolved in this order:

  1. prices in the plugin row's config,
  2. the installed pi-ai catalog for the model,
  3. the published Mistral price list embedded in index.js,
  4. a last-resort default.

The ledger itself is in memory, but it is rebuilt from the session log on every activation, so restarting the Harness does not reset the figure.

Configuration

Edit the row in the profile's cordis.patch.yml (a patch replaces the whole config, so repeat every key you keep):

- id: mistral-spend
  name: '@local/dsh-mistral-spend'
  config:
    apiKeyEnv: MISTRAL_API_KEY      # credential reference holding the key
    baseURL: https://api.mistral.ai # Mistral API root
    currency: EUR                   # currency of the figures
    barBudget: vibe                 # which reported budget the bar tracks
    barMax: 125                     # fallback 100% when no budget is reported
    refreshSeconds: 60              # panel auto-refresh interval
    requestTimeoutMs: 15000         # per-request timeout
    prices:                         # optional per-model overrides
      deepseek-v4-1-flash-1017:
        input: 0.3
        output: 1.2
        cacheRead: 0.007

Layout

FileRole
index.jsHost half: credential lookup, Mistral probe, usage ledger, HTTP bridge, mistral_spend tool
client.jsClient half: sidebar entry, main panel, Settings page, styles, copy
cordis.patch.ymlThe loader row that inserts the plugin
locale/{en,zh}.jsonPlugin Manager title and description
icon.svgOriginal coin-and-dollar mark

The Client talks to the Host through a same-origin JSON bridge at /api/mistral-spend/summary and /api/mistral-spend/key; cross-site requests and non-loopback peers are refused.

Install

dsh plugin --profile web add dsh-mistral-spend

Then restart dsh web. The bar appears at the sidebar foot; click it to open the panel.

From a checkout instead:

dsh plugin --profile web add /path/to/dsh-mistral-spend

Requirements

  • DSH >= 0.2.0
  • A Mistral API key in MISTRAL_API_KEY (or set apiKeyEnv to another name)
  • No runtime dependencies — the package is plain ESM over Node built-ins

Notes

  • The plugin registers no sidebar.panellist entry, so the panel list is left untouched; the bar lives in sidebar.footer.action.
  • The ledger is rebuilt from session logs on every activation, so restarting the Harness does not reset the figure.
  • Nothing is sent anywhere except to api.mistral.ai with your own key.

License

MIT

Comments

Loading…

Similar plugins

dsh-api-ledger

by LAwLi3tCoding

DSH API usage and cost ledger with per-pool reports and CNY/USD display

Tools & CapabilitiesDevelopment & InfrastructureManifest valid

★ 0

MIT

JavaScript

Sep 22, 2026

dsh plugin --profile web add dsh-api-ledger

by jcleener

DSH 插件:常驻 API 用量监控 —— DeepSeek/SiliconFlow/OpenCode Go/火山引擎 余额与配额、会话树 token 与花费(侧边栏入口 + 浮动窗)

Development & InfrastructureManifest valid

★ 0

MIT

JavaScript

Oct 10, 2026

dsh plugin --profile web add api-monitor

by ChrisZhangWG

Adds a Settings Usage dashboard for DeepSeek API balance, official token and cost analysis, trends, context warnings, and live API activity.

Tools & CapabilitiesTerminal & ClientsModels & ProvidersManifest valid

★ 2

↓ 31/wk

MIT

JavaScript

Aug 18, 2026

dsh plugin --profile web add dsh-codex-meter

by faith1688

专为 DeepSeek API 打造的实时用量 / 费用 / 余额计量插件 —— 在聊天输入框旁直接看到 tokens、花费与真实余额。

Tools & CapabilitiesTerminal & ClientsModels & ProvidersManifest valid

★ 3

↓ 250/wk

MIT

JavaScript

Sep 13, 2026

dsh plugin --profile web add @faith1688/dsh-usage-meter-harness

by xtd1145

Real-time DeepSeek API balance (official endpoint) and today-spend estimate (this DSH instance session-log usage x per-model price table) for the DSH web: composer dock strip, always-on floating badge

Tools & CapabilitiesModels & ProvidersManifest valid

★ 0

MIT

JavaScript

Sep 7, 2026

dsh plugin --profile web add dsh-deepseek-cost-live

by nonewind

Token usage & cost monitor for DeepSeek Harness — floating widget with multi-dimensional stats, time-series charts, auto-detected billing plans (Code/Token) and estimated spend.

UI & ExperienceManifest valid

★ 8

↓ 218/wk

MIT

JavaScript

Sep 7, 2026

dsh plugin --profile web add dsh-spend