Token Router for Openclaw

A smart LLM routing and token cost optimization engine that dynamically matches task complexity to the most cost-effective model tier.

qomob
v1.0.0
Jun 3, 2026
0
556
0

Install & Download

1. ClawHub CLI

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

npx clawhub@latest install token-router

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-router 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 Router?

Token Router is an automated decision-making engine designed to optimize Large Language Model (LLM) selection and API token consumption across multi-agent workflows. Since flagship models can cost over 100 times more than lightweight alternatives, routing simple operations to cheaper models is paramount. This skill acts as an intelligent router, analyzing task parameters to maintain maximum quality while cutting operational expenses by 70% to 90%.

By leveraging structured complexity profiling, user preference tracking, and fallback safety protocols, Token Router integrates smoothly with modern development environments, agents, and CLIs. Developers can harness these capabilities to create highly efficient, budget-conscious AI implementations, making it one of the most powerful utilities available in the Openclaw Skills ecosystem.

Token Router Use Cases

  • Cost Optimization Requests: When you need to reduce API bills, analyze token consumption, or find more budget-friendly LLM options.
  • Agentic Multi-Step Workflows: For complex pipelines (like Hermes Agent or Openclaw Skills configurations) where 80% of glue-tasks can run on cheap models while keeping flagship models for critical steps.
  • Model Selection & Tier Mapping: Unsure whether to use Claude Haiku, Gemini Flash, or Claude Sonnet for a specific task.
  • Cascade & Fallback Routing Setup: Designing resilient systems that start with fast, cheap models and escalate to reasoning models only when validation fails.

How Token Router Works

  1. Task Complexity Assessment: The router scores the incoming task on a scale of 1 to 5 across four key dimensions: Reasoning Depth, Output Length, Precision Requirements, and Context Dependency (Total score: 4 to 20).
  2. Model Tier Mapping: The aggregated score assigns the task to one of four optimized tiers: L0 (Router/Flash), L1 (Execution/Haiku), L2 (Reasoning/Sonnet), or L3 (Creative/Opus).
  3. Safety Evaluation: Before executing, the router applies hard rules to upgrade crucial tasks. Tasks involving financial transactions, legal/compliance questions, production deployments, or security audits are automatically upgraded to L2 or L3.
  4. Dynamic Personalization: The router progressively builds a user profile based on natural conversation, adapting to preferences like cost-first, quality-first, or custom tier overrides without annoying questionnaires.

Token Router Setup

Integrating Token Router into your multi-agent architecture or local environment is highly customizable. Depending on your choice of platform within Openclaw Skills, refer to the following setup guidelines:

OpenClaw Integration

Configure your model providers and routing cascading in your local config.yaml:

# config.yaml snippet
models:
  providers:
    openai: "openai/gpt-4o-mini"
    anthropic: "anthropic/claude-3-5-sonnet"
  routing:
    strategy: balanced
    fallback_enabled: true

CLI-based Platforms

For CLI tools like Claude Code or Codex, you can execute switches directly via command-line arguments:

# Switch to lightweight execution models
claude model claude-3-5-haiku

# Run a specific command with cost-optimization overrides
claude "Analyze code performance" --model claude-3-5-sonnet

Token Router Data Schema & Taxonomy

The Token Router stores user preferences and behavioral context within the agent's memory or session state to personalize future routing decisions. The taxonomy of the data structure is as follows:

Attribute Name Data Type Description Allowed Values
strategy String Core optimization directive. cost_first, quality_first, balanced, custom
budget_usd Float Optional monthly budget cap tracker. Any positive decimal
tier_overrides Map/Object Manual model selections designated by user. e.g., translation: L2
upgrade_history Array List of instances where the user requested higher quality. Array of strings/records

Core Schema Example

{
  "token_router_profile": {
    "strategy": "balanced",
    "budget_usd": null,
    "tier_overrides": {},
    "upgrade_history": []
  }
}

Token Router Advanced Features

  • Multi-Platform Native Support: Optimized configurations ready for Trae IDE, Claude Code, OpenClaw, and Hermes Agent architectures.
  • Progressive Profiling: Learns your balance of cost versus quality naturally through standard conversation and keeps profiles updated in persistent Memory.
  • Cascade & Hybrid Routing: Supports advanced flow architectures, such as attempting L0 processing first and cascading on validation failure, or running modular multi-agent pipelines with hybrid configurations.
  • Passive Cost Tracking: Compiles detailed token cost savings reports dynamically without interrupting active developer workflows.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*