sapi-budget
Manifest validCost display for AiSpot (sapi) relays: crawls the provider's group list from its public pricing endpoints instead of hardcoding it, lets you pick the active group from a dropdown in the conversation h
sapi-budget
A DeepSeek Harness plugin that syncs the per-group model prices from an
AiSpot (sapi) deployment and shows what each
conversation costs — a session total in the conversation header and a per-turn
cost at the end of every assistant turn.
The group list is crawled from the provider, never hardcoded, so it follows the provider as groups appear and disappear. You pick the active group from a dropdown in the conversation header, and every historical number is re-priced immediately — no reload, no replay.
What it shows
- Session total in the conversation header, including every descendant
subagent (
subtree(s) = own(s) + Σ subtree(children)). - Per-turn cost at the end of each assistant turn.
- A hover breakdown listing the model, the tokens per bucket, and the total.
Money is never published by the host. The projection carries token buckets only, and the browser prices them against the live catalog — that is what makes a group switch re-price history instantly.
Install
dsh plugin add github:Lanstzz/sapi-budget
Or from a local checkout:
dsh plugin add /absolute/path/to/sapi-budget
Then restart the app: the bundle is loaded at startup.
Runs on macOS, Windows and Linux. There is no platform branch anywhere in the
plugin: the host half is plain JavaScript that registers routes and a session
projection and writes nothing to disk, pricing comes from public HTTP endpoints,
and the stored group choice lives in the browser's localStorage. The UI uses
only theme tokens, so it follows the host's light and dark palettes.
Configuration
All optional. Set them in your profile patch (cordis.patch.yml):
- id: sapi-budget
name: 'dsh-sapi-budget'
config:
baseUrl: https://aispot.swj0227.icu # any compatible deployment
group: '' # '' = let the provider pick the cheapest
currency: USD
refreshMinutes: 30
The group is normally chosen in the UI and persisted in the browser's
localStorage (sapi-budget.group); the config value is only a fallback.
Pricing data
Three public, unauthenticated endpoints on the provider:
| Endpoint | Used for |
|---|---|
/api/pricing | model list, ratios and tiered_expr expressions |
/api/status | quota unit and exchange rate |
/api/user/groups | group names and per-group ratio multipliers |
Tiered expressions are evaluated by a hand-written tokenizer and recursive-descent
parser in pricing.js. There is no eval and no new Function.
Accuracy notes
- Tiered models are marked as estimates (
估算/estimate) in the UI. - A subagent's spend is priced at the root session's model rate, because cross-session model attribution is not available on the host side. Those rows are labelled as estimates too.
- Subagents that finished before the plugin was installed have no readable
projection. They are reported as unknown, never as
$0.00.
Layout
| File | Role |
|---|---|
index.js | Host half: pricing service, three HTTP routes, the sapiCost session projection, and the sapi_price agent tool |
client.js | Browser half: the two slot entries, the group picker, and the tooltip bubble |
pricing.js | Catalog fetching and the tiered_expr evaluator |
test/ | 45 host tests + 59 client tests |
probe-tooltip.mjs | Structural check that the breakdown does not ride on a native title |
Development
node --check index.js && node --check client.js && node --check pricing.js
node --test test/index.host.test.js # 45 pass
node --test test/client.test.js # 59 pass
node probe-tooltip.mjs # exit 0
HANDOFF.md records the architecture decisions and the traps that cost real time
(including why the cost breakdown must never be a multi-line native title on
macOS).
Licence
MIT — see LICENSE.
Comments
Loading…
Similar plugins
by igormel81
Live token cost for every chat in the DSH Web UI: the chat, its subagents and the whole session tree, priced from a bundled models.dev snapshot of seven providers and 139 priced models, with cache rea
★ 1
MIT
JavaScript
Oct 21, 2026
dsh plugin --profile web add dsh-chat-costby 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
★ 0
MIT
JavaScript
Sep 7, 2026
dsh plugin --profile web add dsh-deepseek-cost-liveDeepSeek Harness plugin: real-time API cost with peak / off-peak rates — a composer pill, /cost, a session_cost tool and a JSON snapshot, with subagent and agent-team spend rolled in.
★ 1
MIT
TypeScript
dsh plugin --profile web add dsh-api-costby LAwLi3tCoding
DSH API usage and cost ledger with per-pool reports and CNY/USD display
★ 0
MIT
JavaScript
Sep 22, 2026
dsh plugin --profile web add dsh-api-ledgerby Jannchie
Cost tracking priced from an online catalogue (models.dev + OpenRouter, 8000+ models, each call priced at its own instant): a per-turn cost line, a Cost tab attributing spend to tool output / model ou
★ 9
↓ 939/wk
MIT
JavaScript
Oct 23, 2026
dsh plugin --profile web add dsh-billby dougen
Shows a card in the sidebar footer with the DeepSeek account balance (read from the official /user/balance endpoint with the API key DSH already stores) and the unit prices of the active model — input
★ 9
↓ 7.1k/wk
NOASSERTION
JavaScript
Nov 5, 2026
dsh plugin --profile web add @dougen/dsh-deepseek-usage