Z.ai GLM Usage Tracker

A VS Code extension that tracks your Z.ai GLM Coding Plan usage and displays it in the status bar. Also works with Windsurf, VSCodium, and other VS Code forks.
Features
Real-time Usage Display: See your 5-hour token quota directly in the status bar
- Shows percentage used and current tokens
- Example:
✓ ⚡ 1% • 14.6K tokens
Detailed Tooltip: Hover to see comprehensive usage stats:
- 5-hour token quota with progress bar
- 7-day usage (prompts + tokens)
- 30-day usage (prompts + tokens)
- Connection status and last update time
Quick Pick Menu: Click status bar for detailed stats and actions
- View all usage metrics
- Refresh usage data
- Configure settings
Automatic Refresh: Configurable refresh interval (default: 5 minutes)
Secure API Key Storage: Uses VS Code's encrypted SecretStorage
Installation
VS Code
Search for "Z.ai GLM Usage Tracker" in the Extensions marketplace, or:
ext install melon-hub.zai-usage-tracker
Windsurf / VSCodium / Other Forks
Available on Open VSX. Search for "Z.ai GLM Usage Tracker" in Extensions.
Cursor
Cursor uses a curated marketplace. Install manually:
- Download the latest
.vsix from GitHub Releases
- In Cursor: Extensions →
... menu → Install from VSIX
- Select the downloaded file
Building from Source
npm install
npm run compile
npx @vscode/vsce package
Configuration
API Key
You need a Z.ai API key to use this extension:
- Go to Z.ai API Key Management
- Create or copy your API key
- Click the status bar item or run command
Z.ai Usage Tracker: Configure Settings
- Select "Update API Key" and paste your key
- Your key is stored securely in VS Code's encrypted storage
Plan Tier
Set your GLM Coding Plan tier:
{
"zaiUsage.planTier": "lite" // Options: "lite", "pro", "max"
}
- Lite: ~120 prompts every 5 hours
- Pro: ~600 prompts every 5 hours
- Max: ~2400 prompts every 5 hours
Refresh Interval
Set how often to fetch usage data (in minutes):
{
"zaiUsage.refreshInterval": 5
}
Minimum: 1 minute, Default: 5 minutes
Usage
Once configured, the extension will:
- Automatically activate when VS Code/Cursor starts
- Display usage in the status bar:
✓ ⚡ 1% • 14.6K tokens
- Update periodically based on your refresh interval
- Show detailed tooltip on hover
- Provide quick actions on click
Commands
zaiUsage.refresh: Manually refresh usage data
zaiUsage.configure: Open configuration menu
zaiUsage.showMenu: Show quick actions menu
Status Bar Display
The status bar shows:
- Connection Status: ✓ (connected) or ⚠ (offline/error)
- Icon: Lightning bolt ⚡
- Percentage: 5-hour token quota percentage (e.g., 1%)
- Tokens: Current tokens used (e.g., 14.6K tokens)
Example: ✓ ⚡ 1% • 14.6K tokens
Background color indicates usage level:
- Normal background: < 80% quota used
- Warning background: ≥ 80% quota used
Development
npm run compile # Compile TypeScript
npm run watch # Watch mode
npx vsce package # Package VSIX
See CLAUDE.md for full development and publishing workflow.
How It Works
- API Service: Attempts to fetch usage data from Z.ai's API endpoints
- Fallback: If no API endpoint is available, uses local tracking
- Configuration: Stores API key and settings in VS Code configuration
- Display: Updates status bar with current usage and progress
- Refresh: Periodically fetches updated data (configurable interval)
API Endpoints
The extension uses the official Z.ai monitor API endpoints:
https://api.z.ai/api/monitor/usage/quota/limit - 5-hour token quota
https://api.z.ai/api/monitor/usage/model-usage - Model usage stats (with time range)
Debugging
Run the debug command to see raw API responses:
- Command:
Z.ai Usage Tracker: Debug: Show Raw API Responses
Privacy
- Your API key is stored securely in VS Code's encrypted SecretStorage
- Usage data is only fetched from Z.ai's official API
- No personal data or code is sent to external services
- All data processing happens locally
Troubleshooting
- Click the status bar item and select "Update API Key"
- Or use
Ctrl+Shift+P → "Z.ai Usage Tracker: Configure Settings"
"Failed to fetch usage"
- Check your internet connection
- Verify your API key is valid at z.ai/manage-apikey
- Try clicking "Retry" in the error message
- Run the debug command to see raw API responses
License
MIT
Support
For issues or questions:
Contributing
Contributions welcome! See CLAUDE.md for development and publishing workflow.