58 lines
1.9 KiB
Markdown
58 lines
1.9 KiB
Markdown
---
|
||
name: usage
|
||
description: >
|
||
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
|
||
|
||
```bash
|
||
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_*`.
|
||
|
||
## 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. |