📊 gemini-usage
Your Antigravity plan limits — right from your terminal.
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.
📊 Example · --all
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.
🔍 Where credentials live (per OS)
| 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.
Metadata
Release files for gemini-usage-limits 0.1.0
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 |
|---|---|---|---|---|
| gemini_usage_limits-0.1.0.tar.gz | 23.0 kB | Without provenance | Details for gemini_usage_limits-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gemini_usage_limits-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for gemini_usage_limits-0.1.0-py3-none-any.whl |
Total release size: 37.1 kB
Release files / gemini_usage_limits-0.1.0.tar.gz
| Download URL | gemini_usage_limits-0.1.0.tar.gz |
|---|---|
| Size | 23.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
faf751824dd96d2e7518d4fe6ed747c9736b0c5886a7383463d6d46ff37b24b7
|
|
BLAKE2b-256 checksum How to use checksums |
5205b6b85237fab6e714eb5bc6f707bfd2d38d24bca95a8e4f73bedc99bb0a55
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.9
|
Release files / gemini_usage_limits-0.1.0-py3-none-any.whl
| Download URL | gemini_usage_limits-0.1.0-py3-none-any.whl |
|---|---|
| Size | 14.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fe87f17d093f6c24ca414c9a1c12cae676f27bc0217a50de962135c7e82cd449
|
|
BLAKE2b-256 checksum How to use checksums |
dfe4dc733b816c5b922263dd820a6a52a9d2719f5049e832c45ffda1c30864c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.9
|
Security for gemini-usage-limits 0.1.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.