Gemini CLI
Tracks the Google Gemini CLI from local files. OAuth credentials and session logs feed token counts and conversation activity; an optional Cloud Code endpoint adds user-quota data.
At a glance
- Provider ID —
gemini_cli - Detection —
geminibinary onPATHplus~/.gemini/ - Auth — OAuth in
~/.gemini/oauth_creds.json(refresh tokens supported) - Type — coding agent
- Tracks:
- OAuth status and scope
- Account email
- Auth type and install ID
- Conversation count
- Session usage: input, output, cached, reasoning, tool tokens
- MCP configuration
- Version
Setup
Auto-detection
OpenUsage requires both the gemini binary on PATH and the ~/.gemini/ directory. The CLI creates the directory after the first run.
Optional environment variables consulted when present:
GOOGLE_CLOUD_PROJECTGOOGLE_CLOUD_PROJECT_ID
Manual configuration
{
"accounts": [
{
"id": "gemini_cli",
"provider": "gemini_cli",
"binary": "/usr/local/bin/gemini",
"extra": {
"config_dir": "~/.gemini"
}
}
]
}
Data sources & how each metric is computed
Gemini CLI has two data paths:
- Local files under
~/.gemini/— the authoritative source for OAuth status, account email, conversation count, MCP config, and session token usage. - Optional Cloud Code RPCs —
loadCodeAssistandretrieveUserQuotaagainsthttps://cloudcode-pa.googleapis.com/v1internal/. Provides Google's view of tier/quota for your account. Requires the OAuth access token fromoauth_creds.json(refreshed automatically when expired) plus a Google Cloud project ID either fromextra.config_dir's settings or theGOOGLE_CLOUD_PROJECT/GOOGLE_CLOUD_PROJECT_IDenv var.
OAuth status
- Source:
~/.gemini/oauth_creds.json. Fields:access_token,refresh_token,expiry_date(Unix millis),scope. - Transform: status is computed from
expiry_date - now:- missing / unreadable →
auth(no creds) - expired with
refresh_token→ background refresh againsthttps://oauth2.googleapis.com/token; status remainsokif refresh succeeds. - otherwise
ok. The scope string is stored verbatim.
- missing / unreadable →
Account email
- Source:
~/.gemini/google_accounts.jsonactivefield. - Transform: stored as
Attributes["account_email"].
Conversation count
- Source: count of
*.pbfiles under~/.gemini/antigravity/conversations/. The provider decodes only the protobuf headers; it does not store transcript bodies. - Transform: stored as
Metrics["total_conversations"](Used = file count).
Session token usage (input / output / cached / reasoning / tool)
- Source:
~/.gemini/tmp/session_*.jsonfiles. Each session's last-known token totals are read from the JSON. - Transform: aggregated across sessions:
session_input_tokens,session_output_tokens,session_cached_tokens,session_reasoning_tokens,session_tool_tokens.- Per-model and per-client breakdowns where the session metadata identifies them.
MCP configuration
- Source:
~/.gemini/settings.jsonmcpServersmap plus~/.gemini/mcp-server-enablement.json. - Transform: count of enabled MCP servers stored as a metric; the list is rendered as detail rows.
Install ID, version
- Source:
~/.gemini/installation_idand thegeminibinary version output. - Transform: stored as snapshot attributes (
install_id,cli_version).
Quota (when enabled)
- Source:
POST https://cloudcode-pa.googleapis.com/v1internal/loadCodeAssistreturns the current tier;POST .../retrieveUserQuotareturns per-tier quotas. Each bucket carriesremainingAmountandremainingFraction;usedandlimitare derived (limit = 100,used = 100 - remainingFraction * 100). - Transform: each quota becomes a metric (
quota_<name>) withLimit = 100,Remaining = remainingFraction * 100,Used = 100 - Remaining,Unit = %. The active tier is stored asAttributes["tier"]. When the response indicates< 15%remaining on any quota, status promotes tonear_limit.
Auth status (composite)
- Source: combines OAuth status + Cloud Code call status. A missing project ID produces an
authwarning only on the Cloud Code call; local data continues to render.
What's NOT tracked
- $ spend. Google's free-tier Gemini CLI is not metered to the user, and the Cloud Code RPCs return quota counts, not dollars.
- Full conversation content. Protobuf bodies are not parsed beyond the header.
How fresh is the data?
- Polled every 30 s by default. OAuth refresh runs at most once per poll. Conversation files and session JSONs are re-read each poll; counts update as the CLI writes them.
API endpoints used
POST https://cloudcode-pa.googleapis.com/v1internal/loadCodeAssist— tier discoveryPOST https://cloudcode-pa.googleapis.com/v1internal/retrieveUserQuota— per-tier quota countersPOST https://oauth2.googleapis.com/token— refresh-token exchange (only when access token is expired)
Files read
~/.gemini/oauth_creds.json— OAuth tokens~/.gemini/google_accounts.json— account list~/.gemini/settings.json— CLI settings + MCP servers~/.gemini/installation_id— install ID~/.gemini/antigravity/conversations/**/*.pb— conversation history (protobuf, headers only)~/.gemini/tmp/session_*.json— session transcripts~/.gemini/mcp-server-enablement.json— MCP enable flags
Caveats
- Without a Google Cloud project, user-quota data is unavailable; local session counts still work.
- Refresh tokens are honored automatically; you should never need to re-authenticate.
- Conversation files are protobuf-encoded; OpenUsage decodes the headers it needs but does not store full transcripts.
Troubleshooting
- OAuth status: expired — run
geminionce to refresh; if that fails, re-authenticate withgemini auth login. - No quota data — set
GOOGLE_CLOUD_PROJECTand re-run. - Token counts missing — check that
~/.gemini/tmp/session_*.jsonfiles are being written.
Related
- Gemini API — track raw API usage for the same models