AI Token Monitor: Track Claude, Gemini, Grok, Kimi Quota Live on Your Linux Desktop
Free open-source desktop widget for Linux that shows real-time AI token quotas with HP-bar progress visualization inside Conky. Supports Claude, Gemini, Grok, and Kimi with live API polling and reset countdowns.
- Python
- Conky
- Linux
- MIT
- Updated 2026-06-06
The Problem: Juggling Six AI Services and Never Knowing Which One Is Out #
Modern developers use four to eight AI services simultaneously — Claude for complex reasoning, Gemini for long-context analysis, Grok for real-time web data, Kimi for large document processing. Each service has its own quota dashboard, reset schedule, and billing page.
The result: you hit a rate limit mid-task, spend five minutes switching browser tabs, discover Gemini’s free quota reset at midnight UTC (not your local midnight), and waste another ten minutes debugging why your Kimi call returned 429.
AI Token Monitor solves this with a persistent desktop widget that shows every service’s status at a glance — without leaving your editor.
● Claude ░░░░░░░░░ 无余额
● Gemini ░░░░░░░░░ 配额用完
● Grok ░░░░░░░░░ 耗尽
● Kimi █████████ 22.4M剩
● Codex ───────── 18:42:01
● Kilo ───────── 18:42:01
How It Works #
The monitor has two components:
api_fetcher.py — a background script (cron every 5 min) that polls each service API and writes results to ~/token-monitor/api_cache.json.
conky_ai.py — reads the cache every 30 seconds and outputs Conky-formatted text with inline ${color} tags. Conky renders this as the desktop widget.
api_fetcher.py → api_cache.json → conky_ai.py → Conky display
(cron/5m) (JSON cache) (30s poll) (always on)
This architecture means API failures never freeze your desktop. The cache always has the last known state.
HP-Bar Progress Visualization #
The key feature is the blood-bar style quota display — a row of Unicode block characters that visually represent remaining quota:
| Color | State |
|---|---|
█████████ green | Above 50% quota |
████░░░░░ orange | 20–50% remaining |
█░░░░░░░░ red | Below 20% |
░░░░░░░░░ red | Exhausted / no balance |
───────── gray | No API key configured |
The bar is 9 characters wide. Each █ represents ~11% of quota.
Installation #
# 1. Clone
git clone https://github.com/luckybbjason1/ai-token-monitor
cd ai-token-monitor
# 2. Install
bash install.sh
# 3. Add API keys
nano ~/.config/.ai_monitor_keys
# 4. Restart Conky
pkill conky && conky --daemonize --pause=1
The installer automatically:
- Copies scripts to
~/token-monitor/ - Adds
${execpi 30 python3 ~/token-monitor/conky_ai.py}to your Conky config - Sets up the cron job for
api_fetcher.py
Supported Services and API Methods #
| Service | API Endpoint | What We Detect |
|---|---|---|
| Kimi (Moonshot) | GET /v1/users/me | Exact token quota remaining |
| Claude (Anthropic) | POST /v1/messages | Rate-limit headers per window |
| Gemini (Google) | POST .../generateContent | 429 = quota exceeded |
| Grok (xAI) | GET /v1/models | 403 = balance exhausted |
| Codex / Kilo | — | Countdown to midnight UTC+8 |
For services without quota APIs (Codex, Kilo), the monitor shows a countdown to the standard daily reset at midnight UTC+8.
Security Design #
API keys are stored in ~/.config/.ai_monitor_keys with chmod 600. The file is excluded from git. Keys are never echoed to terminal or written to log files — the fetcher reads them once at startup and they stay in memory only for the duration of the HTTP call.
For the cautious: review api_fetcher.py before installing. It makes only GET/POST requests to official API endpoints with your own keys. No data is sent anywhere except the respective AI service.
Adding Custom Services #
Open api_fetcher.py and add a block after the existing services:
# ── Your Service ─────────────────────────────────
key = keys.get('yourservice')
if key:
try:
r = requests.get('https://api.yourservice.com/v1/usage',
headers={'Authorization': f'Bearer {key}'}, timeout=8)
if r.status_code == 200:
data = r.json()
remain = data['quota_remaining']
total = data['quota_total']
cache['YourService'] = {
'ok': True,
'label': f'{remain//1000}K剩',
'pct': remain / total
}
else:
cache['YourService'] = {'ok': False, 'label': 'API Error'}
except Exception:
pass
Then add {'name': 'YourService', 'reset_h': 24} to the SERVICES list in conky_ai.py.
Related Tools on dibi8 #
If you are managing multiple AI API costs, also check:
- AI Coding 2026 Q2 Shootout — Claude Code vs Cursor vs Codex — real usage cost comparison for dev workflows
- RTK Rust CLI Proxy — 80% AI Cost Savings — automatically routes prompts to cut AI API costs by up to 80%
- AI Coding Monthly Bill 2026 — actual receipts from six months of production AI usage
Get the Code #
The tool is fully open source under MIT license.
GitHub: github.com/luckybbjason1/ai-token-monitor
Star the repo if it saved you from a mid-task rate-limit surprise. Issues and PRs welcome — especially for adding macOS support or new service integrations.
💬 Discussion