gemini-usage-limits
CLI for Antigravity plan usage and rate limits, with Antigravity CLI fallback and warning thresholds.
Downloads & Community Adoption
Health & Engineering Analysis (5 Pillars)
1. Governance & Community50 / 200 โพ
2. PEP Metadata & Packaging200 / 200 โพ
3. Security & Supply Chain150 / 200 โพ
4. Documentation, SEO & Ecosystem105 / 200 โพ
5. Engineering, CI & Quality65 / 200 โพ
Official Documentation & Usage Guide โ gemini-usage-limits
Show full original documentation (English README) โพ
Antigravity shows your plan limits with its /usage command.
gemini-usage gives you plan usage from the shell, for scripts, hooks, and
AI agents deciding when to back off. It uses the Antigravity login already on
your machine.
The 5-hour and weekly windows cover Gemini models and Claude/GPT models in separate groups.
Install gemini-usage-limits from PyPI for the gemini-usage command.
$ gemini-usage
Gemini 5-hour: 1% used, resets 21:18 (in 4h44m)
Gemini 7-day: 18% used, resets Tue 19:33 (in 146h58m)
Claude/GPT 5-hour: 0% used
Claude/GPT 7-day: 0% used
โจ Features
- โฑ๏ธ Usage windows with 5-hour and weekly percentages and local reset times for each group.
- ๐ฆ Thresholds for scripts with
--warn [N]for any window and--warn-7d [N]for the Gemini weekly window. Both exit 1 at or above N%. - ๐ Extra detail with model group descriptions and the plan when available through
--all. - ๐ Antigravity CLI fallback through
agy -p /usagewhen the direct endpoint path fails. - ๐งพ Plain, JSON, or short output for terminals and scripts.
- ๐ Cross-platform with keyring access on macOS and Linux and CLI fallback on Windows.
- ๐ Zero dependencies beyond the Python 3.9+ standard library.
- ๐ Local & private with existing login credentials sent only to Google's Antigravity endpoint.
๐ Quickstart
Install Antigravity and run agy once to sign in with Google.
curl -fsSL https://antigravity.google/cli/install.sh | bash
agy
After signing in, install and run the usage CLI.
pip install gemini-usage-limits
gemini-usage
๐งโ๐ป Usage
| Command | What it does |
|---|---|
gemini-usage |
Available usage windows and their reset times |
gemini-usage --json |
Raw quota-only JSON (alias for --format json) |
gemini-usage --warn [N] |
Exit 1 when any usage window reaches N% (default 70) |
gemini-usage --warn-7d [N] |
Exit 1 at or above N% of the Gemini 7-day window (default 70) |
gemini-usage --all |
Add group descriptions and the plan in plain format |
gemini-usage --format {plain,json,short} |
Choose output format (default plain) |
gemini-usage -v, --verbose |
Print credential and usage sources and the plan, when available, to stderr |
gemini-usage -V, --version |
Print the version |
gemini-usage -h, --help |
Show help |
Flags combine as in gemini-usage --format short --warn 70 --warn-7d 90.
The last of --json and --format wins. --all adds detail in plain format.
Group descriptions come from the quota endpoint and the plan comes from a
separate lookup.
Gemini 5-hour: 1% used, resets 21:18 (in 4h44m)
Gemini 7-day: 18% used, resets Tue 19:33 (in 146h58m)
Claude/GPT 5-hour: 0% used
Claude/GPT 7-day: 0% used
Gemini: Models within this group: Gemini 4 Neon, Gemini 4 Carbon, Gemini 4 Argon, Gemini 4 Hydrogen, Gemini 3.8 Flash
Claude/GPT: Models within this group: Claude Opus 5.5, Claude Sonnet 5.5, GPT-OSS 120B
plan Google AI Pro
๐ค Using it from scripts and agents
gemini-usage --warn 70 || echo "back off"
gemini-usage --warn 70 --warn-7d 90 --format short
gemini-usage --json
The usual output is printed even when a threshold trips. Exit code 0 means
success, 1 means a threshold tripped or no source answered, and 2 means
an argument error. Both warning thresholds are inclusive and compare the
source percentage before rounding for display. --warn includes all reported
windows, and --warn-7d checks the Gemini weekly window when present.
๐ Antigravity CLI fallback
The direct request needs a current access token. When it is expired or the
endpoint path fails, the CLI runs agy -p /usage --print-timeout 60s once in a
temporary directory. Antigravity refreshes its own credential as needed. The
fallback uses whole percentages from its tab-separated output.
$ gemini-usage
Gemini 5-hour: 1% used, resets 21:18 (in 4h44m)
Gemini 7-day: 18% used, resets Tue 19:33 (in 146h58m)
Claude/GPT 5-hour: 0% used
Claude/GPT 7-day: 0% used
(from the agy CLI)
With --format short, each group and window fits on one line.
Gemini 5h 1% ยท Gemini 7d 18% ยท Claude/GPT 5h 0% ยท Claude/GPT 7d 0%
๐ค How it works
Sources are tried in this order.
last-usage.jsonif less than 5 minutes old.- One live
POST https://daily-cloudcode-pa.googleapis.com/v1internal:retrieveUserQuotaSummary, saved on success. - One Antigravity
/usagerun. last-usage.jsonif less than 60 minutes old.
The quota cache lives in ~/.gemini-usage, or GEMINI_USAGE_HOME when set.
Cache writes are atomic. Cached answers at least a minute old show their source
and age, for example (from the endpoint, 3 min ago). If all sources fail, the
distinct reasons appear on stderr with a sign-in hint.
The direct quota request has a 15-second timeout. -v and plain --all can
make one additional request for the plan using the available Antigravity login.
| OS | Credential source |
|---|---|
| macOS | Antigravity's system Keychain entry |
| Linux | Antigravity's Secret Service entry through secret-tool, when available |
| Windows | The signed-in Antigravity CLI via the fallback |
For the protocol and a recipe to rebuild the tool, see docs/HOW_THIS_WAS_BUILT.md.
๐ Privacy & security
- Reads the existing Antigravity login. Antigravity handles token refresh.
- Sends the access token only to
daily-cloudcode-pa.googleapis.comin direct requests. - Keeps only quota fields in the cache and JSON output. The plan lookup extracts the tier name for display.
- Keeps tokens, request headers, and email addresses out of errors and verbose output.
- No telemetry or third-party calls from this CLI.
โ ๏ธ Good to know
- The quota endpoint is undocumented and its format may change.
- Both sources need a signed-in Antigravity CLI and an eligible account.
- The direct request uses Antigravity's versioned User-Agent to receive the Gemini group.
- An unused window can have no reset time. The CLI omits the reset clause for it.
๐ ๏ธ Install options
pip install gemini-usage-limits # from PyPI
pipx install gemini-usage-limits # isolated command installation
pip install . # from a local clone
Requires Python 3.9+. The PyPI distribution is gemini-usage-limits. The command
and GitHub repo are gemini-usage, and the import package is gemini_usage.
๐ค Contributing
Issues and PRs are welcome. After installing the local project with pip install -e .,
run the tests with the following command.
pip install pytest && pytest -q
Tests use temporary directories and mocked HTTP and subprocesses. They never contact the endpoint or read real credentials.
Regenerate the demo with python3 docs/record_demo.py after installing
agg and the DejaVu Sans Mono font.
The recorder uses illustrative quota data with HTTP and credential access
disabled. The README embeds the resulting docs/demo.gif.
๐ License
MIT โ do whatever you like.