OpenRouter Usage — Omarchy bar widget
Live OpenRouter credits and spend in the Omarchy (Quattro / 4.x) bar:
- Balance — your current prepaid credit, straight from OpenRouter's API
- Spend by day — the last 7 days of rated cost from your local pi / omp sessions
- Spend by model — lifetime dollars per model, token counts in the tooltips

Everything is charted in dollars, not tokens — because on a pay-per-token router, 3.4B tokens of a cheap model and 800M tokens of an expensive one are not the same thing.
Requirements
- Omarchy 4.x (Quattro) — the Quickshell-based shell
- pi or omp with OpenRouter as a provider
(session transcripts under
~/.pi/agent/sessions/~/.omp/agent/sessions) - An OpenRouter API key
Install
omarchy plugin add https://github.com/ssobhani/omarchy-openrouter-usage.git --enable
Then provide your API key. Either export OPENROUTER_API_KEY in your session
environment, or (recommended, works for the widget's own refresh schedule):
mkdir -p ~/.config/omarchy/agents
cat > ~/.config/omarchy/agents/openrouter.json <<EOF
{"apiKey": "sk-or-v1-..."}
EOF
chmod 600 ~/.config/omarchy/agents/openrouter.json
The widget appears in the bar once the first scan finds OpenRouter usage.
Optional: budget gauge
OpenRouter's API only reports lifetime purchases and usage, which makes a "spent of funded" gauge meaningless for topped-up accounts. If you want the drain meter and the low-balance alarm, declare your top-up size:
{"apiKey": "sk-or-v1-...", "fundedAmount": 1000}
With fundedAmount set, the balance meter shows the remaining fraction of
that budget and turns urgent below 10%.
Settings
Right-click the widget icon to refresh. In the bar settings UI:
| Setting | Default | Meaning |
|---|---|---|
refreshIntervalSec |
300 | How often the collector re-scans sessions and re-probes the account |
Remove
omarchy plugin remove ssobhani.openrouter-usage
This restores the bar to its previous state. Optionally delete the key/config
file (~/.config/omarchy/agents/openrouter.json) and the collector's cache
(~/.cache/omarchy/agent-usage/openrouter-*.json); the plugin never touches
any other configuration.
How it works
bin/collect(Python, stdlib only) prints one display-ready JSON record: it scans pi/omp session transcripts for messages whoseproviderisopenrouter, sums pi's per-message ratedcostnext to the token counts, and probesGET /api/v1/credits+GET /api/v1/keyfor the live balance.Main.qmlruns that command on a timer and parses stdout. No systemd units, no shared state files — the record never touches disk.Panel.qmlrenders it: balance, spend by day, spend by model.
The collector follows the same conventions as Omarchy's built-in agent usage
collectors (--force, --limits-only, cached probes with a 15s floor,
stale-cache-on-failure), so it plays nicely on flaky networks.
Coexistence with the stock Agents widget
This widget is fully standalone — it does not replace or modify the built-in
omarchy.agents widget. Claude Code / Codex / Fireworks tracking keeps
working exactly as before, side by side.
Credits
OpenRouter "OR" glyph from OpenRouter's official brand assets (openrouter.ai/brand/v2, 2026 rebrand) — chartreuse on dark surfaces, purple on light, per their brand palette. OpenRouter is a trademark of its owner; this project is not affiliated.
License
MIT