Files
nanobot-runtime/skills/usage/SKILL.md
nanobot a970805fdc usage: continuous Ollama Cloud usage sampling + delta report
- scripts/ollama_usage_poll.py: per-minute cron sample into db/ollama_usage.sqlite,
  write-on-change; meta table records every poll so a data gap can be told apart
  from a failed or missed poll
- scripts/ollama_usage_report.py: delta report keyed on per-model request_count
  (limits.*.usage has 0.1 % resolution, short-interval deltas are noise)
- SKILL.md: Continuous sampling section
2026-09-15 06:22:53 +02:00

2.4 KiB
Raw Blame History

name, description
name description
usage Show Ollama Cloud credit/usage spent via the ollama.com usage API. Triggers on: "/usage", "kolik kreditu", "kolik mam vycerpano", "ollama usage", "spotreba ollama", "credits".

Usage

Shows Ollama Cloud credit usage for the current API key.

Run

uv run skills/usage/scripts/ollama_usage.py

The script reads OLLAMA_API_KEY from the workspace/.env file (created by the user). If it is missing or the key fails (401/403), tell the user — never scrape the website.

Output

Format (script prints it, present it to the user as-is — same lines, same order; translate the labels to Czech, keep the numbers exact; no extra model info on the Session/Weekly lines):

Ollama Cloud usage
Session: <pct> %, resets in X hours
Weekly:  <pct> %, resets in Y days
Models (request count, weekly window):
  <model>: <count>

The per-model breakdown lives only in the "Models" section — never inline on the Session/Weekly lines.

Reset times — derived, not from the API

/api/usage contains no reset timestamps (they exist only in the HTML UI). The script computes them: session = until the next full hour UTC (the dashboard shows "Resets in 1 hour"), weekly = until the next Monday 00:00 UTC. Rationale: session usage climbed in real time during testing (rolling window), weekly changes slowly — consistent with hourly/weekly windows. If the window turns out not to be calendar-based, fix until_next_*.

Continuous sampling

A cron job runs scripts/ollama_usage_poll.py every minute and appends to db/ollama_usage.sqlite whenever anything changed (table samples; table meta records every poll, so a gap can be told apart from a failed poll).

For a delta report over that data:

uv run skills/usage/scripts/ollama_usage_report.py [--since ISO] [--until ISO]

Default window is the last 24 hours. Per-model request counts are the exact figure there — limits.*.usage has a resolution of 0.1 %, so short-interval percentage deltas are noise.

Notes

  • Endpoint: GET https://ollama.com/api/usage, header Authorization: Bearer <key> (verified 2026-09; issue #15132 is stale).
  • limits.*.usage is a fraction of the plan limit (× 100 = % as on the dashboard).
  • activity.cost returns $0.00000 on the Pro plan — broken, omitted from the output.
  • The ~/.ollama/id_ed25519 key does not work — only an API key minted at ollama.com/settings/keys.