This release is a pre-release and may not be stable for production use.
ollama-usage
Your Ollama Cloud quota, credits and per-model usage, from the official API — in the terminal, in Python, in Rust, or as JSON.
$ ollama-usage
Plan free
Monthly [███░░░░░░░░░░░░░░░░░] 12.5% resets in 21d 12h
Credits included $0.63 of $5.00 spent this cycle · purchased $0.00 left
Usage last 30 days · 120 req · $0.80
model-a 60 req $0.40 50.0%
model-b 40 req $0.30 37.5%
other models 20 req $0.10 12.5%
One API key is all it needs. Each run reads two documented endpoints and one undocumented one:
| What | Where it comes from |
|---|---|
| Monthly usage, its start and reset time (current plans) | /api/balance: included credits used out of the allowance |
| Session and weekly windows (plans from before the 2026-08-31 pricing change) | /api/balance |
| Included and purchased credit balances | /api/balance |
| Requests, cost and tokens, in total and for the ten most expensive models, over 24 hours, 7 days or 30 days | /api/usage |
| Plan name | /api/me (undocumented, best effort, only its Plan field is read) |
Since version 1.0 nothing is scraped from ollama.com pages and no browser cookie is read. Coming from 0.x? See MIGRATING.md.
Installation
Python package, which also installs the ollama-usage command. Prebuilt
for Python 3.10 and later on Linux, macOS and Windows, from the latest
release:
pip install --no-index --find-links https://github.com/florian-croiset/ollama-usage/releases/expanded_assets/v1.0.0-alpha.3 ollama-cloud-usage==1.0.0a3
The package is ollama-cloud-usage, imported as ollama_cloud_usage; the
command is ollama-usage. --no-index keeps pip off PyPI, where an unrelated
project is published as ollama-usage with the same command name: do not install
both in the same environment. Coming from 0.x, pip uninstall ollama-usage
first.
Or from the repository, which compiles the package and so needs a Rust toolchain (rustup):
pip install git+https://github.com/florian-croiset/ollama-usage
Command only: each release has a standalone archive for Linux, macOS and Windows that needs nothing else. Or with Cargo:
cargo install --git https://github.com/florian-croiset/ollama-usage ollama-usage-cli
The API key
Create a key at ollama.com/settings/keys. It is the same kind of key used to run Ollama Cloud models. The command looks for it in this order:
-
--api-key KEY, which your shell history keeps, so prefer the next one; -
the
OLLAMA_API_KEYenvironment variable; -
api_keyin the configuration file:OS Configuration file Linux ~/.config/ollama-usage/config.toml, or under$XDG_CONFIG_HOMEmacOS ~/Library/Application Support/ollama-usage/config.tomlWindows %APPDATA%\ollama-usage\config.tomlapi_key = "…"
--config PATHreads another file. An unknown setting is an error, so a typo does not go unnoticed.
The Python and Rust libraries read nothing on their own: pass them the key.
Command line
| Option | Effect |
|---|---|
--range 24h|7d|30d |
Period of the usage breakdown. Default 30d. |
--json |
Print the JSON report instead of the table. |
--alert PCT |
Exit with code 1 when a quota window is at or above PCT percent, and say which on stderr. |
-q, --quiet |
Print nothing at all; only the exit code tells the outcome. |
--config PATH |
Read the configuration from PATH. |
--debug |
Log each request, its status and duration to stderr. The key is never logged. |
On a plan from before the pricing change the table shows two windows instead:
$ ollama-usage
Plan pro
Session [███░░░░░░░░░░░░░░░░░] 12.5% resets in 3h 0m
Weekly [████████░░░░░░░░░░░░] 40.0% resets in 1d 12h
Credits purchased $2.50 left
Usage last 30 days · 120 req · $0.80
…
Percentages are green below 50 %, yellow up to 80 % and red beyond. Colours are
used only on a terminal; set NO_COLOR to turn them off
or FORCE_COLOR to force them. Warnings go to stderr, so --json output stays
parseable.
Exit codes
| Code | Meaning |
|---|---|
0 |
ok |
1 |
--alert threshold reached |
2 |
partial report: /api/balance or /api/usage failed, the other answered |
3 |
no report: both failed, or ollama.com rate-limited the key |
4 |
no API key, or the key was rejected |
64 |
invalid arguments or configuration |
An alert takes precedence over a partial report. In a cron job:
ollama-usage --quiet --alert 90 || notify-send "Ollama quota above 90 %, or the check failed"
Python
import os
from ollama_cloud_usage import Client
client = Client(os.environ["OLLAMA_API_KEY"])
report = client.fetch() # or fetch("24h"), fetch("7d")
for name, window in report.windows.items():
print(name, window.used_pct, window.resets_at) # monthly 12.5 2026-02-01 00:00:00+00:00
if report.usage:
for model in report.usage.models:
print(model.model, model.requests, model.cost_usd, model.share_pct)
The report is made of read-only dataclasses that mirror the
JSON report. report.to_dict() gives the JSON form and
Report.from_dict() reads it back, for instance from ollama-usage --json.
A fetch raises only when no report can be built at all:
from ollama_cloud_usage import ApiError, AuthError, NetworkError, RateLimitedError
try:
report = client.fetch()
except AuthError:
... # key rejected, or account suspended
except RateLimitedError as error:
... # retry after error.retry_after seconds (None if ollama.com did not say)
except (NetworkError, ApiError):
... # both endpoints failed
else:
if report.is_partial:
for warning in report.warnings:
print(warning.code, warning.message) # e.g. usage_unavailable
The client releases the GIL while it waits, and keeps the plan name for a day, so reuse one client rather than creating one per call.
examples/ has complete scripts: the quota windows
(quota.py), the usage per model (models.py),
an alert on usage or on the included credits left (alert.py), and
polling that respects the rate limit (watch.py).
Rust
[dependencies]
ollama-usage = { git = "https://github.com/florian-croiset/ollama-usage" }
use ollama_usage::{Client, Range};
let client = Client::new(std::env::var("OLLAMA_API_KEY")?);
let report = client.fetch(Range::Days30)?;
println!("{}", serde_json::to_string_pretty(&report)?);
The client is blocking and Send + Sync. cargo doc --open -p ollama-usage
documents every type.
JSON report
--json, Report.to_dict() and the Rust Report produce the same document,
described by schemas/usage-report-1.0.json.
Within version 1.x fields are only ever added, so check schema_version rather
than the package version. Fields that do not apply, or could not be read, are
null.
{
"schema_version": "1.0",
"fetched_at": "2026-01-10T12:00:00Z",
"plan": "free",
"windows": {
"monthly": {
"used_pct": 12.5,
"starts_at": "2026-01-01T00:00:00Z",
"resets_at": "2026-02-01T00:00:00Z"
},
"session": null,
"weekly": null
},
"credits": {
"included": { "balance_usd": 4.375, "allowance_usd": 5.0, "spent_usd": 0.625 },
"purchased_balance_usd": 0.0
},
"usage": {
"range": "30d",
"from": "2025-12-11T00:00:00Z",
"until": "2026-01-10T12:00:00Z",
"requests": 120,
"cost_usd": 0.8,
"input_tokens": 50000,
"cached_input_tokens": 10000,
"output_tokens": 20000,
"models": [
{
"model": "model-a",
"requests": 60,
"cost_usd": 0.4,
"input_tokens": 25000,
"cached_input_tokens": 5000,
"output_tokens": 10000,
"share_pct": 50.0
}
],
"other": null
},
"warnings": []
}
When reading it:
usagecovers a fixed range ending now, not the quota period. What was used in the current period iscredits.included.spent_usd.share_pctis a share of the cost, or of the requests when nothing was billed.othercombines the models beyond the ten that/api/usagelists one by one.warnings[].codeis stable:balance_unavailable,usage_unavailable,plan_unavailable,monthly_allowance_missing,no_quota_window. Later 1.x versions may add codes.
Rate limits
The API allows 10 requests per minute per user, shared by every key and device.
A fetch makes two, plus one to /api/me the first time a client is used and then
once a day. When ollama.com rate-limits the key, the error says how long it asked
to wait.
Privacy and security
- The key is sent only to
https://ollama.com, redirects are not followed, and it never appears in logs, errors or debug output. - Certificates are checked against the operating system's trust store, so an antivirus or proxy that inspects TLS works as long as its authority is installed on the machine.
/api/mealso returns your name and e-mail address; only the plan name is read.- Nothing is written to disk, and there is no telemetry.
Contributing
See CONTRIBUTING.md.
License
MIT — see LICENSE.
Disclaimer
This project is not affiliated with Ollama. /api/me is undocumented and may
change; if it does, plan becomes null and nothing else breaks. If something
else breaks, please open an issue.
Metadata
Release files for ollama-cloud-usage 1.0.0a3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ollama_cloud_usage-1.0.0a3.tar.gz | 50.5 kB | With provenance | Details for ollama_cloud_usage-1.0.0a3.tar.gz |
Built distributions (wheels)
Total release size: 7.6 MB
Release files / ollama_cloud_usage-1.0.0a3.tar.gz
| Download URL | ollama_cloud_usage-1.0.0a3.tar.gz |
|---|---|
| Size | 50.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3bf1468d8d47ae962e47775dc5d19f3d34067143cf73d560a597049bd4d0a006
|
|
BLAKE2b-256 checksum How to use checksums |
1cea486686be517c2d627400fa296266e7029efda84b4dde6d81b31e7ca1a39d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.
Transparency logRelease files / ollama_cloud_usage-1.0.0a3-cp310-abi3-win_amd64.whl
| Download URL | ollama_cloud_usage-1.0.0a3-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
9957a79711cd35faefe2475986d0e81a36a6788f3e153b91f18a22f77b6b3a8e
|
|
BLAKE2b-256 checksum How to use checksums |
d9d55c70757b60c1fe147f8d32346177cefab2788fefe486bdb94abe577967c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.
Transparency logRelease files / ollama_cloud_usage-1.0.0a3-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | ollama_cloud_usage-1.0.0a3-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 1.6 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
fffee70b9d28079ae3a8b5b827bc46d9ddfb617d608f60d832ee4f4340a76868
|
|
BLAKE2b-256 checksum How to use checksums |
c13674ac7c546020568dc1adb9ebf2e37a440a7b10f3f3a85ecc761c837eb71f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.
Transparency logRelease files / ollama_cloud_usage-1.0.0a3-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
| Download URL | ollama_cloud_usage-1.0.0a3-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
e781606c7130727f646f7e33b36777a093af139eea83d4a8134da2665f9bd0be
|
|
BLAKE2b-256 checksum How to use checksums |
a322e1e2c437051dae00c06d8d448fb5dbcfe229c060ac3a0fa568ba6aa402ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.
Transparency logRelease files / ollama_cloud_usage-1.0.0a3-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | ollama_cloud_usage-1.0.0a3-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.4 MB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
ddfa85678d3b84168f6aff9d47e301e8482769990c294dbc1cb62388c50088e6
|
|
BLAKE2b-256 checksum How to use checksums |
a9f3b2880b19198c86ca1faf9f2b8e423fb4e7a652c5590ca403d95692e0e30a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.
Transparency logRelease files / ollama_cloud_usage-1.0.0a3-cp310-abi3-macosx_10_12_x86_64.whl
| Download URL | ollama_cloud_usage-1.0.0a3-cp310-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 1.5 MB |
| Tags | CPython 3.10 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
ecc1de975bd6f53744d1cbca9e8b8ed1efb6f4d5aaf3500ca5387a7c8fc429f9
|
|
BLAKE2b-256 checksum How to use checksums |
392353d921648663a1535b6b3f53091855a6bda55f0379174504785a8a5b4752
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.
Transparency logSecurity for ollama-cloud-usage 1.0.0a3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 6 files in this release have been uploaded with provenance metadata.
Attestation for ollama_cloud_usage-1.0.0a3.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 8, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.