@blockrun/clawrouter 0.12.266 β 0.12.268
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +147 -21
- package/dist/cli.js +670 -157
- package/dist/index.d.ts +58 -11
- package/dist/index.js +332 -90
- package/docs/configuration.md +102 -9
- package/openclaw.plugin.json +9 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -7,13 +7,15 @@
|
|
|
7
7
|
<p>Agents can't sign up for accounts. Agents can't enter credit cards.<br>
|
|
8
8
|
Agents can only sign transactions.<br><br>
|
|
9
9
|
<strong>ClawRouter is the only LLM router that lets agents operate independently.</strong><br><br>
|
|
10
|
-
<em
|
|
10
|
+
<em>Pay however you like: <strong>credit card</strong> (API key, via <a href="https://user.blockrun.ai">user.blockrun.ai</a>)<br>
|
|
11
|
+
or <strong>USDC</strong> on Base or Solana (x402 wallet, no account at all).<br>
|
|
12
|
+
Or neither β <!-- br:models.free -->7<!-- /br:models.free --> models are free, with no signup, no key and no wallet.</em></p>
|
|
11
13
|
|
|
12
14
|
<br>
|
|
13
15
|
|
|
14
16
|
<img src="https://img.shields.io/badge/π_7_Free_Models-success?style=for-the-badge" alt="7 free models">
|
|
15
17
|
<img src="https://img.shields.io/badge/π€_Agent--Native-black?style=for-the-badge" alt="Agent native">
|
|
16
|
-
<img src="https://img.shields.io/badge
|
|
18
|
+
<img src="https://img.shields.io/badge/π³_Card_or_USDC-blue?style=for-the-badge" alt="Card or USDC">
|
|
17
19
|
<img src="https://img.shields.io/badge/β‘_Local_Routing-yellow?style=for-the-badge" alt="Local routing">
|
|
18
20
|
<img src="https://img.shields.io/badge/π°_x402_USDC-purple?style=for-the-badge" alt="x402 USDC">
|
|
19
21
|
<img src="https://img.shields.io/badge/π_Open_Source-green?style=for-the-badge" alt="Open source">
|
|
@@ -34,7 +36,7 @@ Agents can only sign transactions.<br><br>
|
|
|
34
36
|
|
|
35
37
|
</div>
|
|
36
38
|
|
|
37
|
-
> **ClawRouter** is an open-source smart LLM router that reduces AI API costs by up to <!-- br:savings.autoVsBaselinePct -->84<!-- /br:savings.autoVsBaselinePct -->%. It analyzes each request across <!-- br:clawrouter.dimensions -->15<!-- /br:clawrouter.dimensions --> dimensions and routes to the cheapest capable model in under 1ms, entirely locally.
|
|
39
|
+
> **ClawRouter** is an open-source smart LLM router that reduces AI API costs by up to <!-- br:savings.autoVsBaselinePct -->84<!-- /br:savings.autoVsBaselinePct -->%. It analyzes each request across <!-- br:clawrouter.dimensions -->15<!-- /br:clawrouter.dimensions --> dimensions and routes to the cheapest capable model in under 1ms, entirely locally. It is the only LLM router that an autonomous agent can pay for by itself β a wallet signature is the account, and USDC micropayments over the x402 protocol are the billing β and it takes an ordinary credit card too: sign up at [user.blockrun.ai](https://user.blockrun.ai), top up, and run the same router on an API key. <!-- br:models.chatVisible -->76<!-- /br:models.chatVisible --> models from OpenAI, Anthropic, Google, xAI, DeepSeek, and more. MIT licensed.
|
|
38
40
|
|
|
39
41
|
---
|
|
40
42
|
|
|
@@ -47,14 +49,26 @@ Every other LLM router was built for **human developers** β create an account,
|
|
|
47
49
|
ClawRouter is built for the agent-first world:
|
|
48
50
|
|
|
49
51
|
- **Starts at $0** β <!-- br:models.free -->7<!-- /br:models.free --> open-weight models are free forever (incl. a 1M-context reasoner and two sub-second coders). Image turns route to paid models β see the free-tier note below.
|
|
50
|
-
- **No accounts** β a wallet is generated locally, no signup
|
|
51
|
-
- **No API keys** β your wallet signature IS authentication
|
|
52
|
+
- **No accounts needed** β a wallet is generated locally, no signup
|
|
53
|
+
- **No API keys needed** β your wallet signature IS authentication
|
|
52
54
|
- **No model selection** β <!-- br:clawrouter.dimensions -->15<!-- /br:clawrouter.dimensions -->-dimension scoring + constraint-first ranking ([router-core](https://github.com/BlockRunAI/router-core)) picks the right model automatically
|
|
53
|
-
- **No credit
|
|
55
|
+
- **No credit card needed** β agents pay per-request with USDC via [x402](https://x402.org)
|
|
54
56
|
- **No trust required** β runs locally, <1ms routing, zero external dependencies
|
|
55
57
|
|
|
56
58
|
This is the stack that lets agents operate autonomously: **x402 + USDC + local routing**.
|
|
57
59
|
|
|
60
|
+
### β¦and if you are a human, not an agent
|
|
61
|
+
|
|
62
|
+
Every "no X needed" above is a capability, not a restriction. **ClawRouter takes a credit card too.** Sign up at **[user.blockrun.ai](https://user.blockrun.ai)**, top up, mint an API key, and run `clawrouter login brk_live_β¦`. Same router, same <!-- br:models.chatVisible -->76<!-- /br:models.chatVisible --> models, same local routing β calls go to `api.blockrun.ai` on a bearer token and bill your account credit. No crypto, no gas, no seed phrase.
|
|
63
|
+
|
|
64
|
+
| You are | Pay with | Setup |
|
|
65
|
+
| ------------------- | --------------------------------------- | ---------------------------------------------------------------------------- |
|
|
66
|
+
| Just trying it | Nothing | Install and pin a free model |
|
|
67
|
+
| A person | **Credit card** β account credit | [user.blockrun.ai](https://user.blockrun.ai) β `clawrouter login brk_live_β¦` |
|
|
68
|
+
| An autonomous agent | **USDC** on Base or Solana, per request | Nothing β a wallet is generated on first run |
|
|
69
|
+
|
|
70
|
+
Full walkthrough: [Paying with a credit card](#paying-with-a-credit-card-api-key).
|
|
71
|
+
|
|
58
72
|
---
|
|
59
73
|
|
|
60
74
|
## How it compares
|
|
@@ -64,8 +78,8 @@ This is the stack that lets agents operate autonomously: **x402 + USDC + local r
|
|
|
64
78
|
| **Models** | 200+ | 100+ | Smart routing | Gateway | **<!-- br:models.chatVisible -->76<!-- /br:models.chatVisible -->** |
|
|
65
79
|
| **Free tier** | Rate-limited | BYO keys | No | No | **<!-- br:models.free -->7<!-- /br:models.free --> models, no signup** |
|
|
66
80
|
| **Routing** | Manual selection | Manual selection | Smart (closed) | Observability | **Smart (open source)** |
|
|
67
|
-
| **Auth** | Account + API key | Your API keys | Account + API key | Account + API key | **Wallet signature**
|
|
68
|
-
| **Payment** | Credit card | BYO keys | Credit card | $49-499/mo | **USDC per-request**
|
|
81
|
+
| **Auth** | Account + API key | Your API keys | Account + API key | Account + API key | **Wallet signature _or_ API key** |
|
|
82
|
+
| **Payment** | Credit card | BYO keys | Credit card | $49-499/mo | **USDC per-request _or_ card credit** |
|
|
69
83
|
| **Runs locally** | No | Yes | No | No | **Yes** |
|
|
70
84
|
| **Open source** | No | Yes | No | Partial | **Yes** |
|
|
71
85
|
| **Agent-ready** | No | No | No | No | **Yes** |
|
|
@@ -78,7 +92,20 @@ This is the stack that lets agents operate autonomously: **x402 + USDC + local r
|
|
|
78
92
|
|
|
79
93
|
## Quick Start
|
|
80
94
|
|
|
81
|
-
> **No wallet? <!-- br:models.free -->7<!-- /br:models.free --> models work free out of the box.** Install, run, and pin `free/nemotron-3.5-lightning` (or any of the <!-- br:models.free -->7<!-- /br:models.free -->) β no crypto, no signup, no balance required. Add USDC later when you want paid models.
|
|
95
|
+
> **No wallet? <!-- br:models.free -->7<!-- /br:models.free --> models work free out of the box.** Install, run, and pin `free/nemotron-3.5-lightning` (or any of the <!-- br:models.free -->7<!-- /br:models.free -->) β no crypto, no signup, no balance required. Add a credit card or USDC later when you want paid models.
|
|
96
|
+
|
|
97
|
+
**Two ways to pay for the paid ones β pick one, the rest of ClawRouter is identical:**
|
|
98
|
+
|
|
99
|
+
| | Wallet (default) | API key |
|
|
100
|
+
| ----------------- | ------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
|
|
101
|
+
| **Who it is for** | Autonomous agents, and anyone happy holding USDC | People who would rather pay with a card |
|
|
102
|
+
| **Setup** | Nothing β a wallet is generated on first run | Sign up at [user.blockrun.ai](https://user.blockrun.ai), top up, mint a key, `clawrouter login brk_live_β¦` |
|
|
103
|
+
| **Auth** | An x402 signature per request | `Authorization: Bearer brk_live_β¦` |
|
|
104
|
+
| **Gateway** | `blockrun.ai` (Base) / `sol.blockrun.ai` (Solana) | `api.blockrun.ai` |
|
|
105
|
+
| **Billing** | USDC leaves your wallet per call, non-custodial | Card-funded account credit, drawn down at exact usage |
|
|
106
|
+
|
|
107
|
+
ClawRouter prefers the API key whenever one is configured, so `clawrouter login`
|
|
108
|
+
is all it takes to switch and `clawrouter logout` is all it takes to switch back.
|
|
82
109
|
|
|
83
110
|
### Desktop control plane (macOS)
|
|
84
111
|
|
|
@@ -522,7 +549,10 @@ No Surf account, no API key β settles directly to Surf's Base treasury in USDC
|
|
|
522
549
|
|
|
523
550
|
## Payment
|
|
524
551
|
|
|
525
|
-
|
|
552
|
+
Two rails. This section covers the wallet one; the card/API-key one is
|
|
553
|
+
[below](#paying-with-a-credit-card-api-key).
|
|
554
|
+
|
|
555
|
+
Here, no account and no API key are needed at all β **payment IS authentication**, via [x402](https://x402.org).
|
|
526
556
|
|
|
527
557
|
```
|
|
528
558
|
Request β 402 (price: $0.003) β wallet signs USDC β retry β response
|
|
@@ -551,7 +581,93 @@ USDC stays in your wallet until spent β non-custodial. Price is visible in the
|
|
|
551
581
|
- **Base (EVM):** Send USDC on Base to your EVM address
|
|
552
582
|
- **Solana:** Send USDC on Solana to your Solana address
|
|
553
583
|
- **Coinbase/CEX:** Withdraw USDC to either network
|
|
554
|
-
- **Credit card:**
|
|
584
|
+
- **Credit card:** don't fund a wallet at all β use an API key instead (below)
|
|
585
|
+
|
|
586
|
+
---
|
|
587
|
+
|
|
588
|
+
## Paying with a credit card (API key)
|
|
589
|
+
|
|
590
|
+
Wallets are what let an _agent_ pay for itself. If you are a person and would
|
|
591
|
+
rather pay the way you pay for everything else, BlockRun issues API keys backed
|
|
592
|
+
by card-funded credit β and ClawRouter speaks that too.
|
|
593
|
+
|
|
594
|
+
**1. Sign up and get a key**
|
|
595
|
+
|
|
596
|
+
Go to **[user.blockrun.ai](https://user.blockrun.ai)**:
|
|
597
|
+
|
|
598
|
+
1. Sign in.
|
|
599
|
+
2. **Credits** β top up with a credit card. The processing fee is charged at
|
|
600
|
+
purchase, not on inference: you pay it once on the top-up and every model
|
|
601
|
+
then bills at the published list price, with **no per-call minimum and no
|
|
602
|
+
per-call fee**.
|
|
603
|
+
3. **API Keys** β create a key. It is shown once and looks like
|
|
604
|
+
`brk_live_β¦` β copy it before you leave the page.
|
|
605
|
+
|
|
606
|
+
**2. Tell ClawRouter about it**
|
|
607
|
+
|
|
608
|
+
```bash
|
|
609
|
+
clawrouter login brk_live_... # stores it in ~/.blockrun/.api-key (chmod 600)
|
|
610
|
+
clawrouter login # or run bare and paste at the prompt
|
|
611
|
+
```
|
|
612
|
+
|
|
613
|
+
Or, for CI and containers where you would rather not write a file:
|
|
614
|
+
|
|
615
|
+
```bash
|
|
616
|
+
export BLOCKRUN_API_KEY=brk_live_...
|
|
617
|
+
```
|
|
618
|
+
|
|
619
|
+
Either way, restart the proxy. That is the whole change β routing, model names,
|
|
620
|
+
the free tier, `/model auto`, exclusions and the OpenAI-compatible surface all
|
|
621
|
+
behave exactly as before:
|
|
622
|
+
|
|
623
|
+
```bash
|
|
624
|
+
npx @blockrun/clawrouter
|
|
625
|
+
# [ClawRouter] Using BlockRun API key brk_live_Ab3xQ9β¦f8c1 (from ~/.blockrun/.api-key)
|
|
626
|
+
# [ClawRouter] Billing: account credit β top up at https://user.blockrun.ai/dashboard/credits
|
|
627
|
+
```
|
|
628
|
+
|
|
629
|
+
**3. Check it, and switch back whenever**
|
|
630
|
+
|
|
631
|
+
```bash
|
|
632
|
+
clawrouter status # names the mode, the gateway, and the masked key
|
|
633
|
+
clawrouter doctor # verifies the key against the gateway (401 = revoked or mistyped)
|
|
634
|
+
clawrouter logout # delete the key and go back to paying from the wallet
|
|
635
|
+
```
|
|
636
|
+
|
|
637
|
+
**Using it directly, without ClawRouter.** The same key works against
|
|
638
|
+
`api.blockrun.ai` from any OpenAI or Anthropic SDK β `Authorization: Bearer` for
|
|
639
|
+
OpenAI clients, `x-api-key` for Anthropic ones:
|
|
640
|
+
|
|
641
|
+
```bash
|
|
642
|
+
curl https://api.blockrun.ai/v1/chat/completions \
|
|
643
|
+
-H "Authorization: Bearer brk_live_..." \
|
|
644
|
+
-H "Content-Type: application/json" \
|
|
645
|
+
-d '{"model": "anthropic/claude-sonnet-5", "messages": [{"role": "user", "content": "hello"}]}'
|
|
646
|
+
```
|
|
647
|
+
|
|
648
|
+
Running it through ClawRouter is what adds the smart routing, the fallback
|
|
649
|
+
chains, the response cache and the local spend controls.
|
|
650
|
+
|
|
651
|
+
**What to know**
|
|
652
|
+
|
|
653
|
+
- **The key wins.** If a wallet and a key are both present, ClawRouter uses the
|
|
654
|
+
key. A machine with both means "bill my account", not "keep spending my USDC".
|
|
655
|
+
`clawrouter logout` (and unsetting `BLOCKRUN_API_KEY`) reverses it.
|
|
656
|
+
- **No wallet is created.** In API-key mode ClawRouter never generates, reads or
|
|
657
|
+
signs with a private key β `clawrouter doctor` will not mint one either.
|
|
658
|
+
- **Balance lives server-side.** There is no local balance to check: a call that
|
|
659
|
+
outruns your credit comes back as HTTP `402 insufficient_quota`, naming the
|
|
660
|
+
top-up page. Free models stay free and need no credit at all.
|
|
661
|
+
- **Chat today, media next.** `api.blockrun.ai` currently serves the chat and
|
|
662
|
+
text-completion endpoints (`/v1/chat/completions`, `/v1/messages`, `/v1/models`).
|
|
663
|
+
Image, video, audio and the partner APIs are still wallet-only; ClawRouter says
|
|
664
|
+
so explicitly instead of returning a bare 404, and they light up on the API-key
|
|
665
|
+
path as BlockRun publishes them β no ClawRouter release needed.
|
|
666
|
+
- **`maxCostPerRun` and `/exclude` still apply**, along with the router's own
|
|
667
|
+
budget filter β they live in the router, not the signer. **`clawrouter policy`
|
|
668
|
+
limits do not**: they are enforced in the x402 pre-sign hook, and nothing is
|
|
669
|
+
signed here. Your account balance is the cap instead, and ClawRouter warns at
|
|
670
|
+
startup if you have one of those limits configured.
|
|
555
671
|
|
|
556
672
|
---
|
|
557
673
|
|
|
@@ -576,13 +692,14 @@ USDC stays in your wallet until spent β non-custodial. Price is visible in the
|
|
|
576
692
|
|
|
577
693
|
For basic usage, no configuration needed. For advanced options:
|
|
578
694
|
|
|
579
|
-
| Variable | Default | Description
|
|
580
|
-
| --------------------------- | ------------------------------------- |
|
|
581
|
-
| `
|
|
582
|
-
| `
|
|
583
|
-
| `
|
|
584
|
-
| `
|
|
585
|
-
| `
|
|
695
|
+
| Variable | Default | Description |
|
|
696
|
+
| --------------------------- | ------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
|
|
697
|
+
| `BLOCKRUN_API_KEY` | unset | BlockRun API key (`brk_live_β¦`). Set it and ClawRouter pays from account credit via `api.blockrun.ai` instead of the wallet |
|
|
698
|
+
| `BLOCKRUN_WALLET_KEY` | auto-generated | Your wallet private key |
|
|
699
|
+
| `BLOCKRUN_PROXY_PORT` | `8402` | Local proxy port |
|
|
700
|
+
| `CLAWROUTER_DISABLED` | `false` | Disable smart routing |
|
|
701
|
+
| `CLAWROUTER_DEBUG_HEADERS` | `on` | Set to `off` to suppress `x-clawrouter-*` debug response headers |
|
|
702
|
+
| `CLAWROUTER_SOLANA_RPC_URL` | `https://api.mainnet-beta.solana.com` | Solana RPC endpoint |
|
|
586
703
|
|
|
587
704
|
**Full reference:** [docs/configuration.md](docs/configuration.md)
|
|
588
705
|
|
|
@@ -685,7 +802,7 @@ npm test
|
|
|
685
802
|
|
|
686
803
|
**The LLM router built for autonomous agents**
|
|
687
804
|
|
|
688
|
-
You're here. <!-- br:models.chatVisible -->76<!-- /br:models.chatVisible --> models, local smart routing, x402 USDC
|
|
805
|
+
You're here. <!-- br:models.chatVisible -->76<!-- /br:models.chatVisible --> models, local smart routing, and two ways to pay β a credit-card-funded API key, or x402 USDC from a wallet, which is what lets an agent operate independently.
|
|
689
806
|
|
|
690
807
|
`curl -fsSL https://blockrun.ai/ClawRouter-update | bash`
|
|
691
808
|
|
|
@@ -761,16 +878,25 @@ On the `auto` profile ClawRouter costs <!-- br:savings.autoVsBaselinePct -->84<!
|
|
|
761
878
|
|
|
762
879
|
### How does ClawRouter compare to OpenRouter?
|
|
763
880
|
|
|
764
|
-
ClawRouter is open source and runs locally. It
|
|
881
|
+
ClawRouter is open source and runs locally. It supports wallet-based authentication with USDC per-request payments β which OpenRouter cannot do, and which is what lets an agent pay for itself with no account at all β _and_ the ordinary path of an API key funded by credit card at [user.blockrun.ai](https://user.blockrun.ai). OpenRouter only offers the second. ClawRouter also features smart routing β it automatically picks the best model for each request, while OpenRouter requires manual model selection.
|
|
765
882
|
|
|
766
883
|
### How does ClawRouter compare to LiteLLM?
|
|
767
884
|
|
|
768
|
-
Both are open source and run locally. But ClawRouter adds smart routing (automatic model selection)
|
|
885
|
+
Both are open source and run locally. But ClawRouter adds smart routing (automatic model selection) and its own billing β a credit-card-funded API key, or a wallet paying USDC per request. LiteLLM has no billing of its own: you bring your own provider API keys and manually choose models.
|
|
769
886
|
|
|
770
887
|
### What agents does ClawRouter work with?
|
|
771
888
|
|
|
772
889
|
ClawRouter works with any tool that makes OpenAI-compatible API calls β point it at `http://localhost:8402`. This includes continue.dev, Cursor, VS Code extensions, ElizaOS, and custom agents. It also integrates as a plugin with [OpenClaw](https://openclaw.ai) (an AI coding agent), which enables additional features like slash commands and usage reports.
|
|
773
890
|
|
|
891
|
+
### Do I need a crypto wallet to use ClawRouter?
|
|
892
|
+
|
|
893
|
+
No. A wallet is the default because it is what lets an _agent_ pay for itself,
|
|
894
|
+
but you can sign up at **[user.blockrun.ai](https://user.blockrun.ai)**, top up
|
|
895
|
+
with a credit card, mint an API key and run `clawrouter login brk_live_β¦`. Calls
|
|
896
|
+
then go to `api.blockrun.ai` on a bearer token and bill your account credit β no
|
|
897
|
+
crypto, no gas, no seed phrase. And the <!-- br:models.free -->7<!-- /br:models.free --> free models need neither: no
|
|
898
|
+
wallet, no key, no signup. See [Paying with a credit card](#paying-with-a-credit-card-api-key).
|
|
899
|
+
|
|
774
900
|
### Is ClawRouter free?
|
|
775
901
|
|
|
776
902
|
ClawRouter itself is free and MIT licensed. You pay only for the LLM API calls routed through it β and several open-weight models (`nemotron-3.5-lightning`, `nemotron-3-nano-30b`, `laguna-xs-2.1`, `north-mini-code`, `nemotron-3-nano-omni-30b-a3b-reasoning`, `nemotron-3-ultra-550b`, `llama-3.2-11b-vision`) are completely free (text only). Use `/model free` to smart-route across them, or pick any by name.
|