π¦ ClawHub
AI Usage
by @bshandley
Check AI token usage, quotas, and costs across Anthropic and other providers using Anthropic OAuth API and OpenClaw session logs.
TERMINAL
clawhub install ai-usageπ About This Skill
name: ai-usage description: | Check AI usage across Anthropic and other providers. Use when: 1. User asks about AI usage, token usage, or quota 2. User says "what's my AI usage" or "how much have I used" 3. User asks about Anthropic/Claude usage or limits 4. User asks about costs or spending on AI 5. Monitoring usage during heartbeats (daily check)
AI Usage Check
Quick Start
python3 scripts/usage_check.py # Pretty report with gauges
python3 scripts/usage_check.py --json # JSON output for scripting
Requirements
claude CLI in PATH) β for Anthropic quotaWhat It Shows
Anthropic (real quota from OAuth API):
Other Providers (from OpenClaw session logs):
OpenClaw Anthropic breakdown:
How It Works
GET https://api.anthropic.com/api/oauth/usage using Claude Code's OAuth token from ~/.claude/.credentials.json (requires user:profile scope)claude --print -p "ok" (Claude Code refreshes its own OAuth token on any invocation), then re-reads the updated credentials file. If Claude Code isn't installed, Anthropic quota is skipped gracefully.~/.openclaw/agents/main/sessions/*.jsonl for per-provider/model token and cost dataEnvironment Variables
| Variable | Default | Description |
|----------|---------|-------------|
| OPENCLAW_SESSIONS_DIR | ~/.openclaw/agents/main/sessions | OpenClaw session log directory |
| CLAUDE_CREDENTIALS_PATH | ~/.claude/.credentials.json | Claude Code credentials file |
Tips
--json for programmatic consumption (cron jobs, dashboards, alerts)π‘ Examples
python3 scripts/usage_check.py # Pretty report with gauges
python3 scripts/usage_check.py --json # JSON output for scripting
π Tips & Best Practices
--json for programmatic consumption (cron jobs, dashboards, alerts)