llm-cost-tracker

Track OpenClaw LLM token usage and cost from OpenRouter API. Reports: last 24h, 7d, 30d, 90d, 365d with model breakdown. Skills that trigger this: - "llm cost", "token usage", "openrouter cost", "llm spend", "daily cost report" → runs run_tracker.py - "collect usage data" → runs collect_usage.py (populates DB silently) When "collect usage data" is received (e.g. from a cron job), run: python3 scripts/collect_usage.py and return "Done" — do NOT send any message to Telegram or any chat.

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "llm-cost-tracker" with this command: npx skills add joeyiptk/llm-cost-tracker-openrouter-api

llm-cost-tracker

Track and report LLM token usage and cost for OpenClaw via OpenRouter.

Quick Start

python3 scripts/collect_usage.py --init      # first-time: create DB + backfill
python3 scripts/run_tracker.py               # telegram report (default)
python3 scripts/run_tracker.py --output terminal  # full terminal report
python3 scripts/run_tracker.py --output debug     # per-request debug

Core Design

  • Source of truth: usage.cost.total from OpenRouter — never recomputed from token counts
  • Data source: OpenClaw session JSONL files (including .reset files from context compaction)
  • Deduplication: by openrouter_request_id — safe to re-run backfill anytime
  • Time windows: 24h rolling (UTC); 7d/30d/90d/365d calendar days (configurable timezone)

Schema: request_facts

ColumnSource
openrouter_request_idresponseId (unique key)
created_at_utcentry timestamp
modelmodel ID
prompt_tokensusage.input
completion_tokensusage.output
cached_tokensusage.cacheRead
cache_write_tokensusage.cacheWrite
reasoning_tokensusage.reasoning
total_tokensusage.totalTokens
billed_costusage.cost.total (canonical)

Configuration

config/env.json (all fields optional):

{
  "SESSIONS_DIR": "",
  "TIMEZONE": "Asia/Hong_Kong",
  "UTC_OFFSET_HOURS": 8
}
  • SESSIONS_DIR: override session file location (empty = auto-detect)
  • TIMEZONE / UTC_OFFSET_HOURS: for calendar-day window calculations
  • API key: auto-detected from ~/.openclaw/agents/main/agent/auth-profiles.json or OPENROUTER_API_KEY env var

Scheduled Reports

openclaw cron add --name "llm-cost:collect" --message "collect usage data" \
  --cron "5 0 * * *" --tz "Asia/Hong_Kong" --session isolated --no-deliver

openclaw cron add --name "llm-cost:daily" --message "llm cost" \
  --cron "0 9 * * *" --tz "Asia/Hong_Kong" --session isolated

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Automation

小红书竞品监控助手

小红书竞品监控 - 自动采集竞品笔记,推送飞书通知,写入数据看板

Registry SourceRecently Updated
3210Profile unavailable
Automation

Self-Repair System — Autonomous AI Automation

Automated self-diagnostics: restarts crashed Ollama, repairs broken configs, verifies workspace integrity, recovers from common failures.

Registry SourceRecently Updated
4590Profile unavailable
Automation

Overkill Mission Control

Comprehensive Mission Control dashboard for OpenClaw - monitor agents, automation, teams, documents, messages, and system metrics. Features real-time dashboa...

Registry SourceRecently Updated
4290Profile unavailable
Automation

Task Watcher Skill

Monitor async tasks by polling their state and send Discord/Telegram notifications on changes or completion for workflows like CI/CD, deployments, or reviews.

Registry SourceRecently Updated
3180Profile unavailable