pi-ollama-usage1.1.0
Pi extension that shows Ollama Cloud quota usage (5h session + weekly) in the footer status line
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
pi-ollama-usage
A Pi extension that shows your Ollama Cloud quota usage in the footer status line:
Mo:13.2%
Labels are dimmed and each percentage is color-coded by usage stress — green below 70%, yellow from 70%, red from 90% of the window. Set NO_COLOR to disable colors.
Uses the authenticated GET https://ollama.com/api/usage surface with your Ollama Cloud API key — the same data as the ollama.com/settings dashboard:
- Monthly quota window — Ollama retired the rolling 5h/weekly percent
windows in Oct 2026 in favor of a monthly dollar-based allowance
(
limits.monthly.usageis reported as a 0–1 ratio) - per-model request counts and 4-week activity cost (via
/ollama-usage) - the dollar limit itself ($X of $Y) is not part of the API response, so the extension shows percentages only
The indicator only appears while an Ollama Cloud model is active (provider ollama-cloud, or the built-in ollama provider with a :cloud model).
Install
From npm:
pi install npm:pi-ollama-usage
Or from the git mirror:
pi install git:github.com/MoemenMostafa/pi-ollama-usage
Setup
Works out of the box if you are signed in to the Ollama app/CLI (ollama signin) —
the extension reuses the local daemon's signed identity (~/.ollama/id_ed25519),
the same one used for cloud model requests. No API key needed.
Alternatively, create an API key at ollama.com/settings/keys and make it available in one of these ways (checked in order):
- Pi provider auth —
/login ollamaor anollama-cloudentry from pi-ollama-cloud OLLAMA_API_KEYenvironment variable (e.g. in~/.zshrc:export OLLAMA_API_KEY=...)~/.pi/agent/auth.json→{ "ollama-cloud": { "type": "api-key", "key": "..." } }or the same under"ollama"
Commands
/ollama-usage— one-shot full usage report (monthly window, per-model request counts, 4-week activity cost)/ollama-usage status— show whether the footer indicator is on/off/ollama-usage status on|off— enable/disable the footer indicator (on by default)/ollama-usage patch— re-run the pi-open-tui footer-patch self-heal manually (normally runs automatically at every pi launch)/ollama-auth— interactive auth TUI:- Test current credential — live check against
ollama.com/api/usage, shows current usage if it works - Set / update API key — paste a key, it is validated live, then saved to
~/.pi/agent/auth.json(file mode tightened to 0600) - Remove stored key — deletes the
ollama/ollama-cloudentries fromauth.json(env vars and Pi provider auth untouched)
- Test current credential — live check against
In non-interactive modes (pi -p, JSON/RPC), /ollama-auth prints the active credential as text instead of opening dialogs.
Footer placement with pi-open-tui
If you use the pi-open-tui TUI, the indicator defaults to the extension-status line below the footer. To inline it into the footer's stats row instead, apply the bundled patch:
~/pi-ollama-usage/patches/apply-open-tui-patch.sh
Self-healing after updates: pi-open-tui updates rewrite node_modules and silently wipe the patch — which is what colors the indicator. The extension therefore checks for the patch on every pi launch (session_start hook) and re-applies the bundled patch automatically when it is missing, telling you once to restart pi. This works from a repo checkout (the published package does not ship patches/); /ollama-usage patch runs the same check on demand.
The script is idempotent, tries version-specific patches newest-first, and tells you when the installed pi-open-tui version needs a regenerated patch. See patches/README.md for how the patch works, why the placement regresses after updates, and step-by-step regeneration instructions.
Behavior
- Refreshes on session start, model switch, and after turns — rate-limited to at most once per minute.
- Output is color-coded by usage stress (footer indicator and
/ollama-usagereport): green below 70%, yellow from 70%, red from 90%.NO_COLORdisables colors. - Hides automatically when you switch away from a cloud model, when no API key is available, or on API errors (footer is cosmetic; errors surface only in
/ollama-usage). - Fetches are bounded: 15s timeout, no redirects, malformed/oversized responses are rejected.
License
MIT