@blockrun/clawrouter 0.12.307 → 0.12.308
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 +33 -30
- package/dist/cli.js +138 -36
- package/dist/index.d.ts +2 -1
- package/dist/index.js +136 -34
- package/docs/9-free-ai-models-zero-cost-blockrun.md +33 -16
- package/docs/anthropic-cost-savings.md +3 -3
- package/docs/anthropic-third-party-harness-changes.md +3 -3
- package/docs/clawrouter-vs-openrouter-llm-routing-comparison.md +3 -3
- package/docs/configuration.md +5 -2
- package/docs/routing-profiles.md +3 -3
- package/package.json +2 -2
- package/scripts/reinstall.sh +2 -2
- package/skills/clawrouter/SKILL.md +3 -3
- package/src/top-models.json +2 -1
package/README.md
CHANGED
|
@@ -9,11 +9,11 @@ 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
10
|
<em>Pay however you like: <strong>credit card</strong> — sign up at <a href="https://user.blockrun.ai"><strong>user.blockrun.ai</strong></a>, top up, mint an API key<br>
|
|
11
11
|
or <strong>USDC</strong> on Solana or Base (x402 wallet, no account at all).<br>
|
|
12
|
-
Or neither — <!-- br:models.free -->
|
|
12
|
+
Or neither — <!-- br:models.free -->8<!-- /br:models.free --> models are free, with no signup, no key and no wallet.</em></p>
|
|
13
13
|
|
|
14
14
|
<br>
|
|
15
15
|
|
|
16
|
-
<img src="https://img.shields.io/badge/🆓
|
|
16
|
+
<img src="https://img.shields.io/badge/🆓_8_Free_Models-success?style=for-the-badge" alt="8 free models">
|
|
17
17
|
<img src="https://img.shields.io/badge/🤖_Agent--Native-black?style=for-the-badge" alt="Agent native">
|
|
18
18
|
<img src="https://img.shields.io/badge/💳_Card_or_USDC-blue?style=for-the-badge" alt="Card or USDC">
|
|
19
19
|
<img src="https://img.shields.io/badge/⚡_Local_Routing-yellow?style=for-the-badge" alt="Local routing">
|
|
@@ -36,7 +36,7 @@ Or neither — <!-- br:models.free -->7<!-- /br:models.free --> models are free,
|
|
|
36
36
|
|
|
37
37
|
</div>
|
|
38
38
|
|
|
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 -->
|
|
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 -->91<!-- /br:models.chatVisible --> models from OpenAI, Anthropic, Google, xAI, DeepSeek, and more. MIT licensed.
|
|
40
40
|
|
|
41
41
|
---
|
|
42
42
|
|
|
@@ -48,8 +48,8 @@ Not a seat, not a subscription, not a monthly minimum you keep paying while the
|
|
|
48
48
|
|
|
49
49
|
| | |
|
|
50
50
|
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
51
|
-
| **Every LLM** | <!-- br:models.chatVisible -->
|
|
52
|
-
| **Every tool** | <!-- br:models.image -->12<!-- /br:models.image --> image models, <!-- br:models.video -->
|
|
51
|
+
| **Every LLM** | <!-- br:models.chatVisible -->91<!-- /br:models.chatVisible --> chat models across 9 providers, behind one endpoint and one balance |
|
|
52
|
+
| **Every tool** | <!-- br:models.image -->12<!-- /br:models.image --> image models, <!-- br:models.video -->7<!-- /br:models.video --> video models, music, <!-- br:models.speech -->5<!-- /br:models.speech --> voices, img2img editing, and outbound phone calls that come back as transcripts |
|
|
53
53
|
| **Every data source** | web, news and neural search; prediction markets; live crypto and equity quotes; on-chain SQL over 100M+ labeled wallets; DEX routing; RPC across <!-- br:chains.rpc -->40<!-- /br:chains.rpc --> chains |
|
|
54
54
|
| **Best value per dollar** | <!-- br:clawrouter.dimensions -->15<!-- /br:clawrouter.dimensions -->-dimension local routing sends each request to the cheapest model that can actually do it — <!-- br:savings.autoVsBaselinePct -->84<!-- /br:savings.autoVsBaselinePct -->% below pinning Claude Opus 5 on the same traffic, computed from a published workload mix rather than estimated |
|
|
55
55
|
|
|
@@ -65,7 +65,7 @@ Every other LLM router was built for **human developers** — create an account,
|
|
|
65
65
|
|
|
66
66
|
ClawRouter is built for the agent-first world:
|
|
67
67
|
|
|
68
|
-
- **Starts at $0** — <!-- br:models.free -->
|
|
68
|
+
- **Starts at $0** — <!-- br:models.free -->8<!-- /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.
|
|
69
69
|
- **No accounts needed** — a wallet is generated locally, no signup
|
|
70
70
|
- **No API keys needed** — your wallet signature IS authentication
|
|
71
71
|
- **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
|
|
@@ -76,7 +76,7 @@ This is the stack that lets agents operate autonomously: **x402 + USDC + local r
|
|
|
76
76
|
|
|
77
77
|
### …and if you are a human, not an agent
|
|
78
78
|
|
|
79
|
-
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 -->
|
|
79
|
+
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 -->91<!-- /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.
|
|
80
80
|
|
|
81
81
|
| You are | Pay with | Setup |
|
|
82
82
|
| ------------------- | --------------------------------------- | ------------------------------------------------------------------------------------------- |
|
|
@@ -92,8 +92,8 @@ Full walkthrough: [Paying with a credit card](#paying-with-a-credit-card-api-key
|
|
|
92
92
|
|
|
93
93
|
| | OpenRouter | LiteLLM | Martian | Portkey | **ClawRouter** |
|
|
94
94
|
| ---------------- | ----------------- | ---------------- | ----------------- | ----------------- | ---------------------------------------------------------------------- |
|
|
95
|
-
| **Models** | 200+ | 100+ | Smart routing | Gateway | **<!-- br:models.chatVisible -->
|
|
96
|
-
| **Free tier** | Rate-limited | BYO keys | No | No | **<!-- br:models.free -->
|
|
95
|
+
| **Models** | 200+ | 100+ | Smart routing | Gateway | **<!-- br:models.chatVisible -->91<!-- /br:models.chatVisible -->** |
|
|
96
|
+
| **Free tier** | Rate-limited | BYO keys | No | No | **<!-- br:models.free -->8<!-- /br:models.free --> models, no signup** |
|
|
97
97
|
| **Routing** | Manual selection | Manual selection | Smart (closed) | Observability | **Smart (open source)** |
|
|
98
98
|
| **Auth** | Account + API key | Your API keys | Account + API key | Account + API key | **Wallet signature _or_ API key** |
|
|
99
99
|
| **Payment** | Credit card | BYO keys | Credit card | $49-499/mo | **USDC per-request _or_ card credit** |
|
|
@@ -109,7 +109,7 @@ Full walkthrough: [Paying with a credit card](#paying-with-a-credit-card-api-key
|
|
|
109
109
|
|
|
110
110
|
## Quick Start
|
|
111
111
|
|
|
112
|
-
> **No wallet? <!-- br:models.free -->
|
|
112
|
+
> **No wallet? <!-- br:models.free -->8<!-- /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 -->8<!-- /br:models.free -->) — no crypto, no signup, no balance required. Add a credit card or USDC later when you want paid models.
|
|
113
113
|
|
|
114
114
|
**Two ways to pay for the paid ones — pick one, the rest of ClawRouter is identical:**
|
|
115
115
|
|
|
@@ -127,7 +127,7 @@ is all it takes to switch and `clawrouter logout` is all it takes to switch back
|
|
|
127
127
|
|
|
128
128
|
> **Where do I sign up?** [**user.blockrun.ai**](https://user.blockrun.ai) — sign in with
|
|
129
129
|
> Google, add credit with a card under **Credits**, mint a key under **API Keys**. That
|
|
130
|
-
> one key covers all <!-- br:models.chatVisible -->
|
|
130
|
+
> one key covers all <!-- br:models.chatVisible -->91<!-- /br:models.chatVisible --> chat models
|
|
131
131
|
> plus images, video, speech and the live-data APIs. No wallet, no crypto, no seed phrase.
|
|
132
132
|
|
|
133
133
|
### Desktop control plane (macOS)
|
|
@@ -182,7 +182,7 @@ It backs up the wallet and OpenClaw integration state first and rolls back the p
|
|
|
182
182
|
|
|
183
183
|
> **Using Claude Code?** Check out [BRCC](https://github.com/BlockRunAI/brcc) — it's purpose-built for Claude Code with the same smart routing and x402 payments.
|
|
184
184
|
>
|
|
185
|
-
> **Using NousResearch Hermes?** See [ClawRouter-Hermes](https://github.com/BlockRunAI/ClawRouter-Hermes) — a Python plugin that wires Hermes into the ClawRouter proxy. Same wallet, same <!-- br:models.chatVisible -->
|
|
185
|
+
> **Using NousResearch Hermes?** See [ClawRouter-Hermes](https://github.com/BlockRunAI/ClawRouter-Hermes) — a Python plugin that wires Hermes into the ClawRouter proxy. Same wallet, same <!-- br:models.chatVisible -->91<!-- /br:models.chatVisible --> models, same x402 USDC settlement on Solana & Base.
|
|
186
186
|
|
|
187
187
|
No OpenClaw required. ClawRouter runs as a local proxy on port 8402.
|
|
188
188
|
|
|
@@ -193,7 +193,7 @@ npx @blockrun/clawrouter
|
|
|
193
193
|
```
|
|
194
194
|
|
|
195
195
|
**2. Fund your wallet** — optional, skip for free tier
|
|
196
|
-
Your wallet address is printed on first run. For paid models, send a few USDC on Solana (the default chain) or Base — $5 covers thousands of requests. Prefer a card? [Sign up at user.blockrun.ai](https://user.blockrun.ai) and run `clawrouter login brk_live_…` instead. To stay at $0, pin any of the <!-- br:models.free -->
|
|
196
|
+
Your wallet address is printed on first run. For paid models, send a few USDC on Solana (the default chain) or Base — $5 covers thousands of requests. Prefer a card? [Sign up at user.blockrun.ai](https://user.blockrun.ai) and run `clawrouter login brk_live_…` instead. To stay at $0, pin any of the <!-- br:models.free -->8<!-- /br:models.free --> free models (e.g. `free/nemotron-3.5-lightning`) or use `/model free` inside OpenClaw.
|
|
197
197
|
|
|
198
198
|
**3. Point your client at `http://localhost:8402`**
|
|
199
199
|
|
|
@@ -366,13 +366,15 @@ curl -X POST http://localhost:8402/v1/videos/generations \
|
|
|
366
366
|
|
|
367
367
|
Live per-model prices: [blockrun.ai/pricing](https://blockrun.ai/pricing) (agents: `GET https://blockrun.ai/api/v1/models`). Prices are not copied here, so this page never goes stale on a reprice.
|
|
368
368
|
|
|
369
|
-
| Model | Provider
|
|
370
|
-
| ----------------------------- |
|
|
371
|
-
| `bytedance/seedance-1.5-pro` | ByteDance Seedance
|
|
372
|
-
| `bytedance/seedance-2.0-fast` | ByteDance Seedance
|
|
373
|
-
| `bytedance/seedance-2.0`
|
|
374
|
-
| `
|
|
375
|
-
| `
|
|
369
|
+
| Model | Provider | Duration |
|
|
370
|
+
| ----------------------------- | ------------------ | --------------------- |
|
|
371
|
+
| `bytedance/seedance-1.5-pro` | ByteDance Seedance | 5s default, up to 12s |
|
|
372
|
+
| `bytedance/seedance-2.0-fast` | ByteDance Seedance | 5s default, up to 15s |
|
|
373
|
+
| `bytedance/seedance-2.0-mini` | ByteDance Seedance | 5s default, up to 15s |
|
|
374
|
+
| `bytedance/seedance-2.0` | ByteDance Seedance | 5s default, up to 15s |
|
|
375
|
+
| `bytedance/seedance-2.5` | ByteDance Seedance | 5s default, up to 30s |
|
|
376
|
+
| `xai/grok-imagine-video` | xAI Grok Imagine | 8s default, up to 15s |
|
|
377
|
+
| `xai/grok-imagine-video-1.5` | xAI Grok Imagine | 8s default, up to 15s |
|
|
376
378
|
|
|
377
379
|
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 `duration × tokens/sec × $/1M tokens × 1.05 margin`. Image-to-video is priced the same as text-to-video (the earlier ~40% i2v discount was removed upstream on 2026-06-01; only video-to-video remains cheaper). Sora 2 is flat-priced at $0.10/sec for both t2v and i2v — note it rejects human faces in reference images (use Seedance + RealFace for real people). Calls block for 30–120s while the upstream polls the job. Seedance 2.0 Fast typically returns in 60–80s; 2.0 Pro trades latency for quality.
|
|
378
380
|
|
|
@@ -458,7 +460,7 @@ LLM agents discover all eight operations as `blockrun_phone_*` / `blockrun_voice
|
|
|
458
460
|
|
|
459
461
|
## Models & Pricing
|
|
460
462
|
|
|
461
|
-
<!-- br:models.chatVisible -->
|
|
463
|
+
<!-- br:models.chatVisible -->91<!-- /br:models.chatVisible --> models across 9 providers, one wallet. **<!-- br:models.free -->8<!-- /br:models.free --> models are $0 — paid models start at fractions of a cent.**
|
|
462
464
|
|
|
463
465
|
> **💡** Models are grouped by typical cost of a chat message (~500 input + 500 output tokens). Paid requests also carry a flat **$0.001/tx settlement fee** (covers on-chain gas; already included in the price the gateway quotes). Free models never pay it.
|
|
464
466
|
|
|
@@ -473,7 +475,8 @@ Live per-model prices: [blockrun.ai/pricing](https://blockrun.ai/pricing) (agent
|
|
|
473
475
|
| free/north-mini-code | 256K | coding (Cohere, sub-second) |
|
|
474
476
|
| free/nemotron-3-nano-omni-30b-a3b-reasoning | 256K | reasoning (text only — see note) |
|
|
475
477
|
| free/nemotron-3-ultra-550b | 1M | largest free model (550B/55B MoE) |
|
|
476
|
-
| free/
|
|
478
|
+
| free/nemotron-3.5-bolt | 131K | vision, about a second to answer |
|
|
479
|
+
| free/nemotron-3-super-120b | 131K | reasoning |
|
|
477
480
|
| free/muse-glimmer-30b | 131K | reasoning (Meta Muse, text only) |
|
|
478
481
|
| qwen/qwen3.7-flash | 1M | reasoning, tools (fastest Qwen tier) |
|
|
479
482
|
| poolside/laguna-s-2.1 | 1M | coding (paid sibling of laguna-xs) |
|
|
@@ -561,9 +564,9 @@ Live per-model prices: [blockrun.ai/pricing](https://blockrun.ai/pricing) (agent
|
|
|
561
564
|
| openai/gpt-5.4-pro | 1M | reasoning, tools |
|
|
562
565
|
| openai/gpt-5.5-pro | 1M | reasoning, vision, tools |
|
|
563
566
|
|
|
564
|
-
> **Free tier:** <!-- br:models.free -->
|
|
567
|
+
> **Free tier:** <!-- br:models.free -->8<!-- /br:models.free --> open-weight models cost nothing — `/model free` pins the free default (`nemotron-3.5-lightning`, with the other five as fallbacks), `/model eco` opens on it, or pick one directly (e.g., `/model lightning` for 1M-context reasoning, `/model north-mini` or `/model laguna` for fast coding).
|
|
565
568
|
>
|
|
566
|
-
> **
|
|
569
|
+
> **One free model reads images: `free/nemotron-3.5-bolt`.** It got 8 of 8 right on 64×64 solid-colour PNGs across Base and Solana on 2026-11-05, answered by Bolt itself. The rest of the free tier isn't flagged for vision: `nemotron-3-nano-omni` was right 1 of 4 times on Base in August, and only 2 of 8 probes of `nemotron-3-super-120b` reached that model. These failures can arrive as an HTTP 200 with a wrong answer and no error to branch on. Pin `/model vision-free` for free images; otherwise requests carrying an `image_url` route to a paid vision model.
|
|
567
570
|
> **Best value:** `gpt-5-nano` and `gemini-2.5-flash-lite` deliver strong results at ~$0.0003/request.
|
|
568
571
|
|
|
569
572
|
---
|
|
@@ -709,7 +712,7 @@ chains, the response cache and the local spend controls.
|
|
|
709
712
|
- **Balance lives server-side.** There is no local balance to check: a call that
|
|
710
713
|
outruns your credit comes back as HTTP `402 insufficient_quota`, naming the
|
|
711
714
|
top-up page. Free models stay free and need no credit at all — all
|
|
712
|
-
<!-- br:models.free -->
|
|
715
|
+
<!-- br:models.free -->8<!-- /br:models.free --> are served on the API-key gateway too.
|
|
713
716
|
- **One key covers nearly everything.** Verified live against `api.blockrun.ai`
|
|
714
717
|
on 2026-09-05: chat completions (`/v1/chat/completions`), the Anthropic-shaped
|
|
715
718
|
`/v1/messages`, `/v1/models`, image generation, speech, video, and the partner
|
|
@@ -861,7 +864,7 @@ npm test
|
|
|
861
864
|
|
|
862
865
|
**The LLM router built for autonomous agents**
|
|
863
866
|
|
|
864
|
-
You're here. <!-- br:models.chatVisible -->
|
|
867
|
+
You're here. <!-- br:models.chatVisible -->91<!-- /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.
|
|
865
868
|
|
|
866
869
|
`curl -fsSL https://blockrun.ai/ClawRouter-update | bash`
|
|
867
870
|
|
|
@@ -872,7 +875,7 @@ You're here. <!-- br:models.chatVisible -->90<!-- /br:models.chatVisible --> mod
|
|
|
872
875
|
|
|
873
876
|
**BlockRun for Claude Code**
|
|
874
877
|
|
|
875
|
-
Run Claude Code with <!-- br:models.chatVisible -->
|
|
878
|
+
Run Claude Code with <!-- br:models.chatVisible -->91<!-- /br:models.chatVisible --> models, no rate limits, no Anthropic account, no phone verification. Pay per request with USDC — your wallet is your identity.
|
|
876
879
|
|
|
877
880
|
`curl -fsSL https://blockrun.ai/brcc-install | bash`
|
|
878
881
|
|
|
@@ -885,7 +888,7 @@ Run Claude Code with <!-- br:models.chatVisible -->90<!-- /br:models.chatVisible
|
|
|
885
888
|
|
|
886
889
|
**ClawRouter for NousResearch Hermes**
|
|
887
890
|
|
|
888
|
-
Python plugin that wraps the ClawRouter proxy for `hermes-agent`. Same <!-- br:models.chatVisible -->
|
|
891
|
+
Python plugin that wraps the ClawRouter proxy for `hermes-agent`. Same <!-- br:models.chatVisible -->91<!-- /br:models.chatVisible --> models, same x402 USDC payments on Solana & Base, native Hermes ergonomics.
|
|
889
892
|
|
|
890
893
|
`pip install hermes-plugin-clawrouter`
|
|
891
894
|
|
|
@@ -929,7 +932,7 @@ Python plugin that wraps the ClawRouter proxy for `hermes-agent`. Same <!-- br:m
|
|
|
929
932
|
|
|
930
933
|
### What is BlockRun?
|
|
931
934
|
|
|
932
|
-
BlockRun lets agents pay for the outcome — every LLM, tool and data source, best value per dollar. One endpoint and one balance covering <!-- br:models.chatVisible -->
|
|
935
|
+
BlockRun lets agents pay for the outcome — every LLM, tool and data source, best value per dollar. One endpoint and one balance covering <!-- br:models.chatVisible -->91<!-- /br:models.chatVisible --> chat models plus image, video, music and speech generation, search, market data and multi-chain RPC, billed per call with USDC over [x402](https://x402.org) or a credit-card-funded API key — no seat, no subscription, no minimum. ClawRouter is the open-source local router agents use to reach it.
|
|
933
936
|
|
|
934
937
|
### What is ClawRouter?
|
|
935
938
|
|
|
@@ -957,7 +960,7 @@ No. A wallet is the default because it is what lets an _agent_ pay for itself,
|
|
|
957
960
|
but you can sign up at **[user.blockrun.ai](https://user.blockrun.ai)**, top up
|
|
958
961
|
with a credit card, mint an API key and run `clawrouter login brk_live_…`. Calls
|
|
959
962
|
then go to `api.blockrun.ai` on a bearer token and bill your account credit — no
|
|
960
|
-
crypto, no gas, no seed phrase. And the <!-- br:models.free -->
|
|
963
|
+
crypto, no gas, no seed phrase. And the <!-- br:models.free -->8<!-- /br:models.free --> free models need neither: no
|
|
961
964
|
wallet, no key, no signup. See [Paying with a credit card](#paying-with-a-credit-card-api-key).
|
|
962
965
|
|
|
963
966
|
### Is ClawRouter free?
|
package/dist/cli.js
CHANGED
|
@@ -6840,7 +6840,8 @@ var init_top_models = __esm({
|
|
|
6840
6840
|
"free/north-mini-code",
|
|
6841
6841
|
"free/nemotron-3-nano-omni-30b-a3b-reasoning",
|
|
6842
6842
|
"free/nemotron-3-ultra-550b",
|
|
6843
|
-
"free/
|
|
6843
|
+
"free/nemotron-3.5-bolt",
|
|
6844
|
+
"free/nemotron-3-super-120b",
|
|
6844
6845
|
"free/muse-glimmer-30b"
|
|
6845
6846
|
];
|
|
6846
6847
|
}
|
|
@@ -7328,10 +7329,10 @@ var init_models = __esm({
|
|
|
7328
7329
|
"mistral-free": "free/nemotron-3.5-lightning",
|
|
7329
7330
|
"glm-free": "free/nemotron-3.5-lightning",
|
|
7330
7331
|
// seed-oss-36b (the prior target) EOL'd 2026-08-03
|
|
7331
|
-
//
|
|
7332
|
-
//
|
|
7333
|
-
|
|
7334
|
-
|
|
7332
|
+
// No free Llama is left: NVIDIA deprovisioned Llama 3.2 11B Vision on 2026-11-02.
|
|
7333
|
+
// blockrun's /free-llama page now leads with Muse, so the shorthand follows it.
|
|
7334
|
+
"llama-free": "free/muse-glimmer-30b",
|
|
7335
|
+
// no free Llama left; Muse is Meta's open line after it
|
|
7335
7336
|
// qwen3-coder-480b retired 2026-06-14 → seed-oss-36b, which then EOL'd 2026-08-03.
|
|
7336
7337
|
// Follow the gateway's own retarget rather than chaining to a second dead model.
|
|
7337
7338
|
"qwen-coder": "free/nemotron-3.5-lightning",
|
|
@@ -7370,11 +7371,8 @@ var init_models = __esm({
|
|
|
7370
7371
|
// Vision-capable free models
|
|
7371
7372
|
"nemotron-omni": "free/nemotron-3-nano-omni-30b-a3b-reasoning",
|
|
7372
7373
|
"nano-omni": "free/nemotron-3-nano-omni-30b-a3b-reasoning",
|
|
7373
|
-
// `vision-free`
|
|
7374
|
-
|
|
7375
|
-
// claims working image input on either chain (see the catalog note). Do not
|
|
7376
|
-
// advertise this alias as a way to get free vision.
|
|
7377
|
-
"vision-free": "free/nemotron-3-nano-omni-30b-a3b-reasoning",
|
|
7374
|
+
// `vision-free` names the one free model that proved it reads images.
|
|
7375
|
+
"vision-free": "free/nemotron-3.5-bolt",
|
|
7378
7376
|
// Retired shorthand aliases redirect to live successors. The catch-all target
|
|
7379
7377
|
// moved llama-4-maverick → gpt-oss-120b (2026-07-17) → step-3.7-flash
|
|
7380
7378
|
// (2026-08-29) → nemotron-3.5-lightning (2026-08-30, blockrun #448).
|
|
@@ -7382,7 +7380,8 @@ var init_models = __esm({
|
|
|
7382
7380
|
// strongest live Nemotron
|
|
7383
7381
|
"nemotron-ultra": "free/nemotron-3.5-lightning",
|
|
7384
7382
|
"nemotron-253b": "free/nemotron-3.5-lightning",
|
|
7385
|
-
"nemotron-super": "free/nemotron-3
|
|
7383
|
+
"nemotron-super": "free/nemotron-3-super-120b",
|
|
7384
|
+
// now names a real free model
|
|
7386
7385
|
"nemotron-49b": "free/nemotron-3.5-lightning",
|
|
7387
7386
|
"nemotron-120b": "free/nemotron-3.5-lightning",
|
|
7388
7387
|
devstral: "free/nemotron-3.5-lightning",
|
|
@@ -7427,6 +7426,12 @@ var init_models = __esm({
|
|
|
7427
7426
|
// free on NVIDIA. A reasoning model: a small max_tokens is spent entirely in
|
|
7428
7427
|
// reasoning and returns empty content.
|
|
7429
7428
|
"nvidia/muse-glimmer-30b": "free/muse-glimmer-30b",
|
|
7429
|
+
"nvidia/nemotron-3.5-bolt": "free/nemotron-3.5-bolt",
|
|
7430
|
+
"nemotron-3.5-bolt": "free/nemotron-3.5-bolt",
|
|
7431
|
+
bolt: "free/nemotron-3.5-bolt",
|
|
7432
|
+
"nvidia/nemotron-3-super-120b": "free/nemotron-3-super-120b",
|
|
7433
|
+
"nemotron-3-super-120b": "free/nemotron-3-super-120b",
|
|
7434
|
+
"super-120b": "free/nemotron-3-super-120b",
|
|
7430
7435
|
muse: "free/muse-glimmer-30b",
|
|
7431
7436
|
"muse-glimmer": "free/muse-glimmer-30b",
|
|
7432
7437
|
"muse-glimmer-30b": "free/muse-glimmer-30b",
|
|
@@ -9145,7 +9150,9 @@ var init_models = __esm({
|
|
|
9145
9150
|
// (Llama-3.3-based) hit NVIDIA's 410 EOL. A 12-model sweep found exactly two
|
|
9146
9151
|
// survivors and only the 11B finishes a real completion. Older than the rest
|
|
9147
9152
|
// of the tier and deliberately so: it is a real Llama that actually answers.
|
|
9148
|
-
//
|
|
9153
|
+
// Retired 2026-11-02: NVIDIA deprovisioned it and blockrun delisted it. Entry
|
|
9154
|
+
// kept so explicit pins stay routable;
|
|
9155
|
+
// off the picker, the FREE_MODELS cascade and every default.
|
|
9149
9156
|
id: "free/llama-3.2-11b-vision",
|
|
9150
9157
|
name: "[Free] Llama 3.2 11B Vision",
|
|
9151
9158
|
version: "3.2-11b-vision",
|
|
@@ -9205,6 +9212,35 @@ var init_models = __esm({
|
|
|
9205
9212
|
maxOutput: 16384,
|
|
9206
9213
|
reasoning: true
|
|
9207
9214
|
},
|
|
9215
|
+
{
|
|
9216
|
+
// Nemotron 3.5 Bolt (blockrun 2026-11-04): about a second to answer, no
|
|
9217
|
+
// thinking pass. The one free model flagged for vision. 2026-11-05, 64x64
|
|
9218
|
+
// solid-colour PNGs: 8 of 8 correct across Base and Solana, and every
|
|
9219
|
+
// response's `model` field named Bolt itself, so no rescue did the reading.
|
|
9220
|
+
id: "free/nemotron-3.5-bolt",
|
|
9221
|
+
name: "[Free] Nemotron 3.5 Bolt",
|
|
9222
|
+
version: "3.5-bolt",
|
|
9223
|
+
inputPrice: 0,
|
|
9224
|
+
outputPrice: 0,
|
|
9225
|
+
contextWindow: 131072,
|
|
9226
|
+
maxOutput: 16384,
|
|
9227
|
+
vision: true
|
|
9228
|
+
},
|
|
9229
|
+
{
|
|
9230
|
+
// Nemotron 3.5 Super, served under its older 3-super-120b id (blockrun
|
|
9231
|
+
// 2026-11-04). Reasoning, and the gateway's redirect target for the retired
|
|
9232
|
+
// Llama. NO `vision`, although blockrun tags it: on 2026-11-05 only 2 of 8
|
|
9233
|
+
// image probes were answered by this model; the rest were rescued by
|
|
9234
|
+
// nano-omni or refused with a capacity 429, which proves nothing about it.
|
|
9235
|
+
id: "free/nemotron-3-super-120b",
|
|
9236
|
+
name: "[Free] Nemotron 3 Super 120B",
|
|
9237
|
+
version: "3-super-120b",
|
|
9238
|
+
inputPrice: 0,
|
|
9239
|
+
outputPrice: 0,
|
|
9240
|
+
contextWindow: 131072,
|
|
9241
|
+
maxOutput: 16384,
|
|
9242
|
+
reasoning: true
|
|
9243
|
+
},
|
|
9208
9244
|
// ── 2026-08-30 paid catalog refresh (blockrun #449) ─────────────────────
|
|
9209
9245
|
// Three additions, each probe-verified upstream with a real completion AND a
|
|
9210
9246
|
// real image before listing. All three carry `vision: true` on that evidence
|
|
@@ -89302,7 +89338,7 @@ function usdToMicros(usd2) {
|
|
|
89302
89338
|
function microsToUsd(micros) {
|
|
89303
89339
|
return Number(micros) / 1e6;
|
|
89304
89340
|
}
|
|
89305
|
-
var SessionSpend, CostCapError;
|
|
89341
|
+
var SessionSpend, CostCapError, ZERO_CAP_REFUSAL;
|
|
89306
89342
|
var init_session_spend = __esm({
|
|
89307
89343
|
"src/session-spend.ts"() {
|
|
89308
89344
|
"use strict";
|
|
@@ -89442,6 +89478,7 @@ var init_session_spend = __esm({
|
|
|
89442
89478
|
this.name = "CostCapError";
|
|
89443
89479
|
}
|
|
89444
89480
|
};
|
|
89481
|
+
ZERO_CAP_REFUSAL = "ClawRouter cost cap: maxCostPerRun is 0, so no paid call is made";
|
|
89445
89482
|
}
|
|
89446
89483
|
});
|
|
89447
89484
|
|
|
@@ -155598,6 +155635,42 @@ function gatewaySettledCostUsd(response) {
|
|
|
155598
155635
|
if (!Number.isFinite(value) || value < 0) return void 0;
|
|
155599
155636
|
return value;
|
|
155600
155637
|
}
|
|
155638
|
+
function refuseOverCostCap(res, err) {
|
|
155639
|
+
if (!(err instanceof CostCapError) || res.headersSent) return false;
|
|
155640
|
+
res.writeHead(429, {
|
|
155641
|
+
"Content-Type": "application/json",
|
|
155642
|
+
"X-ClawRouter-Cost-Cap-Exceeded": "1"
|
|
155643
|
+
});
|
|
155644
|
+
res.end(
|
|
155645
|
+
JSON.stringify({
|
|
155646
|
+
error: { message: err.message, type: "cost_cap_exceeded", code: "cost_cap_exceeded" }
|
|
155647
|
+
})
|
|
155648
|
+
);
|
|
155649
|
+
return true;
|
|
155650
|
+
}
|
|
155651
|
+
function withZeroCapGuard(inner, isFree) {
|
|
155652
|
+
return async (input2, init2) => {
|
|
155653
|
+
const { pathname } = new URL(input2 instanceof Request ? input2.url : String(input2));
|
|
155654
|
+
const path8 = pathname.slice(Math.max(pathname.indexOf("/v1/"), 0));
|
|
155655
|
+
const method = (init2?.method ?? "GET").toUpperCase();
|
|
155656
|
+
let allowed;
|
|
155657
|
+
if (/^\/v1\/(?:chat\/completions|messages)$/.test(path8)) {
|
|
155658
|
+
const body = init2?.body;
|
|
155659
|
+
let model;
|
|
155660
|
+
try {
|
|
155661
|
+
const text = typeof body === "string" ? body : body instanceof Uint8Array ? Buffer.from(body).toString() : "";
|
|
155662
|
+
model = JSON.parse(text).model;
|
|
155663
|
+
} catch {
|
|
155664
|
+
model = void 0;
|
|
155665
|
+
}
|
|
155666
|
+
allowed = typeof model === "string" && isFree(model);
|
|
155667
|
+
} else {
|
|
155668
|
+
allowed = ZERO_CAP_FREE_READ.test(path8) && (method === "GET" || method === "HEAD");
|
|
155669
|
+
}
|
|
155670
|
+
if (!allowed) throw new CostCapError(ZERO_CAP_REFUSAL);
|
|
155671
|
+
return inner(input2, init2);
|
|
155672
|
+
};
|
|
155673
|
+
}
|
|
155601
155674
|
async function proxyPaidApiRequest(req, res, apiBase, payFetch, getActualPaymentUsd, accountPassthrough = false, authMode = "wallet") {
|
|
155602
155675
|
const startTime = Date.now();
|
|
155603
155676
|
const upstreamUrl = `${apiBase}${req.url}`;
|
|
@@ -155762,6 +155835,12 @@ function assertExistingProxyBillsUs(existing, requested) {
|
|
|
155762
155835
|
}
|
|
155763
155836
|
}
|
|
155764
155837
|
async function startProxy(options) {
|
|
155838
|
+
if (options.maxCostPerRunUsd !== void 0 && !Number.isFinite(options.maxCostPerRunUsd)) {
|
|
155839
|
+
console.warn(
|
|
155840
|
+
`[ClawRouter] Ignoring maxCostPerRun: ${String(options.maxCostPerRunUsd)} is not a finite number`
|
|
155841
|
+
);
|
|
155842
|
+
options = { ...options, maxCostPerRunUsd: void 0 };
|
|
155843
|
+
}
|
|
155765
155844
|
const upstreamProxy = await applyUpstreamProxy(options.upstreamProxy);
|
|
155766
155845
|
if (upstreamProxy) {
|
|
155767
155846
|
console.log(`[ClawRouter] Upstream proxy: ${upstreamProxy}`);
|
|
@@ -155862,6 +155941,7 @@ async function startProxy(options) {
|
|
|
155862
155941
|
const account = walletKey ? privateKeyToAccount(walletKey) : void 0;
|
|
155863
155942
|
const x402 = authMode === "wallet" ? new x402Client().setSpendControls(false) : void 0;
|
|
155864
155943
|
const registerCostCapHook = (client) => client.onBeforePaymentCreation(async (context) => {
|
|
155944
|
+
if (options.maxCostPerRunUsd === 0) throw new CostCapError(ZERO_CAP_REFUSAL);
|
|
155865
155945
|
const spend = paymentStore.getStore()?.sessionSpend;
|
|
155866
155946
|
if (!spend?.isStrict) return;
|
|
155867
155947
|
const quote = parseQuotedAmountMicros(context.selectedRequirements);
|
|
@@ -155983,8 +156063,12 @@ async function startProxy(options) {
|
|
|
155983
156063
|
);
|
|
155984
156064
|
}
|
|
155985
156065
|
const requestOptions = solanaBatch ? { ...options, _solanaBatchActive: true } : options;
|
|
156066
|
+
const keyFetch = apiKey ? createApiKeyFetch(apiKey, fetch, apiBase) : void 0;
|
|
155986
156067
|
const payFetch = authMode === "api-key" ? withSpendPolicy(
|
|
155987
|
-
|
|
156068
|
+
options.maxCostPerRunUsd === 0 ? withZeroCapGuard(keyFetch, (model) => {
|
|
156069
|
+
const { freeIds } = catalog.current();
|
|
156070
|
+
return freeIds.has(resolveModelAlias(model)) || [...freeIds].some((id2) => toUpstreamModelId(id2) === model);
|
|
156071
|
+
}) : keyFetch,
|
|
155988
156072
|
options.spendControl ?? getSharedSpendControl(),
|
|
155989
156073
|
() => {
|
|
155990
156074
|
const store = paymentStore.getStore();
|
|
@@ -156553,6 +156637,7 @@ async function startProxy(options) {
|
|
|
156553
156637
|
res.end(JSON.stringify(result));
|
|
156554
156638
|
} catch (err) {
|
|
156555
156639
|
if (clientAbort.signal.aborted) return;
|
|
156640
|
+
if (refuseOverCostCap(res, err)) return;
|
|
156556
156641
|
const msg = err instanceof Error ? err.message : String(err);
|
|
156557
156642
|
console.error(`[ClawRouter] Image generation error: ${msg}`);
|
|
156558
156643
|
if (!res.headersSent) {
|
|
@@ -156690,6 +156775,7 @@ async function startProxy(options) {
|
|
|
156690
156775
|
res.end(JSON.stringify(result));
|
|
156691
156776
|
} catch (err) {
|
|
156692
156777
|
if (clientAbort.signal.aborted) return;
|
|
156778
|
+
if (refuseOverCostCap(res, err)) return;
|
|
156693
156779
|
const msg = err instanceof Error ? err.message : String(err);
|
|
156694
156780
|
console.error(`[ClawRouter] Image editing error: ${msg}`);
|
|
156695
156781
|
if (!res.headersSent) {
|
|
@@ -156786,6 +156872,7 @@ async function startProxy(options) {
|
|
|
156786
156872
|
res.end(JSON.stringify(result));
|
|
156787
156873
|
} catch (err) {
|
|
156788
156874
|
if (clientAbort.signal.aborted) return;
|
|
156875
|
+
if (refuseOverCostCap(res, err)) return;
|
|
156789
156876
|
const msg = err instanceof Error ? err.message : String(err);
|
|
156790
156877
|
console.error(`[ClawRouter] Audio generation error: ${msg}`);
|
|
156791
156878
|
if (!res.headersSent) {
|
|
@@ -156952,6 +157039,7 @@ async function startProxy(options) {
|
|
|
156952
157039
|
res.end(JSON.stringify(finalResult));
|
|
156953
157040
|
} catch (err) {
|
|
156954
157041
|
if (clientAbort.signal.aborted) return;
|
|
157042
|
+
if (refuseOverCostCap(res, err)) return;
|
|
156955
157043
|
const msg = err instanceof Error ? err.message : String(err);
|
|
156956
157044
|
console.error(`[ClawRouter] Video generation error: ${msg}`);
|
|
156957
157045
|
if (!res.headersSent) {
|
|
@@ -156962,9 +157050,7 @@ async function startProxy(options) {
|
|
|
156962
157050
|
return;
|
|
156963
157051
|
}
|
|
156964
157052
|
const isVerbatimGatewayPath = req.url === "/v1/messages" || (req.url?.startsWith("/v1/messages?") ?? false) || req.url === "/v1/audio/speech" || (req.url?.startsWith("/v1/audio/speech?") ?? false);
|
|
156965
|
-
if (isVerbatimGatewayPath || req.url?.match(
|
|
156966
|
-
/^\/v1\/(?:partner|pm|exa|modal|stocks|usstock|crypto|fx|commodity|phone|voice)\//
|
|
156967
|
-
)) {
|
|
157053
|
+
if (isVerbatimGatewayPath || req.url?.match(PAID_API_PATH)) {
|
|
156968
157054
|
try {
|
|
156969
157055
|
await proxyPaidApiRequest(
|
|
156970
157056
|
req,
|
|
@@ -156976,6 +157062,7 @@ async function startProxy(options) {
|
|
|
156976
157062
|
authMode
|
|
156977
157063
|
);
|
|
156978
157064
|
} catch (err) {
|
|
157065
|
+
if (refuseOverCostCap(res, err)) return;
|
|
156979
157066
|
const error62 = err instanceof Error ? err : new Error(String(err));
|
|
156980
157067
|
options.onError?.(error62);
|
|
156981
157068
|
if (!res.headersSent) {
|
|
@@ -157008,6 +157095,7 @@ async function startProxy(options) {
|
|
|
157008
157095
|
authMode
|
|
157009
157096
|
);
|
|
157010
157097
|
} catch (err) {
|
|
157098
|
+
if (refuseOverCostCap(res, err)) return;
|
|
157011
157099
|
const error62 = err instanceof Error ? err : new Error(String(err));
|
|
157012
157100
|
options.onError?.(error62);
|
|
157013
157101
|
if (!res.headersSent) {
|
|
@@ -157800,6 +157888,7 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
157800
157888
|
}
|
|
157801
157889
|
} catch (err) {
|
|
157802
157890
|
if (imagegenAbort.signal.aborted) return;
|
|
157891
|
+
if (refuseOverCostCap(res, err)) return;
|
|
157803
157892
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
157804
157893
|
console.error(`[ClawRouter] /imagegen error: ${errMsg}`);
|
|
157805
157894
|
if (!res.headersSent) {
|
|
@@ -158006,6 +158095,7 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
158006
158095
|
sendImg2ImgText(responseText);
|
|
158007
158096
|
} catch (err) {
|
|
158008
158097
|
if (img2imgAbort.signal.aborted) return;
|
|
158098
|
+
if (refuseOverCostCap(res, err)) return;
|
|
158009
158099
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
158010
158100
|
console.error(`[ClawRouter] /img2img error: ${errMsg}`);
|
|
158011
158101
|
if (!res.headersSent) {
|
|
@@ -158429,13 +158519,20 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
158429
158519
|
}
|
|
158430
158520
|
}
|
|
158431
158521
|
let sessionSpend;
|
|
158432
|
-
if (options.maxCostPerRunUsd
|
|
158522
|
+
if (options.maxCostPerRunUsd !== void 0 && !effectiveSessionId) {
|
|
158523
|
+
effectiveSessionId = NO_SESSION_ID;
|
|
158524
|
+
}
|
|
158525
|
+
if (options.maxCostPerRunUsd !== void 0 && effectiveSessionId && !isFreeModel && (options.maxCostPerRunMode ?? "graceful") === "strict") {
|
|
158433
158526
|
const thisReqEstStr = estimatedCostMicros !== void 0 ? estimatedCostMicros.toString() : modelId ? estimate(modelId, body.length, maxTokens) : void 0;
|
|
158434
158527
|
const admission = SessionSpend.admit(
|
|
158435
158528
|
sessionStore,
|
|
158436
158529
|
effectiveSessionId,
|
|
158437
158530
|
usdToMicros(options.maxCostPerRunUsd),
|
|
158438
|
-
|
|
158531
|
+
// No local price usually means zero here: on the wallet rail the signing
|
|
158532
|
+
// check still reads the real quote, and eco's free rungs carry no estimate.
|
|
158533
|
+
// The key rail has nothing behind this check, so count one micro, which
|
|
158534
|
+
// refuses a model it cannot price once the session has nothing left.
|
|
158535
|
+
parseMicros(thisReqEstStr) ?? (options.apiKey?.trim() && !catalog.freeIds.has(resolveModelAlias(modelId ?? "")) ? 1n : 0n)
|
|
158439
158536
|
);
|
|
158440
158537
|
if (!admission.admitted) {
|
|
158441
158538
|
const spentUsd = microsToUsd(admission.spentMicros);
|
|
@@ -158463,12 +158560,12 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
158463
158560
|
return;
|
|
158464
158561
|
}
|
|
158465
158562
|
sessionSpend = admission.spend;
|
|
158466
|
-
} else if (options.maxCostPerRunUsd && effectiveSessionId) {
|
|
158563
|
+
} else if (options.maxCostPerRunUsd !== void 0 && effectiveSessionId) {
|
|
158467
158564
|
sessionSpend = SessionSpend.track(sessionStore, effectiveSessionId);
|
|
158468
158565
|
}
|
|
158469
158566
|
const requestStore = paymentStore.getStore();
|
|
158470
158567
|
if (requestStore) requestStore.sessionSpend = sessionSpend;
|
|
158471
|
-
if (options.maxCostPerRunUsd && effectiveSessionId && !isFreeModel && (options.maxCostPerRunMode ?? "graceful") === "graceful") {
|
|
158568
|
+
if (options.maxCostPerRunUsd !== void 0 && effectiveSessionId && !isFreeModel && (options.maxCostPerRunMode ?? "graceful") === "graceful") {
|
|
158472
158569
|
const runCostUsd = sessionStore.getSessionCostUsd(effectiveSessionId);
|
|
158473
158570
|
const remainingUsd = options.maxCostPerRunUsd - runCostUsd;
|
|
158474
158571
|
const isComplexOrAgentic = hasTools || routingDecision?.tier === "COMPLEX" || routingDecision?.tier === "REASONING";
|
|
@@ -158501,7 +158598,7 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
|
|
|
158501
158598
|
}
|
|
158502
158599
|
} else if (!routingDecision && modelId && !catalog.freeIds.has(modelId)) {
|
|
158503
158600
|
const est = estimate(modelId, body.length, maxTokens);
|
|
158504
|
-
const canAfford =
|
|
158601
|
+
const canAfford = est ? Number(est) / 1e6 <= remainingUsd : remainingUsd > 0;
|
|
158505
158602
|
if (!canAfford) {
|
|
158506
158603
|
console.log(
|
|
158507
158604
|
`[ClawRouter] Budget insufficient for explicit model ${modelId} in session ${effectiveSessionId.slice(0, 8)}...: $${Math.max(0, remainingUsd).toFixed(4)} remaining \u2014 blocking (user explicitly chose ${modelId})`
|
|
@@ -158731,14 +158828,14 @@ data: [DONE]
|
|
|
158731
158828
|
modelsToTry.push(freeFallback);
|
|
158732
158829
|
}
|
|
158733
158830
|
}
|
|
158734
|
-
if (options.maxCostPerRunUsd && effectiveSessionId && !isFreeModel && (options.maxCostPerRunMode ?? "graceful") === "graceful") {
|
|
158831
|
+
if (options.maxCostPerRunUsd !== void 0 && effectiveSessionId && !isFreeModel && (options.maxCostPerRunMode ?? "graceful") === "graceful") {
|
|
158735
158832
|
const runCostUsd = sessionStore.getSessionCostUsd(effectiveSessionId);
|
|
158736
158833
|
const remainingUsd = options.maxCostPerRunUsd - runCostUsd;
|
|
158737
158834
|
const beforeFilter = [...modelsToTry];
|
|
158738
158835
|
modelsToTry = modelsToTry.filter((m) => {
|
|
158739
|
-
if (catalog.freeIds.has(m)) return true;
|
|
158836
|
+
if (catalog.freeIds.has(resolveModelAlias(m))) return true;
|
|
158740
158837
|
const est = estimate(m, body.length, maxTokens);
|
|
158741
|
-
if (!est) return
|
|
158838
|
+
if (!est) return remainingUsd > 0;
|
|
158742
158839
|
return Number(est) / 1e6 <= remainingUsd;
|
|
158743
158840
|
});
|
|
158744
158841
|
const excluded = beforeFilter.filter((m) => !modelsToTry.includes(m));
|
|
@@ -158777,14 +158874,16 @@ data: [DONE]
|
|
|
158777
158874
|
res.removeListener("close", onClientClose);
|
|
158778
158875
|
return;
|
|
158779
158876
|
}
|
|
158780
|
-
if (excluded.length > 0) {
|
|
158877
|
+
if (excluded.length > 0 && modelsToTry[0] !== beforeFilter[0]) {
|
|
158781
158878
|
const budgetSummary = remainingUsd > 0 ? `$${remainingUsd.toFixed(4)} remaining` : `budget exhausted ($${runCostUsd.toFixed(4)}/$${options.maxCostPerRunUsd})`;
|
|
158782
158879
|
console.log(
|
|
158783
158880
|
`[ClawRouter] Budget downgrade (${budgetSummary}): excluded ${excluded.join(", ")}`
|
|
158784
158881
|
);
|
|
158785
158882
|
const fromModel = excluded[0];
|
|
158786
158883
|
const usingFree = modelsToTry.length === 1 && catalog.freeIds.has(modelsToTry[0]);
|
|
158787
|
-
if (
|
|
158884
|
+
if (options.maxCostPerRunUsd === 0) {
|
|
158885
|
+
budgetDowngradeNotice = void 0;
|
|
158886
|
+
} else if (usingFree) {
|
|
158788
158887
|
budgetDowngradeNotice = `> **\u26A0\uFE0F Budget cap reached** ($${runCostUsd.toFixed(4)}/$${options.maxCostPerRunUsd}) \u2014 downgraded to free model. Quality may be reduced. Increase \`maxCostPerRun\` to continue with ${fromModel}.
|
|
158789
158888
|
|
|
158790
158889
|
`;
|
|
@@ -159695,7 +159794,7 @@ data: [DONE]
|
|
|
159695
159794
|
});
|
|
159696
159795
|
}
|
|
159697
159796
|
}
|
|
159698
|
-
var paymentStore, SOLANA_PUBLIC_RPC, BLOCKRUN_API, BLOCKRUN_SOLANA_API, BLOCKRUN_ARC_API, DESKTOP_SERVICE_TOKEN_FILE, IMAGE_DIR, AUDIO_DIR, VIDEO_DIR, AUTO_MODEL, ROUTING_PROFILES, FREE_MODELS, gatewayModelIds, FREE_MODEL, FREE_UPSTREAM_OVERRIDES, MAX_MESSAGES, CONTEXT_LIMIT_KB, HEARTBEAT_INTERVAL_MS, BALANCE_CHECK_TIMEOUT_MS, GATEWAY_CATALOG_TIMEOUT_MS, DEFAULT_REQUEST_TIMEOUT_MS, PER_MODEL_TIMEOUT_MS, REASONING_MODEL_TIMEOUT_MS, MAX_FALLBACK_ATTEMPTS, HEALTH_CHECK_TIMEOUT_MS, RATE_LIMIT_COOLDOWN_MS, OVERLOAD_COOLDOWN_MS, PORT_RETRY_ATTEMPTS, PORT_RETRY_DELAY_MS, MODEL_BODY_READ_TIMEOUT_MS, ERROR_BODY_READ_TIMEOUT_MS, ClientDisconnectedError, rateLimitedModels, overloadedModels, perProviderErrors, BALANCE_CHECK_BUFFER, BALANCE_PREFLIGHT_OUTPUT_TOKEN_CAP, PROVIDER_ERROR_PATTERNS, DEGRADED_RESPONSE_PATTERNS, DEGRADED_LOOP_PATTERNS, VALID_ROLES, ROLE_MAPPINGS, VALID_TOOL_ID_PATTERN, KIMI_BLOCK_RE, KIMI_TOKEN_RE, THINKING_TAG_RE, THINKING_BLOCK_RE, BLOCKRUN_MODEL_BY_ID, IMAGE_PRICING, IMAGE_MODEL_IDS, IMAGE_MODEL_SIZES, IMAGE_MODEL_ALIASES, VIDEO_PRICING, PHONE_PRICING, LOW_CREDIT_USD, lowCreditWarned;
|
|
159797
|
+
var paymentStore, SOLANA_PUBLIC_RPC, BLOCKRUN_API, BLOCKRUN_SOLANA_API, BLOCKRUN_ARC_API, DESKTOP_SERVICE_TOKEN_FILE, IMAGE_DIR, AUDIO_DIR, VIDEO_DIR, AUTO_MODEL, ROUTING_PROFILES, FREE_MODELS, gatewayModelIds, FREE_MODEL, FREE_UPSTREAM_OVERRIDES, MAX_MESSAGES, CONTEXT_LIMIT_KB, HEARTBEAT_INTERVAL_MS, BALANCE_CHECK_TIMEOUT_MS, GATEWAY_CATALOG_TIMEOUT_MS, DEFAULT_REQUEST_TIMEOUT_MS, PER_MODEL_TIMEOUT_MS, REASONING_MODEL_TIMEOUT_MS, MAX_FALLBACK_ATTEMPTS, HEALTH_CHECK_TIMEOUT_MS, RATE_LIMIT_COOLDOWN_MS, OVERLOAD_COOLDOWN_MS, PORT_RETRY_ATTEMPTS, PORT_RETRY_DELAY_MS, MODEL_BODY_READ_TIMEOUT_MS, ERROR_BODY_READ_TIMEOUT_MS, ClientDisconnectedError, rateLimitedModels, overloadedModels, perProviderErrors, BALANCE_CHECK_BUFFER, BALANCE_PREFLIGHT_OUTPUT_TOKEN_CAP, PROVIDER_ERROR_PATTERNS, DEGRADED_RESPONSE_PATTERNS, DEGRADED_LOOP_PATTERNS, VALID_ROLES, ROLE_MAPPINGS, VALID_TOOL_ID_PATTERN, KIMI_BLOCK_RE, KIMI_TOKEN_RE, THINKING_TAG_RE, THINKING_BLOCK_RE, BLOCKRUN_MODEL_BY_ID, IMAGE_PRICING, IMAGE_MODEL_IDS, IMAGE_MODEL_SIZES, IMAGE_MODEL_ALIASES, VIDEO_PRICING, PHONE_PRICING, LOW_CREDIT_USD, lowCreditWarned, NO_SESSION_ID, PAID_API_PATH, ZERO_CAP_FREE_READ;
|
|
159699
159798
|
var init_proxy = __esm({
|
|
159700
159799
|
"src/proxy.ts"() {
|
|
159701
159800
|
"use strict";
|
|
@@ -159763,12 +159862,14 @@ var init_proxy = __esm({
|
|
|
159763
159862
|
// coding, ~161 tok/s — on our NVIDIA key
|
|
159764
159863
|
"free/north-mini-code",
|
|
159765
159864
|
// coding, 607ms median — OpenRouter $0 pool
|
|
159865
|
+
"free/nemotron-3.5-bolt",
|
|
159866
|
+
// about a second, reads images
|
|
159766
159867
|
"free/nemotron-3-nano-omni-30b-a3b-reasoning",
|
|
159767
|
-
//
|
|
159768
|
-
"free/nemotron-3-
|
|
159868
|
+
// 256K ctx, reasoning
|
|
159869
|
+
"free/nemotron-3-super-120b",
|
|
159870
|
+
// reasoning; rescued often when capacity is short
|
|
159871
|
+
"free/nemotron-3-ultra-550b"
|
|
159769
159872
|
// largest free model, 1M ctx — but slow + flaky
|
|
159770
|
-
"free/llama-3.2-11b-vision"
|
|
159771
|
-
// only free Llama left; slowest, so last
|
|
159772
159873
|
]);
|
|
159773
159874
|
FREE_MODEL = "free/nemotron-3.5-lightning";
|
|
159774
159875
|
FREE_UPSTREAM_OVERRIDES = {
|
|
@@ -159973,9 +160074,7 @@ var init_proxy = __esm({
|
|
|
159973
160074
|
"bytedance/seedance-2.5": {
|
|
159974
160075
|
pricePerSecond: 0.315,
|
|
159975
160076
|
defaultDurationSeconds: 5
|
|
159976
|
-
}
|
|
159977
|
-
// Sora 2 via Azure AI Foundry — flat $0.10/s for both t2v and i2v.
|
|
159978
|
-
"azure/sora-2": { pricePerSecond: 0.1, defaultDurationSeconds: 4 }
|
|
160077
|
+
}
|
|
159979
160078
|
};
|
|
159980
160079
|
PHONE_PRICING = {
|
|
159981
160080
|
"phone/lookup/fraud": 0.05,
|
|
@@ -159988,6 +160087,9 @@ var init_proxy = __esm({
|
|
|
159988
160087
|
};
|
|
159989
160088
|
LOW_CREDIT_USD = 1;
|
|
159990
160089
|
lowCreditWarned = false;
|
|
160090
|
+
NO_SESSION_ID = "no-session";
|
|
160091
|
+
PAID_API_PATH = /^\/v1\/(?:partner|pm|exa|modal|stocks|usstock|crypto|fx|commodity|phone|voice)\//;
|
|
160092
|
+
ZERO_CAP_FREE_READ = /^\/v1\/(?:models|usage|balance|audio\/models|audio\/voices|images\/models|video\/models|health\/[^/]+)$/;
|
|
159991
160093
|
}
|
|
159992
160094
|
});
|
|
159993
160095
|
|
|
@@ -310503,7 +310605,7 @@ async function startProxyInBackground(api, startupGeneration) {
|
|
|
310503
310605
|
api.logger.info(`Using wallet from BLOCKRUN_WALLET_KEY: ${wallet.address}`);
|
|
310504
310606
|
}
|
|
310505
310607
|
const routingConfig = api.pluginConfig?.routing;
|
|
310506
|
-
const maxCostPerRunUsd = typeof api.pluginConfig?.maxCostPerRun === "number" ? api.pluginConfig.maxCostPerRun : void 0;
|
|
310608
|
+
const maxCostPerRunUsd = typeof api.pluginConfig?.maxCostPerRun === "number" && Number.isFinite(api.pluginConfig.maxCostPerRun) ? api.pluginConfig.maxCostPerRun : void 0;
|
|
310507
310609
|
const maxCostPerRunMode = api.pluginConfig?.maxCostPerRunMode === "strict" ? "strict" : "graceful";
|
|
310508
310610
|
if (maxCostPerRunUsd !== void 0) {
|
|
310509
310611
|
api.logger.info(
|