dsh-openrouter-spend
OpenRouter spend inside DeepSeek Harness — billed USD from OpenRouter's own analytics API, not token estimates priced from a local table.
What you get

The chip under the composer: billed spend for the selected range, next to the session's token and context stats.

The popover: range and API-key filters, today's spend per model, daily bars, prepaid balance and lifetime spend.
- Chip under the composer — spend for the selected range and API key: today, 7 days, or 30 days.
- Chip popover — range and API-key filters, today's spend per model, a daily bar chart across the window, prepaid balance and lifetime spend.
- Settings → OpenRouter spend — store or clear the management key, set the refresh interval, filter by API key.
The host half caches the summary for refreshSeconds and coalesces concurrent refreshes, so any number of open tabs cost one OpenRouter query per refresh window. When a refresh fails, the last good figures stay on screen and the reason is shown instead of an empty panel.
Requirements
- DeepSeek Harness web profile. The plugin needs the
credentials,webServer, andconnectionservices and stays inactive in profiles without them (for example, headless). - An OpenRouter Management API key — OpenRouter dashboard → Settings → Management API Keys → Create New Key (OpenRouter docs). A regular inference key is rejected:
403 Only management keys can perform this operation.
Install
From npm (web is the default web-GUI profile; use your own profile name instead if you run one):
dsh plugin --profile web add dsh-openrouter-spend
From GitHub (plain JavaScript, no build step and no build-script permission):
dsh plugin --profile web add github:RyabykinIlya/dsh-openrouter-spend#v0.1.2
Then open Settings → OpenRouter spend and paste the management key.
Configuration
Every field can be overridden in the profile's cordis.patch.yml row; the schema validates the row at activation and names the offending field.
| Field | Default | Bounds | Meaning |
|---|---|---|---|
credentialRef |
OPENROUTER_MGMT_API_KEY |
non-empty string | Credentials reference holding the management key |
apiBase |
https://openrouter.ai/api/v1 |
https:// URL |
OpenRouter REST API root |
refreshSeconds |
60 |
10–3600, integer | Seconds between OpenRouter refreshes |
historyDays |
30 |
2–366, integer | Days of history the summary window covers, today included |
timeoutMs |
15000 |
1000–120000, integer | Per-request deadline against OpenRouter |
Viewing preferences (per-key filter, refresh interval override) are browser-local (localStorage).
What the numbers are
- Figures are
total_usage— USD OpenRouter actually billed — fromPOST /api/v1/analytics/query, grouped per UTC day by API key and model. - "Today" is the current UTC day.
- Balance is
total_credits − total_usagefromGET /api/v1/credits: what remains of prepaid credits. - The 7-day and 30-day ranges cover at most
historyDaysdays; keephistoryDays ≥ 30for full coverage.
Security
- The management key is stored through the Harness credentials service (
credentials.set), not in this package's files, and is never echoed back to the browser. - The summary and credential routes are fenced by the connection trust check. Anyone who passes that check — by default, the browser session on your local Harness port — can read your spend figures. Do not expose the Harness web port publicly without its own authentication.
License
MIT. Unofficial plugin; not affiliated with OpenRouter or DeepSeek.
По-русски
Плагин для DeepSeek Harness показывает реальные списания аккаунта OpenRouter (данные из аналитики OpenRouter, в долларах, по UTC-дням): чип под полем ввода с выбором периода сегодня / 7 дней / 30 дней, в поповере — разбивка по моделям за сегодня, график по дням, фильтр по API-ключам и остаток предоплаченных кредитов. В Settings → OpenRouter spend задаётся управляющий ключ и интервал обновления. Установка: dsh plugin --profile web add dsh-openrouter-spend; нужен Management API key из кабинета OpenRouter (Settings → Management API Keys) — обычный ключ модели для аналитики не подходит.
No comments yet. Be the first to write one.