{
  "markdown": "# Gemini CLI Usage Monitor\n\nA Gemini CLI extension that monitors your Google Cloud API usage and compares it against subscription plan limits.\n\n## Overview\n\nThis extension provides a simple way to check your Google Cloud API usage directly from the Gemini CLI. It queries the Google Cloud Monitoring API to fetch your API request count and compares it against your subscription plan limits.\n\n## Features\n\n- 🔍 Query API usage for any Google Cloud project\n- 📊 Compare usage against subscription plan limits (Free, Pro, Ultra, Standard, Enterprise)\n- ⚡ Visual status indicators (OK, LOW, WARNING, OVER LIMIT)\n- 📅 Automatic querying of the most recent complete UTC day\n- 🔐 Secure authentication using Google Cloud Application Default Credentials\n\n## Prerequisites\n\n- Gemini CLI v0.8.2 or later\n- Python 3.6 or later (included with most systems)\n- A Google Cloud project with billing enabled\n- Access to Google Cloud Monitoring API\n\n**No pip packages, gcloud CLI, or system modifications required!** This extension uses only Python standard library and authenticates using your existing Gemini CLI credentials.\n\n## Installation\n\nInstall directly from the git repository - no additional dependencies or setup required:\n\n```bash\ngemini extensions install https://github.com/yourusername/geminicli-usage.git\n```\n\nThat's it! The extension is ready to use.\n\n## Setup (First Time Only)\n\nBefore using the extension, you need to:\n\n### 1. Authenticate with Gemini CLI\n\nIf you haven't already, authenticate with Gemini CLI:\n\n```bash\ngemini\n```\n\nFollow the prompts to sign in with your Google account. This creates authentication credentials that the extension will use.\n\n### 2. Enable Cloud Monitoring API\n\nThe extension requires the Cloud Monitoring API to be enabled in your Google Cloud project. Enable it via the [Google Cloud Console](https://console.cloud.google.com/apis/library/monitoring.googleapis.com):\n\n1. Visit the [Cloud Monitoring API page](https://console.cloud.google.com/apis/library/monitoring.googleapis.com)\n2. Select your project\n3. Click \"Enable\"\n\n**Note**: Most Google Cloud APIs, including the Generative Language API, are not enabled by default and must be activated manually.\n\n## Usage\n\n⚠️ **Interactive mode only** - The extension works in interactive chat. The `-p` (prompt) flag currently has a known bug, likely related to Gemini CLI's MCP implementation, which causes the command to hang indefinitely.\n\nStart Gemini CLI:\n\n```bash\ngemini\n```\n\nThen ask about your usage in natural language:\n\n```\n> Check my usage for project my-project-123 on the pro plan\n```\n\nThe extension provides a `check_usage` tool that Gemini will automatically invoke.\n\n### Example Prompts\n\n```\n> Check my usage for project my-project-123 on the pro plan\n```\n\n```\n> What's my API usage for project my-gcp-project on the free plan?\n```\n\n```\n> Show usage for project my-project, I'm on the ultra plan\n```\n\n```\n> How many API requests have I used today for project my-company-project on the enterprise plan?\n```\n\n### Example Output\n\n```\nGemini API Usage Report - 2025-10-17\n\nTotal Requests: 1,367\n\nPlan: Google AI Pro\n  Limit:     1,500 requests/day\n  Used:      1,367 requests\n  Remaining: 133 requests (8.9% available)\n  Status:    ⚠️  WARNING\n\n💡 Consider upgrading your plan if you frequently approach this limit.\n```\n\n**Tip:** Be specific in your prompts. Include both the project ID and plan type clearly.\n\n### Available Plans\n\n- `free`: 1,000 requests/day\n- `pro`: 1,500 requests/day (Google AI Pro)\n- `ultra`: 2,000 requests/day (Google AI Ultra)\n- `standard`: 1,500 requests/day\n- `enterprise`: 2,000 requests/day\n\n### Status Indicators\n\nThe extension displays one of four status indicators based on your usage:\n\n- **✓ OK**: Usage is below 75% of your daily limit (comfortable usage level)\n- **⚡ LOW**: Usage is between 75% and 90% of your daily limit (approaching limit)\n- **⚠️ WARNING**: Usage is between 90% and 100% of your daily limit (very close to limit)\n- **❌ OVER LIMIT**: Usage has exceeded 100% of your daily limit (rate limiting may occur)\n\n### Note on Time Range\n\nThe extension queries the last 7 days of data by default to ensure metrics are available. The report shows usage for the most recent complete day.\n\n## Troubleshooting\n\n### Extension Hangs or Times Out\n\n**Problem**: Command hangs indefinitely with no response\n\n**Solution**: Use **interactive mode only**. The `-p` (prompt) flag has a known bug, likely related to Gemini CLI's MCP implementation:\n\n```bash\n# ❌ Does not work - hangs indefinitely\ngemini -p 'check my usage...'\n\n# ✅ Works\ngemini\n> check my usage for project X on plan Y\n```\n\nThis appears to be a bug in Gemini CLI's handling of MCP tool calls when using the `-p` flag, not a limitation of this extension.\n\n### Authentication Errors\n\n**Problem**: \"Permission denied accessing project\" or \"Failed to get access token\"\n\n**Solutions**:\n1. Ensure you've authenticated with Gemini CLI first by running `gemini` and following the sign-in prompts (this creates `~/.gemini/oauth_creds.json`)\n2. Verify your project ID is correct\n3. Check you have the required IAM role via the [Google Cloud Console IAM page](https://console.cloud.google.com/iam-admin/iam):\n   - You need at least the `Monitoring Viewer` role (`roles/monitoring.viewer`)\n   - Or any role that includes the `monitoring.timeSeries.list` permission\n\n### API Not Enabled\n\n**Problem**: \"Cloud Monitoring API may not be enabled\"\n\n**Solution**: Enable the API via the [Google Cloud Console](https://console.cloud.google.com/apis/library/monitoring.googleapis.com):\n1. Visit the [Cloud Monitoring API page](https://console.cloud.google.com/apis/library/monitoring.googleapis.com)\n2. Select your project\n3. Click \"Enable\"\n\nThe API is not enabled by default and must be activated manually for each project.\n\n### No Data Found\n\n**Problem**: Query returns 0 requests but you know you've made API calls\n\n**Possible causes**:\n1. The metric may not be available yet (monitoring data has a delay)\n2. You're querying the wrong project ID\n3. The API calls were made to a different service\n\n**Solution**: \n- Wait a few minutes for metrics to populate (monitoring data has inherent delays)\n- Verify your project ID is correct\n- Check the [Google Cloud Console Monitoring page](https://console.cloud.google.com/monitoring) to see available metrics for your project\n\n\n## Uninstallation\n\nTo remove the extension:\n\n```bash\ngemini extensions uninstall gemini-usage-monitor\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit issues or pull requests.\n\n## License\n\nApache 2.0 - See LICENSE file for details\n\n## Support\n\nFor issues or questions:\n- Check the troubleshooting section above\n- Review the [Gemini CLI Extensions Documentation](https://google-gemini.github.io/gemini-cli/docs/extensions/)\n- File an issue in the repository\n\n\n",
  "bytes": 6830,
  "sha": "6e2038b7892f74ac8781b23810c65b0ccd75b9483155f941701011425ff4f76a",
  "repo_slug": "b3nw/gemini-cli-usage",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/plg_b3nw_gemini_cli_usage_ab2eddfb/readme"
}