@blockrun/clawrouter 0.12.68 → 0.12.70
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 +6 -0
- package/dist/cli.js +90 -16
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +9 -0
- package/dist/index.js +106 -19
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/scripts/reinstall.sh +2 -2
- package/scripts/update.sh +2 -2
package/README.md
CHANGED
|
@@ -434,21 +434,27 @@ The first X analytics an agent can call. One function call = one intelligence re
|
|
|
434
434
|
## Frequently Asked Questions
|
|
435
435
|
|
|
436
436
|
### What is ClawRouter?
|
|
437
|
+
|
|
437
438
|
ClawRouter is an open-source (MIT licensed) smart LLM router built for autonomous AI agents. It analyzes each request across 15 dimensions and routes to the cheapest capable model in under 1ms, entirely locally — no external API calls needed for routing decisions.
|
|
438
439
|
|
|
439
440
|
### How much can ClawRouter save on LLM costs?
|
|
441
|
+
|
|
440
442
|
ClawRouter's blended average cost is $2.05 per million tokens compared to $25/M for Claude Opus, representing 92% savings. Actual savings depend on your workload — simple queries are routed to budget models (as low as $0/request with NVIDIA free tier), while complex tasks get premium models.
|
|
441
443
|
|
|
442
444
|
### How does ClawRouter compare to OpenRouter?
|
|
445
|
+
|
|
443
446
|
ClawRouter is open source and runs locally. It uses wallet-based authentication (no API keys) and USDC per-request payments (no credit cards or subscriptions). OpenRouter requires an account, API key, and credit card. ClawRouter also features smart routing — it automatically picks the best model for each request, while OpenRouter requires manual model selection.
|
|
444
447
|
|
|
445
448
|
### How does ClawRouter compare to LiteLLM?
|
|
449
|
+
|
|
446
450
|
Both are open source and run locally. But ClawRouter adds smart routing (automatic model selection), wallet-based auth, and USDC payments. LiteLLM requires you to bring your own API keys and manually choose models.
|
|
447
451
|
|
|
448
452
|
### What agents does ClawRouter work with?
|
|
453
|
+
|
|
449
454
|
ClawRouter integrates with OpenClaw (Claude Code), ElizaOS, and any agent that makes OpenAI-compatible API calls. It runs as a local proxy on port 8402.
|
|
450
455
|
|
|
451
456
|
### Is ClawRouter free?
|
|
457
|
+
|
|
452
458
|
ClawRouter itself is free and MIT licensed. You pay only for the LLM API calls routed through it — and NVIDIA GPT-OSS models are completely free, so you can even use it at zero cost.
|
|
453
459
|
|
|
454
460
|
---
|
package/dist/cli.js
CHANGED
|
@@ -24423,6 +24423,23 @@ var init_solana_balance = __esm({
|
|
|
24423
24423
|
getWalletAddress() {
|
|
24424
24424
|
return this.walletAddress;
|
|
24425
24425
|
}
|
|
24426
|
+
/**
|
|
24427
|
+
* Check native SOL balance (in lamports). Useful for detecting users who
|
|
24428
|
+
* funded with SOL instead of USDC.
|
|
24429
|
+
*/
|
|
24430
|
+
async checkSolBalance() {
|
|
24431
|
+
const controller = new AbortController();
|
|
24432
|
+
const timer = setTimeout(() => controller.abort(), BALANCE_TIMEOUT_MS);
|
|
24433
|
+
try {
|
|
24434
|
+
const owner = address(this.walletAddress);
|
|
24435
|
+
const response = await this.rpc.getBalance(owner).send({ abortSignal: controller.signal });
|
|
24436
|
+
return BigInt(response.value);
|
|
24437
|
+
} catch {
|
|
24438
|
+
return 0n;
|
|
24439
|
+
} finally {
|
|
24440
|
+
clearTimeout(timer);
|
|
24441
|
+
}
|
|
24442
|
+
}
|
|
24426
24443
|
async fetchBalance() {
|
|
24427
24444
|
const owner = address(this.walletAddress);
|
|
24428
24445
|
const mint = address(SOLANA_USDC_MINT);
|
|
@@ -40189,8 +40206,12 @@ var DEFAULT_ROUTING_CONFIG = {
|
|
|
40189
40206
|
// 1,431ms, IQ 32, 41% retention
|
|
40190
40207
|
"moonshot/kimi-k2.5",
|
|
40191
40208
|
// 1,646ms, IQ 47, strong quality
|
|
40209
|
+
"google/gemini-3.1-flash-lite",
|
|
40210
|
+
// $0.25/$1.50, 1M context — newest flash-lite
|
|
40192
40211
|
"google/gemini-2.5-flash-lite",
|
|
40193
|
-
// 1,353ms,
|
|
40212
|
+
// 1,353ms, $0.10/$0.40
|
|
40213
|
+
"openai/gpt-5.4-nano",
|
|
40214
|
+
// $0.20/$1.25, 1M context
|
|
40194
40215
|
"xai/grok-4-fast-non-reasoning",
|
|
40195
40216
|
// 1,143ms, $0.20/$0.50 — fast fallback
|
|
40196
40217
|
"nvidia/gpt-oss-120b"
|
|
@@ -40207,8 +40228,10 @@ var DEFAULT_ROUTING_CONFIG = {
|
|
|
40207
40228
|
// 1,431ms, IQ 32, 41% retention
|
|
40208
40229
|
"google/gemini-2.5-flash",
|
|
40209
40230
|
// 1,238ms, 60% retention
|
|
40231
|
+
"google/gemini-3.1-flash-lite",
|
|
40232
|
+
// $0.25/$1.50, 1M context
|
|
40210
40233
|
"google/gemini-2.5-flash-lite",
|
|
40211
|
-
// 1,353ms,
|
|
40234
|
+
// 1,353ms, $0.10/$0.40
|
|
40212
40235
|
"xai/grok-4-1-fast-non-reasoning",
|
|
40213
40236
|
// 1,244ms, fast fallback
|
|
40214
40237
|
"xai/grok-3-mini"
|
|
@@ -40258,28 +40281,38 @@ var DEFAULT_ROUTING_CONFIG = {
|
|
|
40258
40281
|
primary: "nvidia/gpt-oss-120b",
|
|
40259
40282
|
// 1,252ms, FREE! $0.00/$0.00
|
|
40260
40283
|
fallback: [
|
|
40284
|
+
"google/gemini-3.1-flash-lite",
|
|
40285
|
+
// $0.25/$1.50 — newest flash-lite
|
|
40286
|
+
"openai/gpt-5.4-nano",
|
|
40287
|
+
// $0.20/$1.25 — fast nano
|
|
40261
40288
|
"google/gemini-2.5-flash-lite",
|
|
40262
40289
|
// 1,353ms, $0.10/$0.40
|
|
40263
|
-
"xai/grok-4-fast-non-reasoning"
|
|
40290
|
+
"xai/grok-4-fast-non-reasoning"
|
|
40264
40291
|
// 1,143ms, $0.20/$0.50
|
|
40265
|
-
"google/gemini-2.5-flash"
|
|
40266
|
-
// 1,238ms
|
|
40267
40292
|
]
|
|
40268
40293
|
},
|
|
40269
40294
|
MEDIUM: {
|
|
40270
|
-
primary: "google/gemini-
|
|
40271
|
-
//
|
|
40295
|
+
primary: "google/gemini-3.1-flash-lite",
|
|
40296
|
+
// $0.25/$1.50 — 1M context, newest flash-lite
|
|
40272
40297
|
fallback: [
|
|
40298
|
+
"openai/gpt-5.4-nano",
|
|
40299
|
+
// $0.20/$1.25, 1M context
|
|
40300
|
+
"google/gemini-2.5-flash-lite",
|
|
40301
|
+
// 1,353ms, $0.10/$0.40
|
|
40273
40302
|
"xai/grok-4-fast-non-reasoning",
|
|
40274
40303
|
"google/gemini-2.5-flash",
|
|
40275
|
-
"deepseek/deepseek-chat",
|
|
40276
40304
|
"nvidia/gpt-oss-120b"
|
|
40277
40305
|
]
|
|
40278
40306
|
},
|
|
40279
40307
|
COMPLEX: {
|
|
40280
|
-
primary: "google/gemini-
|
|
40281
|
-
//
|
|
40282
|
-
fallback: [
|
|
40308
|
+
primary: "google/gemini-3.1-flash-lite",
|
|
40309
|
+
// $0.25/$1.50 — 1M context handles complexity
|
|
40310
|
+
fallback: [
|
|
40311
|
+
"google/gemini-2.5-flash-lite",
|
|
40312
|
+
"xai/grok-4-0709",
|
|
40313
|
+
"google/gemini-2.5-flash",
|
|
40314
|
+
"deepseek/deepseek-chat"
|
|
40315
|
+
]
|
|
40283
40316
|
},
|
|
40284
40317
|
REASONING: {
|
|
40285
40318
|
primary: "xai/grok-4-1-fast-reasoning",
|
|
@@ -40444,6 +40477,9 @@ var MODEL_ALIASES = {
|
|
|
40444
40477
|
gpt5: "openai/gpt-5.4",
|
|
40445
40478
|
"gpt-5.4": "openai/gpt-5.4",
|
|
40446
40479
|
"gpt-5.4-pro": "openai/gpt-5.4-pro",
|
|
40480
|
+
"gpt-5.4-nano": "openai/gpt-5.4-nano",
|
|
40481
|
+
nano: "openai/gpt-5.4-nano",
|
|
40482
|
+
"gpt-5-nano": "openai/gpt-5.4-nano",
|
|
40447
40483
|
codex: "openai/gpt-5.3-codex",
|
|
40448
40484
|
mini: "openai/gpt-4o-mini",
|
|
40449
40485
|
o1: "openai/o1",
|
|
@@ -40461,6 +40497,7 @@ var MODEL_ALIASES = {
|
|
|
40461
40497
|
flash: "google/gemini-2.5-flash",
|
|
40462
40498
|
"gemini-3.1-pro-preview": "google/gemini-3.1-pro",
|
|
40463
40499
|
"google/gemini-3.1-pro-preview": "google/gemini-3.1-pro",
|
|
40500
|
+
"gemini-3.1-flash-lite": "google/gemini-3.1-flash-lite",
|
|
40464
40501
|
// xAI
|
|
40465
40502
|
grok: "xai/grok-3",
|
|
40466
40503
|
"grok-fast": "xai/grok-4-fast-reasoning",
|
|
@@ -40576,7 +40613,9 @@ var BLOCKRUN_MODELS = [
|
|
|
40576
40613
|
outputPrice: 0.4,
|
|
40577
40614
|
contextWindow: 128e3,
|
|
40578
40615
|
maxOutput: 32768,
|
|
40579
|
-
toolCalling: true
|
|
40616
|
+
toolCalling: true,
|
|
40617
|
+
deprecated: true,
|
|
40618
|
+
fallbackModel: "openai/gpt-5.4-nano"
|
|
40580
40619
|
},
|
|
40581
40620
|
{
|
|
40582
40621
|
id: "openai/gpt-5.2-pro",
|
|
@@ -40614,6 +40653,16 @@ var BLOCKRUN_MODELS = [
|
|
|
40614
40653
|
reasoning: true,
|
|
40615
40654
|
toolCalling: true
|
|
40616
40655
|
},
|
|
40656
|
+
{
|
|
40657
|
+
id: "openai/gpt-5.4-nano",
|
|
40658
|
+
name: "GPT-5.4 Nano",
|
|
40659
|
+
version: "5.4",
|
|
40660
|
+
inputPrice: 0.2,
|
|
40661
|
+
outputPrice: 1.25,
|
|
40662
|
+
contextWindow: 105e4,
|
|
40663
|
+
maxOutput: 32768,
|
|
40664
|
+
toolCalling: true
|
|
40665
|
+
},
|
|
40617
40666
|
// OpenAI GPT-5.3 Family
|
|
40618
40667
|
{
|
|
40619
40668
|
id: "openai/gpt-5.3",
|
|
@@ -40858,6 +40907,16 @@ var BLOCKRUN_MODELS = [
|
|
|
40858
40907
|
maxOutput: 65536,
|
|
40859
40908
|
toolCalling: true
|
|
40860
40909
|
},
|
|
40910
|
+
{
|
|
40911
|
+
id: "google/gemini-3.1-flash-lite",
|
|
40912
|
+
name: "Gemini 3.1 Flash Lite",
|
|
40913
|
+
version: "3.1",
|
|
40914
|
+
inputPrice: 0.25,
|
|
40915
|
+
outputPrice: 1.5,
|
|
40916
|
+
contextWindow: 1e6,
|
|
40917
|
+
maxOutput: 8192,
|
|
40918
|
+
toolCalling: true
|
|
40919
|
+
},
|
|
40861
40920
|
// DeepSeek
|
|
40862
40921
|
{
|
|
40863
40922
|
id: "deepseek/deepseek-chat",
|
|
@@ -47200,11 +47259,20 @@ function estimateAmount(modelId, bodyLength, maxTokens) {
|
|
|
47200
47259
|
return amountMicros.toString();
|
|
47201
47260
|
}
|
|
47202
47261
|
var IMAGE_PRICING = {
|
|
47203
|
-
"openai/dall-e-3": {
|
|
47204
|
-
|
|
47262
|
+
"openai/dall-e-3": {
|
|
47263
|
+
default: 0.04,
|
|
47264
|
+
sizes: { "1024x1024": 0.04, "1792x1024": 0.08, "1024x1792": 0.08 }
|
|
47265
|
+
},
|
|
47266
|
+
"openai/gpt-image-1": {
|
|
47267
|
+
default: 0.02,
|
|
47268
|
+
sizes: { "1024x1024": 0.02, "1536x1024": 0.04, "1024x1536": 0.04 }
|
|
47269
|
+
},
|
|
47205
47270
|
"black-forest/flux-1.1-pro": { default: 0.04 },
|
|
47206
47271
|
"google/nano-banana": { default: 0.05 },
|
|
47207
|
-
"google/nano-banana-pro": {
|
|
47272
|
+
"google/nano-banana-pro": {
|
|
47273
|
+
default: 0.1,
|
|
47274
|
+
sizes: { "1024x1024": 0.1, "2048x2048": 0.1, "4096x4096": 0.15 }
|
|
47275
|
+
}
|
|
47208
47276
|
};
|
|
47209
47277
|
function estimateImageCost(model, size5, n = 1) {
|
|
47210
47278
|
const pricing = IMAGE_PRICING[model];
|
|
@@ -47760,7 +47828,13 @@ async function startProxy(options) {
|
|
|
47760
47828
|
}
|
|
47761
47829
|
if (req.url?.match(/^\/v1\/(?:x|partner)\//)) {
|
|
47762
47830
|
try {
|
|
47763
|
-
await proxyPartnerRequest(
|
|
47831
|
+
await proxyPartnerRequest(
|
|
47832
|
+
req,
|
|
47833
|
+
res,
|
|
47834
|
+
apiBase,
|
|
47835
|
+
payFetch,
|
|
47836
|
+
() => paymentStore.getStore()?.amountUsd ?? 0
|
|
47837
|
+
);
|
|
47764
47838
|
} catch (err) {
|
|
47765
47839
|
const error = err instanceof Error ? err : new Error(String(err));
|
|
47766
47840
|
options.onError?.(error);
|