Usage Costs for Openclaw

A powerful analytics tool to monitor, report, and optimize AI token usage and costs across all agent sessions.

netanel-abergel
v1.0.0
Apr 6, 2026
0
539
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install usage-costs

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install usage-costs using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is Usage Costs?

The Usage Costs skill provides deep visibility into the financial impact of running AI agents within the Openclaw Skills ecosystem. By monitoring live sessions and historical logs, it delivers precise reports on token consumption, specifically optimized for high-performance models like Claude Sonnet. It helps developers understand where their budget is going by breaking down costs into input, output, and cache-related expenses.

This skill is particularly useful for teams running complex workflows or automated cron jobs that require regular auditing to ensure resource efficiency. It bridges the gap between raw API usage and actionable financial insights directly through the terminal or chat interface.

Usage Costs Use Cases

  • Daily financial auditing to track total AI model spending.
  • Analyzing the cost-effectiveness of long-running agent sessions using Openclaw Skills.
  • Monitoring token consumption of automated cron jobs and background subagents.
  • Auditing cache performance to identify opportunities for cost reduction through prompt caching.

How Usage Costs Works

  1. Scans live session metrics via the CLI to retrieve current token counts per active agent.
  2. Accesses the cron run history directory to aggregate usage data from background tasks.
  3. Parses daily aggregate files to calculate historical spend over weeks or months.
  4. Applies specific pricing logic for providers like Anthropic, accounting for input, output, and cache hit/miss rates.
  5. Generates human-readable cost reports formatted for immediate analysis.

Usage Costs Setup

To initialize the tracking environment for Openclaw Skills, ensure your local context is configured:

# Create the local context file with your pricing variables
echo "PRICING_INPUT=3.00" > /opt/ocana/openclaw/workspace/skills/usage-costs/.context
echo "PRICING_OUTPUT=15.00" >> /opt/ocana/openclaw/workspace/skills/usage-costs/.context

# Ensure the token history log exists
touch /opt/ocana/openclaw/workspace/data/token-history.jsonl

Usage Costs Data Schema & Taxonomy

The skill organizes usage data across several flat-file formats for transparency:

Data Source Format Key Metrics Captured
token-history.jsonl JSONL Date, input/output tokens, cache_read, cost_usd
cron/runs/*.jsonl JSONL Job name, timestamp, usage.input_tokens, usage.output_tokens
status --deep CLI Output Session key, model, kind (main/subagent), active tokens
sessions/*.jsonl JSONL Detailed message-level usage and provider-calculated cost

Usage Costs Advanced Features

  • Multi-agent support: Separates costs for main sessions versus background subagents.
  • Provider-specific extraction: Includes a specialized Python logic for Anthropic Claude models to extract exact cost fields from message metadata.
  • Cache efficiency reporting: Calculates how much was saved through cache reads versus cache writes.
  • Historical trend analysis: Summarizes spend across custom timeframes including today, yesterday, and the past week.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*