Token Usage Tracker for Openclaw

A comprehensive toolkit for logging per-call token usage, normalizing timestamps, and compressing LLM context to optimize performance and costs.

gerhardvr26
v1.0.0
Mar 1, 2026
0
882
0

Install & Download

1. ClawHub CLI

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

npx clawhub@latest install oken-usage-tracker

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 oken-usage-tracker 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 Usage Tracker?

The Token Usage Tracker is a specialized suite of utilities designed for the OpenClaw ecosystem to provide deep visibility into LLM consumption. By integrating interceptors and logging helpers, it enables developers to maintain a transparent audit trail of every API call, ensuring that costs are managed and performance is optimized through intelligent context compression. This skill is essential for any developer looking to build sustainable and efficient AI-driven applications using Openclaw Skills.

This collection of scripts doesn't just record data; it actively helps reduce the footprint of your messages. With built-in summarization tools, you can trim verbose contexts before they reach the model, significantly lowering your overhead without sacrificing the quality of agent interactions.

Token Usage Tracker Use Cases

  • Monitoring real-time token consumption across various LLM providers.
  • Reducing API costs by summarizing lengthy contexts before transmission.
  • Normalizing timestamps across distributed logs for easier debugging and analysis.
  • Setting up threshold-based alerts to prevent unexpected billing spikes.
  • Cleaning and deduping historical token usage logs for accurate reporting.

How Token Usage Tracker Works

  1. The interceptor captures incoming and outgoing LLM messages, normalizing metadata like timestamps for consistency.
  2. The tracker script logs the per-call token usage directly into a JSONL format for persistent, queryable storage.
  3. The context summarizer processes large data payloads to reduce the token count while preserving essential information.
  4. Alert scripts evaluate the usage data against pre-defined thresholds in the configuration to trigger notifications.
  5. Utility scripts perform maintenance tasks like log deduping and timestamp migration to keep the data schema clean and efficient.

Token Usage Tracker Setup

  1. Configure the skill-config.json file to set your preferred timezone and log directory.
  2. Copy the Python scripts from the scripts/ directory into your active workspace.
  3. Wire the token_interceptor.py into your message pipeline to begin capturing data.
  4. (Optional) Review and apply the systemd unit files found in references/systemd/ for background service management.
# Example: Reducing context size before an API call
python scripts/context_summarizer.py --input large_context.txt

# Example: Cleaning up logs
python scripts/dedupe_log.py --file ./skills/logs/usage.jsonl

Token Usage Tracker Data Schema & Taxonomy

The skill organizes data primarily in JSONL format within the configured log folder for high-performance writes and easy ingestion into analytics tools.

Component File/Path Metadata/Parameters
Configuration skill-config.json timezone, log_folder, summary_target_tokens
Usage Logs .logs/*.jsonl Timestamp, token_count, model_id, request_id
Logic scripts/ Executable Python logic for interceptors and trackers
Deployment references/systemd/ Service unit templates for Linux environments

Token Usage Tracker Advanced Features

  • Intelligent context compression via context_summarizer.py to minimize payload size and latency.
  • Automated timestamp normalization to ensure consistency across different geographic regions.
  • Threshold-based alerting logic designed to monitor usage spikes and prevent budget overruns.
  • Data maintenance utilities for deduplicating logs and migrating legacy data formats smoothly.
  • Granular control over compression settings including max_context_tokens and summary_target_tokens via Openclaw Skills configuration files.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*