API Tokens Monitor — Claude Code Skill
A Claude Code skill for tracking API token usage, monitoring balances, and getting alerts across multiple AI API providers.
Features
- Multi-Provider Support — OpenRouter, OpenAI, Anthropic, MiniMax, Kimi (Moonshot), DeepSeek, Google Gemini, and custom providers
- Balance Monitoring — Automatic balance checking via provider APIs
- Daily Usage Review — End-of-day report summarizing task types, token consumption, and costs
- Drop Alerts — Get notified when any provider's balance drops by $1 (configurable threshold)
- Usage Logging — Track tasks by type (coding, Q&A, translation, analysis, etc.)
- Trend Analysis — Compare daily spending against 7-day averages
- Scheduled Automation — Set up daily reviews and periodic balance checks via Claude Code scheduled tasks
- Multi-Currency — Supports USD, CNY, and other currencies with optional conversion
Installation
1. Copy the skill to your Claude Code skills directory
# Clone the repo
git clone https://github.com/YOUR_USERNAME/api-tokens-monitor.git
# Copy to your Claude Code skills directory
cp -r api-tokens-monitor ~/.claude/skills/api-tokens-monitor
# Or symlink it
ln -s $(pwd)/api-tokens-monitor ~/.claude/skills/api-tokens-monitor
2. Set up API key environment variables
The skill reads API keys from environment variables — it never stores raw keys. Add the relevant variables to your shell profile (~/.zshrc, ~/.bashrc, etc.):
# OpenRouter
export OPENROUTER_API_KEY="sk-or-..."
# OpenAI
export OPENAI_API_KEY="sk-..."
# Anthropic
export ANTHROPIC_API_KEY="sk-ant-..."
# MiniMax
export MINIMAX_API_KEY="..."
export MINIMAX_GROUP_ID="..."
# Kimi / Moonshot
export MOONSHOT_API_KEY="sk-..."
# DeepSeek
export DEEPSEEK_API_KEY="sk-..."
# Google Gemini
export GEMINI_API_KEY="..."
Only set the variables for providers you actually use.
3. Update file paths (important!)
Open SKILL.md and replace all instances of /Users/oratis/Claude/Skills/API_TOKENS_MONITOR/ with your actual installation path.
Usage
Add a provider
Tell Claude Code:
"Add OpenRouter as an API provider" / "添加 OpenRouter 到我的 API 监控"
Claude will verify your environment variable, test the API connection, record the initial balance, and ask if you want to set up alerts.
Check balances
"Check my API balances" / "查看我的 API 余额"
Returns a table showing each provider's current balance, change since last check, and alert status.
Log usage
"Log this task: coding with claude-3.5-sonnet, 15000 input tokens, 8000 output tokens"
"记录一下:用 gpt-4o 做了代码审查,输入 20000 tokens,输出 5000 tokens"
Daily review
"Run my daily API usage review" / "做一下今天的 API 用量复盘"
Produces a comprehensive report:
📊 Daily Usage Review — 2026-03-28
Task Breakdown
| Task Type | Count | Input Tokens | Output Tokens | Cost |
|-----------|-------|-------------|--------------|--------|
| Coding | 12 | 45,000 | 23,000 | $0.85 |
| Q&A | 5 | 12,000 | 8,000 | $0.24 |
Provider Usage
| Provider | Models Used | Total Tokens | Cost | Balance |
|------------|----------------------|-------------|-------|---------|
| OpenRouter | claude-3.5-sonnet | 88,000 | $1.09 | $12.45 |
Balance Changes
| Provider | Start of Day | End of Day | Daily Spend |
|------------|-------------|-----------|-------------|
| OpenRouter | $13.54 | $12.45 | $1.09 |
Set up scheduled daily review
"Set up a daily review at 10pm" / "每天晚上10点自动做用量复盘"
Creates a Claude Code scheduled task that runs automatically.
Set up balance alerts
"Set up balance alerts for all providers" / "设置余额预警"
Creates periodic balance checks (default: every 4 hours) that alert you when any balance drops by more than the configured threshold.
Manual balance input
For providers without balance APIs (Anthropic, Gemini):
"My Anthropic balance is $45.00" / "我的 Anthropic 余额是 45 美元"
Supported Providers
| Provider |
Balance API |
Auto-Check |
Notes |
| OpenRouter |
Yes |
Yes |
Full API support with usage history |
| OpenAI |
Partial |
Yes |
Costs API available, balance may require dashboard |
| Anthropic |
No |
Manual |
No public balance API, manual input required |
| MiniMax |
Yes |
Yes |
Supports cash + gift balance |
| Kimi (Moonshot) |
Yes |
Yes |
Supports cash + voucher balance |
| DeepSeek |
Yes |
Yes |
Supports granted + topped-up balance |
| Google Gemini |
No |
Manual |
Check via GCP console |
| Custom |
Configurable |
Yes |
Provide your own curl command |
File Structure
api-tokens-monitor/
├── SKILL.md # Skill definition (Claude Code reads this)
├── providers.md # Registered providers and last known balances
├── usage_log.md # Daily usage history
└── README.md # This file
Data Privacy & Security
- No raw API keys are stored — only environment variable names are referenced
- All data files are local to your machine
- Balance checks are performed via your own terminal, no third-party proxy
- Usage logs stay on disk and are never transmitted
Customization
Alert threshold
Default is $1.00 per provider. Change it when adding a provider or update providers.md directly.
Review schedule
Default daily review is at 22:00 local time. Adjust by updating the scheduled task:
"Change my daily review to 11pm" / "把每日复盘改到晚上11点"
Balance check frequency
Default is every 4 hours. Adjust similarly:
"Check balances every 2 hours" / "每2小时检查一次余额"
Limitations
- Some providers (Anthropic, Gemini) don't expose a balance API — these require manual input
- Token counts for usage logging may need manual input or estimation if not available from the provider
- Scheduled tasks only run while Claude Code is active
- Exchange rates for cross-currency comparisons are fetched on demand and may fluctuate
Contributing
PRs welcome! To add support for a new provider:
- Add the provider's balance check method to the
Supported Providers section in SKILL.md
- Add the provider to the table in this README
- Test the balance check command and document the response format
License
MIT