TokenBroker for Openclaw

TokenBroker is a unified AI API gateway that provides smart routing, budget control, and cost auditing for local LLM API calls.

wenrl2006
v0.1.0
May 22, 2026
0
627
0

Install & Download

1. ClawHub CLI

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

npx clawhub@latest install ai-token-broker

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 ai-token-broker 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 TokenBroker?

TokenBroker is an advanced, unified AI API gateway built to streamline how your local agents interact with various LLM providers. As one of the premier Openclaw Skills, it acts as an intelligent proxy that sits between your applications and your AI endpoints. It dynamically resolves routing rules to ensure that requests are sent to the most budget-appropriate and performance-fitting models.

By managing connections centrally, TokenBroker avoids redundant billing, optimizes token usage, and automatically switches fallback pipelines based on real-time budget status. The system is designed to seamlessly integrate with local budgeting frameworks to enforce monthly caps, making it an essential component for high-throughput AI environments.

TokenBroker Use Cases

  • Enforcing LLM Cost Limits: Prevent infinite loops or bloated agent tasks from running up expensive API bills by enforcing hard daily and monthly budget limits.
  • Dynamic Model Allocation: Automatically route simple, routine conversations to free models while reserving premium deep-reasoning models for code generation and intricate math analysis.
  • Centralized API Auditing: Gain real-time visibility into developer or agent expenditures with centralized cost logs and simple conversational query tools.
  • Graceful Budget Degradation: Automatically fall back to free or lower-tier models instead of crashing the application when API budget caps are reached.

How TokenBroker Works

  1. Interception: An agent initiates an LLM request, which is intercepted by the local TokenBroker gateway service.
  2. Budget Evaluation: TokenBroker queries the connected budgeting module to check if the current usage remains within the daily/monthly safe thresholds.
  3. Optimal Model Routing: Based on the task complexity classification, the gateway matches the query against current provider cost structures to select the most economical, capable engine.
  4. API Forwarding: The request is routed to the selected LLM provider (e.g., DeepSeek V3 Lite, DeepSeek V4 Fast, or DeepSeek V4 Thinking).
  5. Audit Logging: The gateway logs usage metrics, token metrics, and API costs before returning the output to the agent.

TokenBroker Setup

Prerequisites

TokenBroker depends on its backend service running on port 8766. It typically starts automatically upon installation. If you need to manually launch or restart the service, navigate to the system directory and run the server:

cd ~/.openclaw/workspace/production-system/token-broker
npx ts-node src/server.ts

Installation

Deploy this skill directly via your command line interface:

# Install via ClawHub
clawhub install ai-token-broker

# Or install via OpenClaw command line
openclaw skills install ai-token-broker

Following installation, the system automatically compiles TypeScript builds, validates port configuration, launches the background engine, and registers it as a daemon managed by Supervisor.

TokenBroker Data Schema & Taxonomy

Routing Strategy Rules

TokenBroker maps specific execution types to optimized API targets:

Task Type Target Model Routing Rule Description
Daily Q&A DeepSeek V3 Lite Automatically routed to the free tier to minimize operational costs.
Analysis & Writing DeepSeek V4 Fast Dispatched to mid-tier models optimized for rapid and low-cost execution.
Coding & Reasoning DeepSeek V4 Thinking Routed to high-reasoning, premium models for mission-critical logic.
Budget Exhaustion Free Tier Fallback Automatically downgrades the provider to free options to maintain uptime.

Interactive Command Set

Manage the gateway using conversational query structures within your interface:

Command Pattern Expected System Response
Broker status or Gateway status Verifies and prints the current API gateway connection status.
Route stats or API stats Displays a detailed report of routed LLM calls and associated latency.
Set route [Task] [Provider] Updates or overrides active routing rules in the configuration store.
How much spent today Prints an aggregated summary of the actual budget consumed today.
Broker help Displays the listing of all available management commands.

TokenBroker Advanced Features

  • TokenBudget Synergy: Integrates out-of-the-box with budget frameworks to display active savings meters and live consumption metrics inside the agent terminal.
  • Fail-Safe Health Monitor: Dynamically queries the health endpoint http://localhost:8766/api/health. If offline, it downgrades automatically to direct API connections so operations remain uninterrupted.
  • Multi-Tenant Exclusion Rules: Supports defining exclusions for automated processes, such as cron jobs or diagnostic routines, keeping them separate from standard budget tracking sheets.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*