Token Cockpit for Openclaw

An essential utility among Openclaw Skills that analyzes local usage logs to monitor, project, and optimize your LLM API token spend without sharing your data.

chris-openclaw
v1.0.0
May 23, 2026
0
709
0

Install & Download

1. ClawHub CLI

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

npx clawhub@latest install token-cockpit

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 token-cockpit 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 Token Cockpit?

Token Cockpit is a lightweight, local-first utility built to help developers audit, forecast, and dramatically reduce their LLM token bills. While running AI agents is incredibly powerful, it often leads to unexpected API costs when the monthly invoice lands. As one of the premier Openclaw Skills for financial observability, Token Cockpit turns standard local usage logs into a comprehensive breakdown of where your budget is being spent and, more importantly, where it is being wasted.

The tool computes everything completely on your local machine, meaning no sensitive data or API keys ever leave your local environment. It addresses the observability gaps in modern AI agent deployments by offering automated reporting, custom budget tracking with alerts, and intelligent suggestions on how to route tasks to cheaper LLMs without losing performance.

Token Cockpit Use Cases

  • Monitoring LLM Spend: Instantly check how much you have spent overall and which models (such as GPT-4o or Claude Opus) are consuming the largest share of your budget.
  • Setting Up Budget Alerts: Establish limit thresholds and trigger automated notifications when daily or monthly spend approaches a warning or error level.
  • Optimizing Model Routing: Identify small-token, trivial tasks being handled by expensive premium models and calculate potential savings from downgrading them.
  • What-If Simulations: Estimate cost differences before changing models globally, answering questions like "how much would I save if I migrated all premium traffic to Haiku?"
  • Projecting Future Costs: Extrapolate current run rates to estimate your final monthly API bill based on local log history.

How Token Cockpit Works

  1. Log Location & Ingestion: The tool automatically scans standard local directories for usage logs (such as usage.jsonl). It tolerates various structures and handles multiple token schema variations.
  2. Price Estimation: It cross-references token counts against a customizable default price table (in USD per million tokens) or a user-provided pricing.json configuration.
  3. Analysis & Calculation: Based on the command invoked, it aggregates costs, projects monthly spending, flags budget overages, or isolates small-scale queries suitable for routing optimizations.
  4. Structured Output: The results are printed to the console as developer-friendly reports or exported directly as JSON output (--json) for automated ingestion or dashboard visualization.

Token Cockpit Setup

To start optimizing your spend with one of the most practical Openclaw Skills, set up the script locally:

Usage Commands

Run basic reports, set budgets, or check routes:

# Generate a spending and usage report for the last 30 days
python token_cockpit.py report --logs ~/.openclaw/usage.jsonl --days 30

# Check spending against a $50 limit for the month
python token_cockpit.py budget --limit 50 --period month --logs ~/.openclaw/usage.jsonl

# Identify optimization opportunities for small token queries
python token_cockpit.py route --logs ~/.openclaw/usage.jsonl --small-tokens 2000

# Simulate migrating from a premium model to a cost-effective alternative
python token_cockpit.py simulate --from claude-opus --to claude-haiku --logs ~/.openclaw/usage.jsonl

Custom Pricing Setup

To ensure exact calculations, provide a custom pricing.json to override default USD pricing (per million tokens):

{
  "claude-opus": {"input": 15.0, "output": 75.0},
  "claude-haiku": {"input": 1.0, "output": 5.0},
  "gpt-4o-mini": {"input": 0.15, "output": 0.60}
}

Pass the file to any command using the pricing flag:

python token_cockpit.py report --logs ~/.openclaw/usage.jsonl --pricing pricing.json

Token Cockpit Data Schema & Taxonomy

Token Cockpit operates flexibly on standard JSONL or JSON log formats, searching for key nested metadata blocks. Below is the structured taxonomy utilized by the tool:

Input Data Fields Supported

Field Name (Variants) Description
input_tokens / prompt_tokens / tokens_in Count of tokens sent to the LLM (Input/Prompt)
output_tokens / completion_tokens / tokens_out Count of tokens generated by the LLM (Output/Completion)
usage Nested JSON object commonly holding token count attributes

Model Price Mapping Schema

Parameter Type Unit Description
input Float USD / Million Tokens Cost per million input/prompt tokens
output Float USD / Million Tokens Cost per million output/completion tokens

Token Cockpit Advanced Features

  • Structured JSON Outputs: Append --json to any execution to convert command-line reports into raw JSON datasets, enabling seamless integration with monitoring scripts and custom alerts.
  • Auto-Detection Algorithms: Automatically checks multiple local path patterns (such as environment variables, user directories, and data subfolders) to discover usage files with minimal setup.
  • Unpriced Model Safety Rails: Flags model calls missing pricing configurations with a warning (⚠️) and calculates them as $0 rather than silently displaying incorrect aggregate estimates.
  • Automated Budget Guardrails: Run budget checks on a daily cron task, filtering outputs to trigger only when spent crosses warning thresholds (e.g., 80% or 100%).

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*