Xpersona
O

Openclaw Cost Tracker

CLAWHUB · Unverified

Track OpenClaw token usage and API costs from local session data. Prefer openclaw-cost-diff for current cost analysis and window-over-window comparison acros... Skill: Openclaw Cost Tracker Owner: pfrederiksen Summary: Track OpenClaw token usage and API costs from local session data. Prefer openclaw-cost-diff for current cost analysis and window-over-window comparison acros... Tags: latest:1.1.3 Version history: v1.1.3 | 2026-04-20T17:29:41.938Z | user Prefer openclaw-cost-diff workflow, add updated local usage guidance, keep cost_tracker.py as fallback v1.1.2 | 2026-03-25T2

62
Rank
84
Safety
1.6k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1.6K downloads reported by the source. Last updated 10/10/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s17fk3ter6h1bve6rnejmqxjfx83eymx:openclaw-cost-tracker
  1. Setup complexity is LOW. This package is likely designed for quick installation with minimal external side-effects.
  2. Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-pfrederiksen-openclaw-cost-tracker/snapshot"

Run-check

$0.02 USD

1 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

21,769 characters of source documentation, loaded on request.

Extracted files

4 files captured from the source.

SKILL.md

---
name: openclaw-cost-tracker
description: "Track OpenClaw token usage and API costs from local session data. Prefer openclaw-cost-diff for current cost analysis and window-over-window comparison across models, agents, and channels. Use this skill when a user asks about token spend, API costs, regressions, model breakdowns, daily trends, or what changed between time windows. No API keys needed."
---

# OpenClaw Cost Tracker

Analyze OpenClaw token usage and API costs from local session data.

Prefer `openclaw-cost-diff` as the default tool for current analysis because it can compare time windows and break down changes by model, agent, and channel.

## Preferred usage

```bash
# Compare the last 7 days vs the prior 7 days
/root/.openclaw/venvs/openclaw-cost-diff/bin/openclaw-cost-diff --last 7d --prev 7d

# JSON output for tooling or dashboards
/root/.openclaw/venvs/openclaw-cost-diff/bin/openclaw-cost-diff --data /root/.openclaw/agents --last 7d --prev 7d --json

# Focus on a specific model
/root/.openclaw/venvs/openclaw-cost-diff/bin/openclaw-cost-diff --model openai-codex/gpt-5.4 --last 14d --prev 14d

# Compare agent behavior
/root/.openclaw/venvs/openclaw-cost-diff/bin/openclaw-cost-diff --agent main --prev-agent codex --last 7d --prev 7d
```

## Legacy/local fallback

Use the bundled `cost_tracker.py` only as a secondary local fallback when `openclaw-cost-diff` is unavailable or when you want the older single-window daily spend report format.

```bash
# All-time cost report
python3 scripts/cost_tracker.py

# Last 7 days
python3 scripts/cost_tracker.py --days 7

# Today only
python3 scripts/cost_tracker.py --days 1

# Since a specific date
python3 scripts/cost_tracker.py --since 2026-02-01

# JSON output for dashboards/integrations
python3 scripts/cost_tracker.py --days 30 --format json

# Custom agents directory
python3 scripts/cost_tracker.py --agents-dir /path/to/agents
```

## What It Reports

**Per-model breakdown:**
- Total cost, tokens, and request count
- Input/output/cache token split
- Visual percentage bar

**Daily spend:** Bar chart of cost per day (text) or structured array (JSON).

**Grand totals:** Combined cost, tokens, and requests across all models.

## How It Works

1. Auto-discovers the OpenClaw agents directory (`~/.openclaw/agents`)
2. Scans all agent session JSONL files (filtered by mtime for speed)
3. Extracts `message.usage` and `message.model` from each entry
4. Aggregates by model and by day
5. Outputs formatted report or JSON

## JSON Output Schema

```json
{
  "models": [
    {
      "model": "claude-opus-4-6",
      "totalTokens": 220800000,
      "inputTokens": 3200,
      "outputTokens": 390800,
      "cacheReadTokens": 149400000,
      "cacheWriteTokens": 1200000,
      "totalCost": 528.55,
      "requestCount": 2088
    }
  ],
  "daily": [
    { "date": "2026-02-20", "cost": 37.14, "byModel": { "opus-4-6": 35.0, "sonnet-4": 2.14 } }
  ],
  "grandTotal": { "totalCost": 580.11, "totalTokens": 269800000, "tota

README.md

# OpenClaw Cost Tracker

[![ClawHub](https://img.shields.io/badge/ClawHub-openclaw--cost--tracker-blue)](https://clawhub.ai/pfrederiksen/openclaw-cost-tracker)
[![Version](https://img.shields.io/badge/version-1.1.1-green)]()

An [OpenClaw](https://openclaw.ai) skill for analyzing token usage and API costs from local session data. The preferred workflow now uses `openclaw-cost-diff` for current analysis and window-over-window comparisons, with the older `cost_tracker.py` kept as a fallback.

## Features

- 💰 **Cost diffs across time windows** via `openclaw-cost-diff`
- 🧭 **Breakdowns by model, agent, and channel**
- 📊 **Window-over-window regression detection**
- 📄 **JSON output** for integrations and dashboards
- 🧰 **Legacy fallback** with `cost_tracker.py` for the older single-window summary format

## Installation

```bash
clawhub install openclaw-cost-tracker
```

## Usage

```bash
# Preferred local wrapper
/root/.openclaw/workspace/tools/ocost --last 7d --prev 7d --top 5

# Direct diff tool invocation
/root/.openclaw/venvs/openclaw-cost-diff/bin/openclaw-cost-diff --data /root/.openclaw/agents --last 7d --prev 7d

# JSON output
/root/.openclaw/venvs/openclaw-cost-diff/bin/openclaw-cost-diff --data /root/.openclaw/agents --last 7d --prev 7d --json

# Legacy fallback
python3 scripts/cost_tracker.py --days 7
```

## Security

**Minimal and transparent.** The bundled fallback script is plain Python source, and the preferred diff workflow uses a separately installed CLI. Keep both repo and skill text-only and auditable.

**No hidden payloads.** This skill README and SKILL.md are plain text only.

**Run as non-root when possible.** The analysis only needs read access to local session data.

You can still audit the fallback script source at [scripts/cost_tracker.py](scripts/cost_tracker.py).

## Requirements

- OpenClaw installed with session data in `~/.openclaw/agents/`
- Python 3.8+

## License

MIT

## Links

- [ClawHub](https://clawhub.ai/pfrederiksen/openclaw-cost-tracker)
- [OpenClaw](https://openclaw.ai)
- [Full source](scripts/cost_tracker.py)

_meta.json

{
  "ownerId": "kn7cvyzb78ahvv8e5888vj9r5581apwf",
  "slug": "openclaw-cost-tracker",
  "version": "1.1.3",
  "publishedAt": 1776706181938
}

skill-card.md

## Description:

Tracks OpenClaw token usage and API costs from local session data, preferring openclaw-cost-diff for current cost analysis and comparisons while keeping the bundled Python script as a fallback.

This skill is ready for commercial/non-commercial use.

## Publisher:

[pfrederiksen](https://clawhub.ai/user/pfrederiksen)

### License/Terms of Use:

MIT-0

## Use Case:

Developers and OpenClaw users use this skill to inspect local session data for token spend, model-level cost breakdowns, daily trends, and window-over-window cost regressions without API keys.

### Deployment Geography for Use:

Global

## Known Risks and Mitigations:

Risk: The default workflow invokes a separate local openclaw-cost-diff executable that is not included in the reviewed artifact.

Mitigation: Verify the external CLI's source, version, ownership, permissions, and checksum before use, or run the bundled scripts/cost_tracker.py fallback instead.

Risk: Cost analysis reads local OpenClaw session data that may contain sensitive usage history.

Mitigation: Run as a non-root user with read-only access limited to the required OpenClaw session data.

## Reference(s):

- [ClawHub skill page](https://clawhub.ai/pfrederiksen/skills/openclaw-cost-tracker)
- [OpenClaw](https://openclaw.ai)
- [Bundled fallback script](scripts/cost_tracker.py)

## Skill Output:

**Output Type(s):** [Text, Markdown, JSON, Shell commands, Guidance]

**Output Format:** [Markdown guidance with bash commands and optional JSON cost reports]

**Output Parameters:** [1D]

**Other Properties Related to Output:** [Reads local OpenClaw session JSONL data; no API keys required.]

## Skill Version(s):

1.1.3 (source: server release evidence)

## Ethical Considerations:

Users should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment.

Sponsored

Ads related to Openclaw Cost Tracker and adjacent AI workflows.