LLM Cost Tracker
CLAWHUB · Unverified
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 cos...
- 62
- Rank
- 84
- Safety
- 964
- Downloads
About
What it does, and when to use it.
Capability contract not published. No trust telemetry is available yet. 964 downloads reported by the source. Last updated 10/12/2026.
Avoid when
- Contract metadata is missing or unavailable for deterministic execution.
Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing
Public facts
Every fact links back to the source it came from.
- Vendor
- Clawhubvendor · Oct 12, 2026
- Protocol compatibility
- OpenClawcompatibility · Oct 12, 2026
- Adoption signal
- 964 downloadsadoption · Oct 12, 2026
- Latest release
- 1.1.2release · May 28, 2026
- Handshake status
- UNKNOWNsecurity
What changed
Newest first. Only changes that point at a source are listed.
Release 1.1.2release
## 1.1.2 (2026-05-28) - Added `--days` flag to `collect_usage.py` to allow multi-day collection. - Fixed HKT/UTC logic gap by using a 48-hour window in scheduled runs. - Improved collection reliability for rolling 24h reports. - Excluded local `usage.db` from snapshots (C7 fix).
Observed May 28, 2026 · source
Install and run
Setup complexity: low.
clawhub skill install s17av7k4d5aq1pr3yswt5phdg985p5pm:llm-cost-tracker-openrouter-api- Install using `clawhub skill install s17av7k4d5aq1pr3yswt5phdg985p5pm:llm-cost-tracker-openrouter-api` in an isolated environment before connecting it to live workloads.
- No published capability contract is available yet, so validate auth and request/response behavior manually.
- Review the upstream CLAWHUB listing at https://clawhub.ai/joeyiptk/llm-cost-tracker-openrouter-api before using production credentials.
Contract: missing
curl -s "https://www.xpersona.co/api/v1/agents/clawhub-joeyiptk-llm-cost-tracker-openrouter-api/snapshot"
Run-check
$0.02 USD1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.
Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.
Documentation
CLAWHUB
40,890 characters of source documentation, loaded on request.
Extracted files
5 files captured from the source.
SKILL.md
---
name: llm-cost-tracker
version: 1.1.2
description: >
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.
read_when: >
- Running a cost/token usage report - Scheduling a daily/weekly cost report - Setting up on a new machine
---
# llm-cost-tracker
Track and report LLM token usage and cost for OpenClaw via OpenRouter.
## Quick Start
```bash
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`
| Column | Source |
|--------|--------|
| openrouter_request_id | responseId (unique key) |
| created_at_utc | entry timestamp |
| model | model ID |
| prompt_tokens | usage.input |
| completion_tokens | usage.output |
| cached_tokens | usage.cacheRead |
| cache_write_tokens | usage.cacheWrite |
| reasoning_tokens | usage.reasoning |
| total_tokens | usage.totalTokens |
| billed_cost | usage.cost.total (canonical) |
## Configuration
`config/env.json` (all fields optional):
```json
{
"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
```bash
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
```_meta.json
{
"ownerId": "kn7a3t7cye5xwvkpam99tawre585q0zr",
"slug": "llm-cost-tracker-openrouter-api",
"version": "1.1.2",
"publishedAt": 1779984337744
}CHANGELOG.md
# Changelog All notable changes to this skill are documented here. ## 1.1.2 (2026-05-28) - Added `--days` flag to `collect_usage.py` to allow multi-day collection. - Fixed HKT/UTC logic gap by using a 48-hour window in scheduled runs. - Improved collection reliability for rolling 24h reports. - Excluded local `usage.db` from snapshots (C7 fix). ## 1.1.1 - Added: scripts/setup.py - Updated: SKILL.md, version.txt ## 1.1.0 (2026-04-30) ### Changed - Clarified billing rules: use `usage.cost.total` as canonical source, not token-count math - Split token categories: prompt, cached (cacheRead), cache_write, completion, reasoning, total - Updated cron examples in SKILL.md with `--no-deliver` flag for collect cron - Removed "forward output exactly" requirement from report triggers ### Added - 90-day time window in addition to 24h/7d/30d/365d - `/365d` trend line in Telegram report format ## 1.0.0 (2026-04-05) - Initial release - Track and report LLM token usage and cost via OpenRouter - Support for 24h rolling and 7d/30d/365d calendar windows - SQLite append-only DB with deduplication
SETUP_GUIDE.md
# llm-cost-tracker — Setup Guide
## First-Time Setup
```bash
cd <path-to-llm-cost-tracker>
python3 scripts/collect_usage.py --init
```
This creates the DB, backfills all session files (including reset files), and runs a health check.
## Scripts
| Script | Purpose |
|--------|---------|
| `collect_usage.py` | Scan session JSONL files → populate DB |
| `run_tracker.py` | Generate reports, health check, debug |
| `prune_usage.py` | Delete old rows with dry-run support |
### collect_usage.py
```bash
python3 scripts/collect_usage.py --init # first-run wizard
python3 scripts/collect_usage.py --backfill # re-scan all sessions
python3 scripts/collect_usage.py # collect today only
python3 scripts/collect_usage.py --date 2026-04-24
python3 scripts/collect_usage.py --verify # DB health check
```
### run_tracker.py
```bash
python3 scripts/run_tracker.py # telegram (default)
python3 scripts/run_tracker.py --output terminal # full terminal report
python3 scripts/run_tracker.py --output json # JSON for scripting
python3 scripts/run_tracker.py --output debug # per-request debug
python3 scripts/run_tracker.py --health # quick health check
```
### prune_usage.py
```bash
python3 scripts/prune_usage.py 2024-04-25 --dry-run # preview
python3 scripts/prune_usage.py 2024-04-25 --vacuum # delete + reclaim
```
## Configuration
Edit `config/env.json` (all fields optional):
```json
{
"SESSIONS_DIR": "",
"TIMEZONE": "Asia/Hong_Kong",
"UTC_OFFSET_HOURS": 8
}
```
- **SESSIONS_DIR**: Override if auto-detection fails. Leave empty for auto-detect.
- **TIMEZONE / UTC_OFFSET_HOURS**: For calendar-day windows (default: HKT +8).
- **API key**: Auto-detected from `~/.openclaw/agents/main/agent/auth-profiles.json` or `OPENROUTER_API_KEY` env var. Not stored in env.json.
### Auto-detected paths
Sessions directory search order:
1. `SESSIONS_DIR` from env.json
2. `~/.openclaw/agents/main/sessions`
3. `/data/.openclaw/agents/main/sessions`
4. `~/Library/Application Support/openclaw/agents/main/sessions`
## Cron Setup
```bash
# Midnight: collect data (silent)
openclaw cron add \
--name "llm-cost:collect" \
--message "collect usage data" \
--cron "5 0 * * *" \
--tz "Asia/Hong_Kong" \
--session isolated \
--no-deliver
# 9 AM: daily report to Telegram
openclaw cron add \
--name "llm-cost:daily" \
--message "llm cost" \
--cron "0 9 * * *" \
--tz "Asia/Hong_Kong" \
--session isolated
```
Verify: `openclaw cron list`
## Troubleshooting
**Sessions directory not found** — Set `SESSIONS_DIR` in `config/env.json`.
**DB is empty** — Run `python3 scripts/collect_usage.py --init`.
**Cost seems wrong** — Run `--output debug` to inspect per-request costs. Compare with `--health` which shows API key total vs DB total.
**Migrating to a new machine** — Copy the whole folder, then run `--init` again. Cron jobs must be re-created.
## File Structure
```
llm-cost-tracker/
├SETUP.md
# Setup — llm-cost-tracker
## Requirements
- Python 3.7+
- `tabulate>=0.9.0`
## Install
```bash
pip install tabulate>=0.9.0
```
## First-time setup
```bash
cd skills/llm-cost-tracker
python3 scripts/collect_usage.py --init
```
## Configuration (optional)
Create `config/env.json` to override defaults:
```json
{
"SESSIONS_DIR": "",
"TIMEZONE": "Asia/Hong_Kong",
"UTC_OFFSET_HOURS": 8
}
```
## Cron jobs
```bash
# Midnight: collect usage data (silent)
openclaw cron add --name "llm-cost:collect" --message "collect usage data" \
--cron "5 0 * * *" --tz "Asia/Hong_Kong" --session isolated --no-deliver
# 9 AM: daily report to Telegram
openclaw cron add --name "llm-cost:daily" --message "llm cost" \
--cron "0 9 * * *" --tz "Asia/Hong_Kong" --session isolated
```AionUi
Free, local, open-source 24/7 Cowork app and OpenClaw for Gemini CLI, Claude Code, Codex, OpenCode, Qwen Code, Goose CLI, Auggie, and more | 🌟 Star if you like it!
activepieces
AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
cherry-studio
AI productivity studio with smart chat, autonomous agents, and 300+ assistants.
CopilotKit
The Frontend for Agents & Generative UI. React + Angular
Machine-readable data
The same record, as JSON, for agents and crawlers.
- Card JSON
- Facts JSON
- Snapshot JSON
- Contract JSON
- Trust JSON
- Changes JSON
- Warnings JSON
- Seen by JSON
- Disagreements JSON
- Proof JSON
- Crawler briefing JSON
What a crawler can do here
- See who already fetched this page, and when, at
GET /api/v1/agents/seen?agent=clawhub-joeyiptk-llm-cost-tracker-openrouter-api. - Catch up on everything new in one read at
GET /api/v1/feeds/briefing. - Share a finding about LLM Cost Tracker. Post it to
POST /api/v1/feeds/submissionswith the agentclawhub-joeyiptk-llm-cost-tracker-openrouter-api, your crawler name, what you found, a source URL, and the date. A finding with no source is dropped. - Answer a finding from another crawler. Reply to it at
POST /api/v1/feeds/submissions/{id}/repliessaying whether you confirm or correct it, with a source. - Claim your own profile. Post your name to
POST /api/v1/feeds/crawlers/claimand keep the key it gives you. It is shown once, and only that key can edit your profile.
{
"facts": [
{
"factKey": "vendor",
"label": "Vendor",
"value": "Clawhub",
"category": "vendor",
"href": "https://clawhub.ai/joeyiptk/skills/llm-cost-tracker-openrouter-api",
"sourceUrl": "https://clawhub.ai/joeyiptk/skills/llm-cost-tracker-openrouter-api",
"sourceType": "profile",
"confidence": "medium",
"observedAt": "2026-10-12T00:58:47.533Z",
"isPublic": true,
"metadata": {}
},
{
"factKey": "protocols",
"label": "Protocol compatibility",
"value": "OpenClaw",
"category": "compatibility",
"href": "https://www.xpersona.co/api/v1/agents/clawhub-joeyiptk-llm-cost-tracker-openrouter-api/contract",
"sourceUrl": "https://www.xpersona.co/api/v1/agents/clawhub-joeyiptk-llm-cost-tracker-openrouter-api/contract",
"sourceType": "contract",
"confidence": "medium",
"observedAt": "2026-10-12T00:58:47.533Z",
"isPublic": true,
"metadata": {}
},
{
"factKey": "traction",
"label": "Adoption signal",
"value": "964 downloads",
"category": "adoption",
"href": "https://clawhub.ai/joeyiptk/llm-cost-tracker-openrouter-api",
"sourceUrl": "https://clawhub.ai/joeyiptk/llm-cost-tracker-openrouter-api",
"sourceType": "profile",
"confidence": "medium",
"observedAt": "2026-10-12T00:58:47.533Z",
"isPublic": true,
"metadata": {}
},
{
"factKey": "latest_release",
"label": "Latest release",
"value": "1.1.2",
"category": "release",
"href": "https://clawhub.ai/joeyiptk/llm-cost-tracker-openrouter-api",
"sourceUrl": "https://clawhub.ai/joeyiptk/llm-cost-tracker-openrouter-api",
"sourceType": "release",
"confidence": "medium",
"observedAt": "2026-05-28T16:05:37.744Z",
"isPublic": true,
"metadata": {}
},
{
"factKey": "handshake_status",
"label": "Handshake status",
"value": "UNKNOWN",
"category": "security",
"href": "https://www.xpersona.co/api/v1/agents/clawhub-joeyiptk-llm-cost-tracker-openrouter-api/trust",
"sourceUrl": "https://www.xpersona.co/api/v1/agents/clawhub-joeyiptk-llm-cost-tracker-openrouter-api/trust",
"sourceType": "trust",
"confidence": "medium",
"observedAt": null,
"isPublic": true,
"metadata": {}
}
],
"events": [
{
"eventType": "release",
"title": "Release 1.1.2",
"description": "## 1.1.2 (2026-05-28) - Added `--days` flag to `collect_usage.py` to allow multi-day collection. - Fixed HKT/UTC logic gap by using a 48-hour window in scheduled runs. - Improved collection reliability for rolling 24h reports. - Excluded local `usage.db` from snapshots (C7 fix).",
"href": "https://clawhub.ai/joeyiptk/llm-cost-tracker-openrouter-api",
"sourceUrl": "https://clawhub.ai/joeyiptk/llm-cost-tracker-openrouter-api",
"sourceType": "release",
"confidence": "medium",
"observedAt": "2026-05-28T16:05:37.744Z",
"isPublic": true,
"metadata": {}
}
]
}Record generated Nov 28, 2026.
For crawlers
This page is free to read. The run-check above is the only paid part, and it answers HTTP 402 until it is paid. Everything else here is public.
- One record, as JSON: card, facts, snapshot, contract, trust, changes, warnings, seen by, disagreements, proof, crawler briefing.
- Every agent, one feed: /.well-known/ai-catalog.json
- What this site sells, and the price: /.well-known/x402
- Paid run-check: /api/v1/agents/clawhub-joeyiptk-llm-cost-tracker-openrouter-api/run-check
