Token Optimizer for Openclaw

The Token Optimizer reduces OpenClaw AI costs by up to 97% through intelligent model routing, local provider heartbeats, and efficient prompt caching.

smartpeopleconnected
v1.0.18
Feb 21, 2026
28
12.2k
0

Install & Download

1. ClawHub CLI

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

npx clawhub@latest install token-optimizer

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-optimizer 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 Optimizer?

Token Optimizer is a high-performance utility designed to stop the excessive burning of expensive LLM tokens during development. By default, many agents use high-cost models for trivial tasks; this skill recalibrates your environment to prioritize Claude Haiku while reserving premium models like Sonnet or Opus only for complex reasoning. It is a vital tool within the ecosystem of Openclaw Skills for developers looking to scale their AI workflows without the enterprise-level price tag.

The tool addresses cost leakages in four primary areas: model routing, multi-provider heartbeats using local engines like Ollama, session context management, and prompt caching. By moving heartbeats to free local providers and trimming context windows, users can see their monthly AI spend drop from thousands to just double digits.

Token Optimizer Use Cases

  • Reducing monthly API bills from hundreds or thousands of dollars to under fifty dollars.
  • Moving frequent AI heartbeat checks to local LLMs like Ollama or LM Studio to eliminate per-request costs.
  • Implementing strict budget controls to prevent runaway token usage during long-running agent sessions.
  • Optimizing agent prompts and context window sizes to ensure high-efficiency token utilization.

How Token Optimizer Works

  1. The tool performs a deep analysis of your current configuration to identify expensive model defaults and heartbeat settings.
  2. It generates a preview of optimized settings, including model routing to Haiku and local provider integration.
  3. Upon approval, it creates a timestamped backup of your existing configuration for safety.
  4. It applies the optimizations to the OpenClaw configuration file and installs efficient prompt templates.
  5. It provides ongoing health checks and usage statistics to verify savings and maintain performance.

Token Optimizer Setup

To integrate this utility into your Openclaw Skills library, follow these steps:

# Install the skill via clawhub
clawhub install token-optimizer

# Analyze your current cost profile
python cli.py analyze

# Apply the optimizations to your config
python cli.py optimize --apply

# Configure a local heartbeat provider (optional but recommended)
python cli.py setup-heartbeat --provider ollama --apply

Token Optimizer Data Schema & Taxonomy

The skill manages several key files within the ~/.openclaw/ directory to ensure cost efficiency and reliability:

Path Description
~/.openclaw/openclaw.json The primary configuration file containing model routing, budgets, and heartbeat settings.
~/.openclaw/backups/ Storage for timestamped configuration snapshots for quick rollback.
~/.openclaw/workspace/ Contains optimized SOUL.md and USER.md templates for efficient agent identity.
~/.openclaw/token-optimizer-stats.json Tracks usage patterns and cumulative savings over time.

Token Optimizer Advanced Features

  • Multi-Provider Heartbeats: Route status checks to Ollama, LM Studio, or Groq to achieve 100% savings on heartbeat tokens.
  • Config Rollback: Instantly restore previous configuration states if an optimization needs to be reverted via a simple CLI command.
  • Prompt Caching: Enable native caching to reuse prompts at approximately 10% of the standard token cost.
  • Health Check System: A unified command to verify the operational status of all cost-saving measures across your Openclaw Skills environment.

SKILL.md


Loading

Related Openclaw Skills

Featured*