MCPcopy
hub / github.com/BlockRunAI/ClawRouter

github.com/BlockRunAI/ClawRouter @v0.12.216 sqlite

repository ↗ · DeepWiki ↗ · release v0.12.216 ↗
591 symbols 1,729 edges 135 files 143 documented · 24%
README

ClawRouter Banner

The LLM router built for autonomous agents

Agents can't sign up for accounts. Agents can't enter credit cards.

Agents can only sign transactions.

ClawRouter is the only LLM router that lets agents operate independently.

8 models free, no crypto required. No signup. No API key. No credit card.

8 free models  Agent native  No API keys  Local routing  x402 USDC  Open source

npm version npm downloads GitHub stars CI TypeScript License: MIT

USDC Hackathon Winner x402 Protocol Base Network Solana OpenClaw Plugin Telegram

ClawRouter is an open-source smart LLM router that reduces AI API costs by up to 92%. It analyzes each request across 15 dimensions and routes to the cheapest capable model in under 1ms, entirely locally. ClawRouter is the only LLM router built for autonomous AI agents — it uses wallet signatures for authentication (no API keys) and USDC micropayments via the x402 protocol (no credit cards). 55+ models from OpenAI, Anthropic, Google, xAI, DeepSeek, and more. MIT licensed.


Why ClawRouter exists

Every other LLM router was built for human developers — create an account, get an API key, pick a model from a dashboard, pay with a credit card.

Agents can't do any of that.

ClawRouter is built for the agent-first world:

  • Starts at $0 — 8 NVIDIA models are free forever (incl. 675B Mistral Large 3, Qwen3.5 122B + a vision-capable Nemotron Omni)
  • No accounts — a wallet is generated locally, no signup
  • No API keys — your wallet signature IS authentication
  • No model selection — 15-dimension scoring picks the right model automatically
  • No credit cards — agents pay per-request with USDC via x402
  • No trust required — runs locally, <1ms routing, zero external dependencies

This is the stack that lets agents operate autonomously: x402 + USDC + local routing.


How it compares

OpenRouter LiteLLM Martian Portkey ClawRouter
Models 200+ 100+ Smart routing Gateway 55+
Free tier Rate-limited BYO keys No No 8 models, no signup
Routing Manual selection Manual selection Smart (closed) Observability Smart (open source)
Auth Account + API key Your API keys Account + API key Account + API key Wallet signature
Payment Credit card BYO keys Credit card $49-499/mo USDC per-request
Runs locally No Yes No No Yes
Open source No Yes No Partial Yes
Agent-ready No No No No Yes

✓ Open source · ✓ Smart routing · ✓ Runs locally · ✓ Crypto native · ✓ Agent ready

We're the only one that checks all five boxes.


Quick Start

No wallet? 8 models work free out of the box. Install, run, and pin nvidia/gpt-oss-120b (or any of the 8) — no crypto, no signup, no balance required. Add USDC later when you want paid models.

Option A — OpenClaw Agent

OpenClaw is an AI coding agent. If you're using it, ClawRouter installs as a plugin. Two paths:

A1. Recommended — one-shot install script:

curl -fsSL https://blockrun.ai/ClawRouter-update | bash
openclaw gateway restart

This handles everything: registration, models config, auth profile, wallet setup. Smart routing (blockrun/auto) is now your default model.

A2. If you prefer pure npm:

npm install -g @blockrun/clawrouter
clawrouter setup            # finishes OpenClaw integration — REQUIRED
openclaw gateway restart

⚠️ Skipping clawrouter setup will leave you broken. Bare npm install -g only puts the package on disk; it does NOT register the plugin with OpenClaw, sync the models allowlist, or write the auth profile. Symptom: /models in your bot shows only ~7 entries (OpenClaw's hardcoded defaults) instead of the full ~38 BlockRun models. Run clawrouter setup to repair, or use path A1 to begin with.

Option B — Standalone (continue.dev, Cursor, VS Code, any OpenAI-compatible client)

Using Claude Code? Check out BRCC — it's purpose-built for Claude Code with the same smart routing and x402 payments.

Using NousResearch Hermes? See ClawRouter-Hermes — a Python plugin that wires Hermes into the ClawRouter proxy. Same wallet, same 55+ models, same x402 USDC settlement on Base & Solana.

No OpenClaw required. ClawRouter runs as a local proxy on port 8402.

1. Start the proxy

npx @blockrun/clawrouter

2. Fund your wallet — optional, skip for free tier Your wallet address is printed on first run. For paid models, send a few USDC on Base or Solana — $5 covers thousands of requests. To stay at $0, pin any of the 8 free models (e.g. nvidia/gpt-oss-120b) or use /model free inside OpenClaw.

3. Point your client at http://localhost:8402

continue.dev~/.continue/config.yaml

Important: apiBase must end with /v1/ (including the trailing slash). Without it, continue.dev constructs the URL as /chat/completions instead of /v1/chat/completions, and the proxy returns 404.

models:
  - name: ClawRouter Auto
    provider: openai
    model: blockrun/auto
    apiBase: http://localhost:8402/v1/
    apiKey: x402
    roles:
      - chat
      - edit
      - apply

To pin a specific model, replace blockrun/auto with any model from blockrun.ai/models, e.g. anthropic/claude-opus-4.8, xai/grok-4-0709.

Both provider: openai and provider: clawrouter work — just make sure apiBase ends with /v1/.

Legacy JSON format (~/.continue/config.json)

{
  "models": [
    {
      "title": "ClawRouter Auto",
      "provider": "openai",
      "model": "blockrun/auto",
      "apiBase": "http://localhost:8402/v1/",
      "apiKey": "x402"
    }
  ]
}

Cursor — Settings → Models → OpenAI-compatible

Set base URL to http://localhost:8402, API key to x402, model to blockrun/auto.

Any OpenAI SDK

from openai import OpenAI
client = OpenAI(base_url="http://localhost:8402", api_key="x402")
response = client.chat.completions.create(model="blockrun/auto", messages=[...])

Routing Profiles

Choose your routing strategy with /model <profile>:

Profile Strategy Savings Best For
/model free Free NVIDIA models 100% $0 balance, learning
/model auto Balanced (default) 74-100% General use
/model eco Cheapest possible 95-100% Maximum savings
/model premium Best quality 0% Mission-critical

Shortcuts: /model grok, /model br-sonnet, /model gpt5, /model o3


How It Works

100% local routing. <1ms latency. Zero external API calls.

Request → Weighted Scorer (15 dimensions) → Tier → Best Model → Response
Tier ECO Model AUTO Model PREMIUM Model
SIMPLE nvidia/gpt-oss-120b (FREE) gemini-2.5-flash ($0.30/$2.50) kimi-k2.6 ($0.95/$4.00)
MEDIUM gemini-3.1-flash-lite ($0.25/$1.50) kimi-k2.6 ($0.95/$4.00) gpt-5.3-codex ($1.75/$14.00)
COMPLEX gemini-3.1-flash-lite ($0.25/$1.50) gemini-3.1-pro ($2/$12) claude-opus-4.8 ($5/$25)
REASONING grok-4-1-fast-reasoning ($0.20/$0.50) grok-4-1-fast-reasoning ($0.20/$0.50) claude-sonnet-4.6 ($3/$15)

Blended average: $2.05/M vs $25/M for Claude Opus = 92% savings


Image Generation

Generate images directly from chat with /cr-imagegen:

/cr-imagegen a dog dancing on the beach
/cr-imagegen --model dall-e-3 a futuristic city at sunset
/cr-imagegen --model banana-pro --size 2048x2048 mountain landscape

The slash command is /cr-imagegen to avoid colliding with Telegram channel commands. Typing /imagegen in chat still works for backward compatibility.

Model Provider Price Max Size
nano-banana Google Gemini Flash $0.05/image 1024x1024
banana-pro Google Gemini Pro $0.10/image 4096x4096
dall-e-3 OpenAI DALL-E 3 $0.04/image 1792x1024
gpt-image OpenAI GPT Image 1 $0.02/image 1536x1024
flux Black Forest Flux 1.1 $0.04/image 1024x1024
xai/grok-imagine-image xAI Grok Imagine $0.02/image 1024x1024
xai/grok-imagine-image-pro xAI Grok Imagine Pro $0.07/image 1024x1024
zai/cogview-4 Zhipu CogView-4 $0.015/image 1440x1440

Video Generation

Generate short AI videos directly from chat with /videogen:

/videogen a red apple slowly spinning
/videogen --model seedance-2-fast --duration=5 a cat waving
/videogen --model grok-video a neon city at night

Or drive it over HTTP — ClawRouter proxies the BlockRun gateway, handles x402 payment, and downloads the returned MP4 to local disk, rewriting url to http://localhost:8402/videos/<file>.mp4 so the asset survives past the upstream's temporary bucket.

curl -X POST http://localhost:8402/v1/videos/generations \
  -H "Content-Type: application/json" \
  -d '{"model":"bytedance/seedance-2.0-fast","prompt":"a red apple slowly spinning","duration_seconds":5}'
Model Provider 5s text-to-video 5s image-to-video Duration
bytedance/seedance-1.5-pro ByteDance Seedance ~$0.46 ~$0.46 (flat) 5s default, up to 10s
bytedance/seedance-2.0-fast ByteDance Seedance ~$1.19 ~$1.19 (flat) 5s default, up to 10s
bytedance/seedance-2.0 ByteDance Seedance ~$1.49 ~$1.49 (flat) 5s default, up to 10s
azure/sora-2 OpenAI Sora (Azure) ~$0.42 (4s) ~$0.42 (4s, flat) 4s default; 4/8/12s
xai/grok-imagine-video xAI Grok Imagine ~$0.42 (8s) n/a 8s default

Seedance is token-priced upstream at ~20,256 tokens/sec — the blockrun videos route now defaults Seedance to resolution=720p with generate_audio=true for text-to-video (2× the per-second token count of the older 480p baseline; audio is included in that rate). The quote is `durat

Extension points exported contracts — how you extend this code

SpendControlStorage (Interface)
(no doc) [5 implementers]
src/spend-control.ts
RouterStrategy (Interface)
(no doc) [2 implementers]
src/router/types.ts
TestResult (Interface)
(no doc)
test/e2e-tool-id-sanitization.ts
ScanFinding (Interface)
(no doc)
test/integration/security-scanner.test.ts
SystemInfo (Interface)
(no doc)
src/doctor.ts
DerivedKeys (Interface)
(no doc)
src/wallet.ts
JournalEntry (Interface)
(no doc)
src/journal.ts
ResponseEntry (Interface)
(no doc)
src/response-store.ts

Core symbols most depended-on inside this repo

get
called by 168
src/response-cache.ts
set
called by 109
src/response-cache.ts
generateKey
called by 99
src/response-cache.ts
close
called by 92
src/session.ts
assert
called by 74
test/fallback.ts
assertTrue
called by 72
test/test-clawrouter.mjs
startProxy
called by 55
src/proxy.ts
transform
called by 50
src/share-formatters.ts

Shape

Function 437
Method 88
Interface 40
Class 26

Languages

TypeScript99%
Python1%

Modules by API surface

src/proxy.ts52 symbols
src/spend-control.ts35 symbols
src/share-formatters.ts28 symbols
src/index.ts27 symbols
test/test-e2e.ts24 symbols
src/session.ts18 symbols
src/doctor.ts18 symbols
src/cli.ts18 symbols
src/textual-tool-calls.ts14 symbols
src/solana-balance.ts14 symbols
src/web-search-provider.ts13 symbols
src/response-cache.ts13 symbols

Dependencies from manifests, versioned

@eslint/js10.0.1 · 1×
@noble/hashes2.2.0 · 1×
@scure/bip322.0.1 · 1×
@scure/bip391.5.0 · 1×
@solana/kit5.0.0 · 1×
@x402/core2.9.0 · 1×
@x402/evm2.9.0 · 1×
@x402/fetch2.9.0 · 1×
@x402/svm2.9.0 · 1×
eslint10.2.0 · 1×
openclaw2026.5.4 · 1×
prettier3.8.1 · 1×

For agents

$ claude mcp add ClawRouter \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact