Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ortop

A tiny, read-only terminal dashboard for keeping an eye on your OpenRouter spend — inspired by bottom. It auto-refreshes, has nothing to click, and only ever issues GET requests: it never creates keys, spends credits, or changes anything on your account.

╭ ortop — OpenRouter monitor ─────────────────────────────────────────────────╮
│ $45.89 left   used $4.11 / $50.00 purchased                                  │
│ [████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 8.2% of credits used    │
╰──────────────────────────────────────────────────────────────────────────────╯
╭ Balance over time ───────────────────────────────────────────────────────────╮
│ $49│⠉⠉⠉⠉⠉⠉⠉⠑⠒⠒⠒⠒⠒⠒⠒⠒⠒⠒⠒⠒⠒⠒⠒⠒⠒⠒⠒⠒⠒⠢⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⢄⣀⣀⡠⠔             │
╰──────────────────────────────────────────────────────────────────────────────╯
╭ Daily (14d)  Σ $6.69 ────────────────────────────────────────────────────────╮
│ ▅▅▅▅ ▁▁▁▁ ▃▃▃▃ ▅▅▅▅ ▆▆▆▆ ▇▇▇▇ ▃▃▃▃ ▁▁▁▁ ▆▆▆▆ ▇▇▇▇ ▃▃▃▃                        │
│ SU1  M2   T2   W2   TH2  F2   S2   SU2  M3   T3   W3   ...                     │
╰──────────────────────────────────────────────────────────────────────────────╯
╭ Weekly (8w) ───────────────────╮╭ Monthly (6m) ──────────────────────────────╮
│ ▁ █ ▅   5/25  6/1  6/8         ││ ▁ █   May  Jun                             │
╰────────────────────────────────╯╰────────────────────────────────────────────╯
 q quit · r refresh · every 1m0s · updated 14:59:03

What it shows

  • Balance — credits remaining (purchased − used), color-coded as it runs low.
  • Budget gauge — usage against your purchased credits (or a per-key limit).
  • Balance over time — a slowly scrolling line chart.
  • Daily / Weekly / Monthly — spend per period. Daily bars are labelled by weekday and week (M1, T1, … S2, SU2) so two weeks stay readable.

The layout stacks vertically and adapts to your terminal: panels drop from the bottom up as the window shrinks, and below 24×9 it just asks for more room. Best viewed at ~80×24 or larger.

Why it keeps its own history

OpenRouter has no spend-history API — /credits reports lifetime totals and /key reports current spend, but nothing returns "cost per day." So ortop polls periodically and appends snapshots to a local JSONL file, deriving per-period spend by diffing cumulative usage. The time charts start empty and fill in as it runs (no backfill), and it never invents data for periods it didn't record.

History lives at ~/.local/share/ortop/history.jsonl (override with --data).

Setup

Needs Go 1.23+.

go build -o ortop ./...

Provide one or both keys via the environment:

Variable Used for Gives you
OPENROUTER_PROVISIONING_KEY GET /credits true account balance (purchased vs. used)
OPENROUTER_API_KEY GET /key key label, spend limit, rate limit, per-key usage

At least one is required. With only an inference key, the charts track that key's own cumulative usage; set a provisioning key (OpenRouter → Settings → Provisioning Keys) to see your real account balance.

export OPENROUTER_PROVISIONING_KEY="sk-or-v1-..."
./ortop                 # poll every 60s (default)
./ortop --interval 30s  # poll faster

Tip: keep the key out of your shell history by putting it in a private file:

mkdir -p ~/.config/ortop && chmod 700 ~/.config/ortop
printf 'export OPENROUTER_PROVISIONING_KEY="sk-or-v1-..."\n' > ~/.config/ortop/env
chmod 600 ~/.config/ortop/env
echo '[ -f ~/.config/ortop/env ] && . ~/.config/ortop/env' >> ~/.bashrc

Keys

q / Esc / Ctrl-C quit · r forces an immediate refresh. That's it — it otherwise runs hands-off.

Flags

--interval duration   how often to poll OpenRouter (default 1m0s)
--data string         path to the local history file

About

a simple tui for openrouter monitoring

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages