@blockrun/clawrouter 0.12.307 → 0.12.309

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/dist/index.js CHANGED
@@ -266387,7 +266387,8 @@ var top_models_default = [
266387
266387
  "free/north-mini-code",
266388
266388
  "free/nemotron-3-nano-omni-30b-a3b-reasoning",
266389
266389
  "free/nemotron-3-ultra-550b",
266390
- "free/llama-3.2-11b-vision",
266390
+ "free/nemotron-3.5-bolt",
266391
+ "free/nemotron-3-super-120b",
266391
266392
  "free/muse-glimmer-30b"
266392
266393
  ];
266393
266394
 
@@ -266784,10 +266785,10 @@ var MODEL_ALIASES = {
266784
266785
  "mistral-free": "free/nemotron-3.5-lightning",
266785
266786
  "glm-free": "free/nemotron-3.5-lightning",
266786
266787
  // seed-oss-36b (the prior target) EOL'd 2026-08-03
266787
- // A free Llama exists again: nemotron-super-49b (Llama-3.3-based) hit 410 on
266788
- // 2026-08-30, and a 12-model sweep of what NVIDIA still serves found Llama 3.2
266789
- // 11B Vision as the only one that finishes a real completion.
266790
- "llama-free": "free/llama-3.2-11b-vision",
266788
+ // No free Llama is left: NVIDIA deprovisioned Llama 3.2 11B Vision on 2026-11-02.
266789
+ // blockrun's /free-llama page now leads with Muse, so the shorthand follows it.
266790
+ "llama-free": "free/muse-glimmer-30b",
266791
+ // no free Llama left; Muse is Meta's open line after it
266791
266792
  // qwen3-coder-480b retired 2026-06-14 → seed-oss-36b, which then EOL'd 2026-08-03.
266792
266793
  // Follow the gateway's own retarget rather than chaining to a second dead model.
266793
266794
  "qwen-coder": "free/nemotron-3.5-lightning",
@@ -266826,11 +266827,8 @@ var MODEL_ALIASES = {
266826
266827
  // Vision-capable free models
266827
266828
  "nemotron-omni": "free/nemotron-3-nano-omni-30b-a3b-reasoning",
266828
266829
  "nano-omni": "free/nemotron-3-nano-omni-30b-a3b-reasoning",
266829
- // `vision-free` kept for backward compatibility ONLY — it still resolves to
266830
- // nano-omni, which is the strongest free model, but the free tier no longer
266831
- // claims working image input on either chain (see the catalog note). Do not
266832
- // advertise this alias as a way to get free vision.
266833
- "vision-free": "free/nemotron-3-nano-omni-30b-a3b-reasoning",
266830
+ // `vision-free` names the one free model that proved it reads images.
266831
+ "vision-free": "free/nemotron-3.5-bolt",
266834
266832
  // Retired shorthand aliases redirect to live successors. The catch-all target
266835
266833
  // moved llama-4-maverick → gpt-oss-120b (2026-07-17) → step-3.7-flash
266836
266834
  // (2026-08-29) → nemotron-3.5-lightning (2026-08-30, blockrun #448).
@@ -266838,7 +266836,8 @@ var MODEL_ALIASES = {
266838
266836
  // strongest live Nemotron
266839
266837
  "nemotron-ultra": "free/nemotron-3.5-lightning",
266840
266838
  "nemotron-253b": "free/nemotron-3.5-lightning",
266841
- "nemotron-super": "free/nemotron-3.5-lightning",
266839
+ "nemotron-super": "free/nemotron-3-super-120b",
266840
+ // now names a real free model
266842
266841
  "nemotron-49b": "free/nemotron-3.5-lightning",
266843
266842
  "nemotron-120b": "free/nemotron-3.5-lightning",
266844
266843
  devstral: "free/nemotron-3.5-lightning",
@@ -266883,6 +266882,12 @@ var MODEL_ALIASES = {
266883
266882
  // free on NVIDIA. A reasoning model: a small max_tokens is spent entirely in
266884
266883
  // reasoning and returns empty content.
266885
266884
  "nvidia/muse-glimmer-30b": "free/muse-glimmer-30b",
266885
+ "nvidia/nemotron-3.5-bolt": "free/nemotron-3.5-bolt",
266886
+ "nemotron-3.5-bolt": "free/nemotron-3.5-bolt",
266887
+ bolt: "free/nemotron-3.5-bolt",
266888
+ "nvidia/nemotron-3-super-120b": "free/nemotron-3-super-120b",
266889
+ "nemotron-3-super-120b": "free/nemotron-3-super-120b",
266890
+ "super-120b": "free/nemotron-3-super-120b",
266886
266891
  muse: "free/muse-glimmer-30b",
266887
266892
  "muse-glimmer": "free/muse-glimmer-30b",
266888
266893
  "muse-glimmer-30b": "free/muse-glimmer-30b",
@@ -268627,7 +268632,9 @@ var BLOCKRUN_MODELS = [
268627
268632
  // (Llama-3.3-based) hit NVIDIA's 410 EOL. A 12-model sweep found exactly two
268628
268633
  // survivors and only the 11B finishes a real completion. Older than the rest
268629
268634
  // of the tier and deliberately so: it is a real Llama that actually answers.
268630
- // Slowest in the tier (~18 tok/s) — last rung of the cascade.
268635
+ // Retired 2026-11-02: NVIDIA deprovisioned it and blockrun delisted it. Entry
268636
+ // kept so explicit pins stay routable;
268637
+ // off the picker, the FREE_MODELS cascade and every default.
268631
268638
  id: "free/llama-3.2-11b-vision",
268632
268639
  name: "[Free] Llama 3.2 11B Vision",
268633
268640
  version: "3.2-11b-vision",
@@ -268687,6 +268694,35 @@ var BLOCKRUN_MODELS = [
268687
268694
  maxOutput: 16384,
268688
268695
  reasoning: true
268689
268696
  },
268697
+ {
268698
+ // Nemotron 3.5 Bolt (blockrun 2026-11-04): about a second to answer, no
268699
+ // thinking pass. The one free model flagged for vision. 2026-11-05, 64x64
268700
+ // solid-colour PNGs: 8 of 8 correct across Base and Solana, and every
268701
+ // response's `model` field named Bolt itself, so no rescue did the reading.
268702
+ id: "free/nemotron-3.5-bolt",
268703
+ name: "[Free] Nemotron 3.5 Bolt",
268704
+ version: "3.5-bolt",
268705
+ inputPrice: 0,
268706
+ outputPrice: 0,
268707
+ contextWindow: 131072,
268708
+ maxOutput: 16384,
268709
+ vision: true
268710
+ },
268711
+ {
268712
+ // Nemotron 3.5 Super, served under its older 3-super-120b id (blockrun
268713
+ // 2026-11-04). Reasoning, and the gateway's redirect target for the retired
268714
+ // Llama. NO `vision`, although blockrun tags it: on 2026-11-05 only 2 of 8
268715
+ // image probes were answered by this model; the rest were rescued by
268716
+ // nano-omni or refused with a capacity 429, which proves nothing about it.
268717
+ id: "free/nemotron-3-super-120b",
268718
+ name: "[Free] Nemotron 3 Super 120B",
268719
+ version: "3-super-120b",
268720
+ inputPrice: 0,
268721
+ outputPrice: 0,
268722
+ contextWindow: 131072,
268723
+ maxOutput: 16384,
268724
+ reasoning: true
268725
+ },
268690
268726
  // ── 2026-08-30 paid catalog refresh (blockrun #449) ─────────────────────
268691
268727
  // Three additions, each probe-verified upstream with a real completion AND a
268692
268728
  // real image before listing. All three carry `vision: true` on that evidence
@@ -287416,11 +287452,15 @@ var SessionSpend = class _SessionSpend {
287416
287452
  }
287417
287453
  };
287418
287454
  var CostCapError = class extends SpendPolicyError {
287419
- constructor(reason) {
287455
+ /** A graceful-mode refusal: the budget ran out, and nothing cheaper may be swapped in. */
287456
+ budgetExhausted;
287457
+ constructor(reason, budgetExhausted = false) {
287420
287458
  super(reason);
287421
287459
  this.name = "CostCapError";
287460
+ this.budgetExhausted = budgetExhausted;
287422
287461
  }
287423
287462
  };
287463
+ var ZERO_CAP_REFUSAL = "ClawRouter cost cap: maxCostPerRun is 0, so no paid call is made";
287424
287464
 
287425
287465
  // src/compression/types.ts
287426
287466
  var DEFAULT_COMPRESSION_CONFIG = {
@@ -289909,12 +289949,14 @@ var FREE_MODELS = /* @__PURE__ */ new Set([
289909
289949
  // coding, ~161 tok/s — on our NVIDIA key
289910
289950
  "free/north-mini-code",
289911
289951
  // coding, 607ms median — OpenRouter $0 pool
289952
+ "free/nemotron-3.5-bolt",
289953
+ // about a second, reads images
289912
289954
  "free/nemotron-3-nano-omni-30b-a3b-reasoning",
289913
- // vision (text/image/video/audio)
289914
- "free/nemotron-3-ultra-550b",
289955
+ // 256K ctx, reasoning
289956
+ "free/nemotron-3-super-120b",
289957
+ // reasoning; rescued often when capacity is short
289958
+ "free/nemotron-3-ultra-550b"
289915
289959
  // largest free model, 1M ctx — but slow + flaky
289916
- "free/llama-3.2-11b-vision"
289917
- // only free Llama left; slowest, so last
289918
289960
  ]);
289919
289961
  var gatewayModelIds;
289920
289962
  async function loadGatewayCatalog(apiBase, apiKey) {
@@ -290840,9 +290882,7 @@ var VIDEO_PRICING = {
290840
290882
  "bytedance/seedance-2.5": {
290841
290883
  pricePerSecond: 0.315,
290842
290884
  defaultDurationSeconds: 5
290843
- },
290844
- // Sora 2 via Azure AI Foundry — flat $0.10/s for both t2v and i2v.
290845
- "azure/sora-2": { pricePerSecond: 0.1, defaultDurationSeconds: 4 }
290885
+ }
290846
290886
  };
290847
290887
  var PHONE_PRICING = {
290848
290888
  "phone/lookup/fraud": 0.05,
@@ -290939,7 +290979,119 @@ function gatewaySettledCostUsd(response) {
290939
290979
  if (!Number.isFinite(value) || value < 0) return void 0;
290940
290980
  return value;
290941
290981
  }
290942
- async function proxyPaidApiRequest(req, res, apiBase, payFetch, getActualPaymentUsd, accountPassthrough = false, authMode = "wallet") {
290982
+ var NO_SESSION_ID = "no-session";
290983
+ var PAID_API_PATH = /^\/v1\/(?:partner|pm|exa|modal|stocks|usstock|crypto|fx|commodity|phone|voice)\//;
290984
+ function refuseOverCostCap(res, err) {
290985
+ if (!(err instanceof CostCapError) || res.headersSent) return false;
290986
+ res.writeHead(429, {
290987
+ "Content-Type": "application/json",
290988
+ "X-ClawRouter-Cost-Cap-Exceeded": "1",
290989
+ ...err.budgetExhausted ? { "X-ClawRouter-Budget-Mode": "blocked" } : {}
290990
+ });
290991
+ res.end(
290992
+ JSON.stringify({
290993
+ error: {
290994
+ message: err.message,
290995
+ type: "cost_cap_exceeded",
290996
+ code: err.budgetExhausted ? "budget_exhausted" : "cost_cap_exceeded"
290997
+ }
290998
+ })
290999
+ );
291000
+ return true;
291001
+ }
291002
+ function capMessagesRequest(body, headers, cap) {
291003
+ let parsed = {};
291004
+ try {
291005
+ const value = JSON.parse(body.toString());
291006
+ if (value && typeof value === "object" && !Array.isArray(value)) {
291007
+ parsed = value;
291008
+ }
291009
+ } catch {
291010
+ }
291011
+ const messages = Array.isArray(parsed.messages) ? parsed.messages.filter(
291012
+ (m) => typeof m?.role === "string" && m.content !== void 0
291013
+ ) : [];
291014
+ const sessionId = getSessionId(headers) ?? deriveSessionId(messages) ?? NO_SESSION_ID;
291015
+ const store = paymentStore.getStore();
291016
+ const track = () => {
291017
+ const spend2 = SessionSpend.track(cap.sessions, sessionId);
291018
+ if (store) store.sessionSpend = spend2;
291019
+ return spend2;
291020
+ };
291021
+ const model = typeof parsed.model === "string" ? parsed.model : void 0;
291022
+ if (model !== void 0 && cap.isFree(model)) {
291023
+ track();
291024
+ return { recordSuccess: () => {
291025
+ } };
291026
+ }
291027
+ const estimate = parseMicros(
291028
+ model === void 0 ? void 0 : estimateAmount(
291029
+ resolveModelAlias(model),
291030
+ body.length,
291031
+ resolveMaxTokens(parsed),
291032
+ new Map(cap.models.map((m) => [m.id, m]))
291033
+ )
291034
+ );
291035
+ let spend;
291036
+ if (cap.mode === "strict") {
291037
+ const admission = SessionSpend.admit(
291038
+ cap.sessions,
291039
+ sessionId,
291040
+ usdToMicros(cap.usd),
291041
+ // As on the chat path: the key rail has no signing check behind this one, so
291042
+ // one micro refuses a model it can't price once the session has nothing left.
291043
+ estimate ?? (cap.authMode === "api-key" ? 1n : 0n)
291044
+ );
291045
+ if (!admission.admitted) {
291046
+ const projected = admission.spentMicros + admission.heldMicros + admission.estimateMicros;
291047
+ throw new CostCapError(
291048
+ `ClawRouter cost cap exceeded: projected spend $${microsToUsd(projected).toFixed(4)} would exceed limit $${cap.usd}`
291049
+ );
291050
+ }
291051
+ spend = admission.spend;
291052
+ if (store) store.sessionSpend = spend;
291053
+ } else {
291054
+ const remainingUsd = cap.usd - cap.sessions.getSessionCostUsd(sessionId);
291055
+ const canAfford = estimate !== void 0 ? microsToUsd(estimate) <= remainingUsd : remainingUsd > 0;
291056
+ if (!canAfford) {
291057
+ throw new CostCapError(
291058
+ `ClawRouter budget exhausted: $${Math.max(0, remainingUsd).toFixed(4)} remaining (limit: $${cap.usd}). Increase maxCostPerRun to continue.`,
291059
+ true
291060
+ );
291061
+ }
291062
+ spend = track();
291063
+ }
291064
+ return {
291065
+ recordSuccess: () => {
291066
+ if (estimate !== void 0) spend.recordSuccess(estimate);
291067
+ }
291068
+ };
291069
+ }
291070
+ var ZERO_CAP_FREE_READ = /^\/v1\/(?:models|usage|balance|audio\/models|audio\/voices|images\/models|video\/models|health\/[^/]+)$/;
291071
+ function withZeroCapGuard(inner, isFree) {
291072
+ return async (input2, init2) => {
291073
+ const { pathname } = new URL(input2 instanceof Request ? input2.url : String(input2));
291074
+ const path8 = pathname.slice(Math.max(pathname.indexOf("/v1/"), 0));
291075
+ const method = (init2?.method ?? "GET").toUpperCase();
291076
+ let allowed;
291077
+ if (/^\/v1\/(?:chat\/completions|messages)$/.test(path8)) {
291078
+ const body = init2?.body;
291079
+ let model;
291080
+ try {
291081
+ const text = typeof body === "string" ? body : body instanceof Uint8Array ? Buffer.from(body).toString() : "";
291082
+ model = JSON.parse(text).model;
291083
+ } catch {
291084
+ model = void 0;
291085
+ }
291086
+ allowed = typeof model === "string" && isFree(model);
291087
+ } else {
291088
+ allowed = ZERO_CAP_FREE_READ.test(path8) && (method === "GET" || method === "HEAD");
291089
+ }
291090
+ if (!allowed) throw new CostCapError(ZERO_CAP_REFUSAL);
291091
+ return inner(input2, init2);
291092
+ };
291093
+ }
291094
+ async function proxyPaidApiRequest(req, res, apiBase, payFetch, getActualPaymentUsd, accountPassthrough = false, authMode = "wallet", capRequest) {
290943
291095
  const startTime = Date.now();
290944
291096
  const upstreamUrl = `${apiBase}${req.url}`;
290945
291097
  const isBlockrunExa = req.url?.startsWith("/v1/exa/") ?? false;
@@ -290951,6 +291103,7 @@ async function proxyPaidApiRequest(req, res, apiBase, payFetch, getActualPayment
290951
291103
  bodyChunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
290952
291104
  }
290953
291105
  const body = Buffer.concat(bodyChunks);
291106
+ const capped = capRequest?.(body);
290954
291107
  const headers = {};
290955
291108
  for (const [key3, value] of Object.entries(req.headers)) {
290956
291109
  if (key3 === "host" || key3 === "connection" || key3 === "transfer-encoding" || key3 === "content-length")
@@ -290972,6 +291125,7 @@ async function proxyPaidApiRequest(req, res, apiBase, payFetch, getActualPayment
290972
291125
  body: body.length > 0 ? new Uint8Array(body) : void 0,
290973
291126
  signal: clientAbort.signal
290974
291127
  });
291128
+ if (upstream.ok) capped?.recordSuccess();
290975
291129
  const responseHeaders = {};
290976
291130
  upstream.headers.forEach((value, key3) => {
290977
291131
  if (key3 === "transfer-encoding" || key3 === "connection" || key3 === "content-encoding" || key3 === "content-length")
@@ -291103,6 +291257,12 @@ function assertExistingProxyBillsUs(existing, requested) {
291103
291257
  }
291104
291258
  }
291105
291259
  async function startProxy(options) {
291260
+ if (options.maxCostPerRunUsd !== void 0 && !Number.isFinite(options.maxCostPerRunUsd)) {
291261
+ console.warn(
291262
+ `[ClawRouter] Ignoring maxCostPerRun: ${String(options.maxCostPerRunUsd)} is not a finite number`
291263
+ );
291264
+ options = { ...options, maxCostPerRunUsd: void 0 };
291265
+ }
291106
291266
  const upstreamProxy = await applyUpstreamProxy(options.upstreamProxy);
291107
291267
  if (upstreamProxy) {
291108
291268
  console.log(`[ClawRouter] Upstream proxy: ${upstreamProxy}`);
@@ -291203,6 +291363,7 @@ async function startProxy(options) {
291203
291363
  const account = walletKey ? privateKeyToAccount(walletKey) : void 0;
291204
291364
  const x402 = authMode === "wallet" ? new x402Client().setSpendControls(false) : void 0;
291205
291365
  const registerCostCapHook = (client) => client.onBeforePaymentCreation(async (context) => {
291366
+ if (options.maxCostPerRunUsd === 0) throw new CostCapError(ZERO_CAP_REFUSAL);
291206
291367
  const spend = paymentStore.getStore()?.sessionSpend;
291207
291368
  if (!spend?.isStrict) return;
291208
291369
  const quote = parseQuotedAmountMicros(context.selectedRequirements);
@@ -291324,8 +291485,13 @@ async function startProxy(options) {
291324
291485
  );
291325
291486
  }
291326
291487
  const requestOptions = solanaBatch ? { ...options, _solanaBatchActive: true } : options;
291488
+ const keyFetch = apiKey ? createApiKeyFetch(apiKey, fetch, apiBase) : void 0;
291489
+ const isFreeForCap = (model) => {
291490
+ const { freeIds } = catalog.current();
291491
+ return freeIds.has(resolveModelAlias(model)) || [...freeIds].some((id2) => toUpstreamModelId(id2) === model);
291492
+ };
291327
291493
  const payFetch = authMode === "api-key" ? withSpendPolicy(
291328
- createApiKeyFetch(apiKey, fetch, apiBase),
291494
+ options.maxCostPerRunUsd === 0 ? withZeroCapGuard(keyFetch, isFreeForCap) : keyFetch,
291329
291495
  options.spendControl ?? getSharedSpendControl(),
291330
291496
  () => {
291331
291497
  const store = paymentStore.getStore();
@@ -291894,6 +292060,7 @@ async function startProxy(options) {
291894
292060
  res.end(JSON.stringify(result));
291895
292061
  } catch (err) {
291896
292062
  if (clientAbort.signal.aborted) return;
292063
+ if (refuseOverCostCap(res, err)) return;
291897
292064
  const msg = err instanceof Error ? err.message : String(err);
291898
292065
  console.error(`[ClawRouter] Image generation error: ${msg}`);
291899
292066
  if (!res.headersSent) {
@@ -292031,6 +292198,7 @@ async function startProxy(options) {
292031
292198
  res.end(JSON.stringify(result));
292032
292199
  } catch (err) {
292033
292200
  if (clientAbort.signal.aborted) return;
292201
+ if (refuseOverCostCap(res, err)) return;
292034
292202
  const msg = err instanceof Error ? err.message : String(err);
292035
292203
  console.error(`[ClawRouter] Image editing error: ${msg}`);
292036
292204
  if (!res.headersSent) {
@@ -292127,6 +292295,7 @@ async function startProxy(options) {
292127
292295
  res.end(JSON.stringify(result));
292128
292296
  } catch (err) {
292129
292297
  if (clientAbort.signal.aborted) return;
292298
+ if (refuseOverCostCap(res, err)) return;
292130
292299
  const msg = err instanceof Error ? err.message : String(err);
292131
292300
  console.error(`[ClawRouter] Audio generation error: ${msg}`);
292132
292301
  if (!res.headersSent) {
@@ -292293,6 +292462,7 @@ async function startProxy(options) {
292293
292462
  res.end(JSON.stringify(finalResult));
292294
292463
  } catch (err) {
292295
292464
  if (clientAbort.signal.aborted) return;
292465
+ if (refuseOverCostCap(res, err)) return;
292296
292466
  const msg = err instanceof Error ? err.message : String(err);
292297
292467
  console.error(`[ClawRouter] Video generation error: ${msg}`);
292298
292468
  if (!res.headersSent) {
@@ -292302,10 +292472,9 @@ async function startProxy(options) {
292302
292472
  }
292303
292473
  return;
292304
292474
  }
292305
- const isVerbatimGatewayPath = req.url === "/v1/messages" || (req.url?.startsWith("/v1/messages?") ?? false) || req.url === "/v1/audio/speech" || (req.url?.startsWith("/v1/audio/speech?") ?? false);
292306
- if (isVerbatimGatewayPath || req.url?.match(
292307
- /^\/v1\/(?:partner|pm|exa|modal|stocks|usstock|crypto|fx|commodity|phone|voice)\//
292308
- )) {
292475
+ const isMessagesPath = req.url === "/v1/messages" || (req.url?.startsWith("/v1/messages?") ?? false);
292476
+ const isVerbatimGatewayPath = isMessagesPath || req.url === "/v1/audio/speech" || (req.url?.startsWith("/v1/audio/speech?") ?? false);
292477
+ if (isVerbatimGatewayPath || req.url?.match(PAID_API_PATH)) {
292309
292478
  try {
292310
292479
  await proxyPaidApiRequest(
292311
292480
  req,
@@ -292314,9 +292483,19 @@ async function startProxy(options) {
292314
292483
  payFetch,
292315
292484
  () => paymentStore.getStore()?.amountUsd ?? 0,
292316
292485
  false,
292317
- authMode
292486
+ authMode,
292487
+ // $0 is enforced below this, where calls are signed or fetched.
292488
+ isMessagesPath && options.maxCostPerRunUsd !== void 0 && options.maxCostPerRunUsd !== 0 ? (body) => capMessagesRequest(body, req.headers, {
292489
+ usd: options.maxCostPerRunUsd,
292490
+ mode: options.maxCostPerRunMode ?? "graceful",
292491
+ authMode,
292492
+ sessions: sessionStore,
292493
+ models: catalog.current().models,
292494
+ isFree: isFreeForCap
292495
+ }) : void 0
292318
292496
  );
292319
292497
  } catch (err) {
292498
+ if (refuseOverCostCap(res, err)) return;
292320
292499
  const error62 = err instanceof Error ? err : new Error(String(err));
292321
292500
  options.onError?.(error62);
292322
292501
  if (!res.headersSent) {
@@ -292329,6 +292508,8 @@ async function startProxy(options) {
292329
292508
  } else if (!res.writableEnded) {
292330
292509
  res.end();
292331
292510
  }
292511
+ } finally {
292512
+ paymentStore.getStore()?.sessionSpend?.release();
292332
292513
  }
292333
292514
  return;
292334
292515
  }
@@ -292349,6 +292530,7 @@ async function startProxy(options) {
292349
292530
  authMode
292350
292531
  );
292351
292532
  } catch (err) {
292533
+ if (refuseOverCostCap(res, err)) return;
292352
292534
  const error62 = err instanceof Error ? err : new Error(String(err));
292353
292535
  options.onError?.(error62);
292354
292536
  if (!res.headersSent) {
@@ -293141,6 +293323,7 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
293141
293323
  }
293142
293324
  } catch (err) {
293143
293325
  if (imagegenAbort.signal.aborted) return;
293326
+ if (refuseOverCostCap(res, err)) return;
293144
293327
  const errMsg = err instanceof Error ? err.message : String(err);
293145
293328
  console.error(`[ClawRouter] /imagegen error: ${errMsg}`);
293146
293329
  if (!res.headersSent) {
@@ -293347,6 +293530,7 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
293347
293530
  sendImg2ImgText(responseText);
293348
293531
  } catch (err) {
293349
293532
  if (img2imgAbort.signal.aborted) return;
293533
+ if (refuseOverCostCap(res, err)) return;
293350
293534
  const errMsg = err instanceof Error ? err.message : String(err);
293351
293535
  console.error(`[ClawRouter] /img2img error: ${errMsg}`);
293352
293536
  if (!res.headersSent) {
@@ -293770,13 +293954,20 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
293770
293954
  }
293771
293955
  }
293772
293956
  let sessionSpend;
293773
- if (options.maxCostPerRunUsd && effectiveSessionId && !isFreeModel && (options.maxCostPerRunMode ?? "graceful") === "strict") {
293957
+ if (options.maxCostPerRunUsd !== void 0 && !effectiveSessionId) {
293958
+ effectiveSessionId = NO_SESSION_ID;
293959
+ }
293960
+ if (options.maxCostPerRunUsd !== void 0 && effectiveSessionId && !isFreeModel && (options.maxCostPerRunMode ?? "graceful") === "strict") {
293774
293961
  const thisReqEstStr = estimatedCostMicros !== void 0 ? estimatedCostMicros.toString() : modelId ? estimate(modelId, body.length, maxTokens) : void 0;
293775
293962
  const admission = SessionSpend.admit(
293776
293963
  sessionStore,
293777
293964
  effectiveSessionId,
293778
293965
  usdToMicros(options.maxCostPerRunUsd),
293779
- parseMicros(thisReqEstStr) ?? 0n
293966
+ // No local price usually means zero here: on the wallet rail the signing
293967
+ // check still reads the real quote, and eco's free rungs carry no estimate.
293968
+ // The key rail has nothing behind this check, so count one micro, which
293969
+ // refuses a model it cannot price once the session has nothing left.
293970
+ parseMicros(thisReqEstStr) ?? (options.apiKey?.trim() && !catalog.freeIds.has(resolveModelAlias(modelId ?? "")) ? 1n : 0n)
293780
293971
  );
293781
293972
  if (!admission.admitted) {
293782
293973
  const spentUsd = microsToUsd(admission.spentMicros);
@@ -293804,12 +293995,12 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
293804
293995
  return;
293805
293996
  }
293806
293997
  sessionSpend = admission.spend;
293807
- } else if (options.maxCostPerRunUsd && effectiveSessionId) {
293998
+ } else if (options.maxCostPerRunUsd !== void 0 && effectiveSessionId) {
293808
293999
  sessionSpend = SessionSpend.track(sessionStore, effectiveSessionId);
293809
294000
  }
293810
294001
  const requestStore = paymentStore.getStore();
293811
294002
  if (requestStore) requestStore.sessionSpend = sessionSpend;
293812
- if (options.maxCostPerRunUsd && effectiveSessionId && !isFreeModel && (options.maxCostPerRunMode ?? "graceful") === "graceful") {
294003
+ if (options.maxCostPerRunUsd !== void 0 && effectiveSessionId && !isFreeModel && (options.maxCostPerRunMode ?? "graceful") === "graceful") {
293813
294004
  const runCostUsd = sessionStore.getSessionCostUsd(effectiveSessionId);
293814
294005
  const remainingUsd = options.maxCostPerRunUsd - runCostUsd;
293815
294006
  const isComplexOrAgentic = hasTools || routingDecision?.tier === "COMPLEX" || routingDecision?.tier === "REASONING";
@@ -293842,7 +294033,7 @@ async function proxyRequest(req, res, apiBase, payFetch, options, routerOpts, de
293842
294033
  }
293843
294034
  } else if (!routingDecision && modelId && !catalog.freeIds.has(modelId)) {
293844
294035
  const est = estimate(modelId, body.length, maxTokens);
293845
- const canAfford = !est || Number(est) / 1e6 <= remainingUsd;
294036
+ const canAfford = est ? Number(est) / 1e6 <= remainingUsd : remainingUsd > 0;
293846
294037
  if (!canAfford) {
293847
294038
  console.log(
293848
294039
  `[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})`
@@ -294072,14 +294263,14 @@ data: [DONE]
294072
294263
  modelsToTry.push(freeFallback);
294073
294264
  }
294074
294265
  }
294075
- if (options.maxCostPerRunUsd && effectiveSessionId && !isFreeModel && (options.maxCostPerRunMode ?? "graceful") === "graceful") {
294266
+ if (options.maxCostPerRunUsd !== void 0 && effectiveSessionId && !isFreeModel && (options.maxCostPerRunMode ?? "graceful") === "graceful") {
294076
294267
  const runCostUsd = sessionStore.getSessionCostUsd(effectiveSessionId);
294077
294268
  const remainingUsd = options.maxCostPerRunUsd - runCostUsd;
294078
294269
  const beforeFilter = [...modelsToTry];
294079
294270
  modelsToTry = modelsToTry.filter((m) => {
294080
- if (catalog.freeIds.has(m)) return true;
294271
+ if (catalog.freeIds.has(resolveModelAlias(m))) return true;
294081
294272
  const est = estimate(m, body.length, maxTokens);
294082
- if (!est) return true;
294273
+ if (!est) return remainingUsd > 0;
294083
294274
  return Number(est) / 1e6 <= remainingUsd;
294084
294275
  });
294085
294276
  const excluded = beforeFilter.filter((m) => !modelsToTry.includes(m));
@@ -294118,14 +294309,16 @@ data: [DONE]
294118
294309
  res.removeListener("close", onClientClose);
294119
294310
  return;
294120
294311
  }
294121
- if (excluded.length > 0) {
294312
+ if (excluded.length > 0 && modelsToTry[0] !== beforeFilter[0]) {
294122
294313
  const budgetSummary = remainingUsd > 0 ? `$${remainingUsd.toFixed(4)} remaining` : `budget exhausted ($${runCostUsd.toFixed(4)}/$${options.maxCostPerRunUsd})`;
294123
294314
  console.log(
294124
294315
  `[ClawRouter] Budget downgrade (${budgetSummary}): excluded ${excluded.join(", ")}`
294125
294316
  );
294126
294317
  const fromModel = excluded[0];
294127
294318
  const usingFree = modelsToTry.length === 1 && catalog.freeIds.has(modelsToTry[0]);
294128
- if (usingFree) {
294319
+ if (options.maxCostPerRunUsd === 0) {
294320
+ budgetDowngradeNotice = void 0;
294321
+ } else if (usingFree) {
294129
294322
  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}.
294130
294323
 
294131
294324
  `;
@@ -307640,7 +307833,7 @@ async function startProxyInBackground(api, startupGeneration) {
307640
307833
  api.logger.info(`Using wallet from BLOCKRUN_WALLET_KEY: ${wallet.address}`);
307641
307834
  }
307642
307835
  const routingConfig = api.pluginConfig?.routing;
307643
- const maxCostPerRunUsd = typeof api.pluginConfig?.maxCostPerRun === "number" ? api.pluginConfig.maxCostPerRun : void 0;
307836
+ const maxCostPerRunUsd = typeof api.pluginConfig?.maxCostPerRun === "number" && Number.isFinite(api.pluginConfig.maxCostPerRun) ? api.pluginConfig.maxCostPerRun : void 0;
307644
307837
  const maxCostPerRunMode = api.pluginConfig?.maxCostPerRunMode === "strict" ? "strict" : "graceful";
307645
307838
  if (maxCostPerRunUsd !== void 0) {
307646
307839
  api.logger.info(
@@ -1,7 +1,7 @@
1
1
  # 9 Free AI Models, Zero Cost: How BlockRun Gives Developers Top-Tier LLMs for Nothing
2
2
 
3
3
  > **The count in this title is a snapshot, and so is every model name below.**
4
- > It was 9 when this was written; the published free tier is <!-- br:models.free -->7<!-- /br:models.free --> today, and _none_ of the
4
+ > It was 9 when this was written; the published free tier is <!-- br:models.free -->8<!-- /br:models.free --> today, and _none_ of the
5
5
  > nine originals is still in it. Free hosting is volatile — NVIDIA retired four
6
6
  > of the five visible free models in a single sweep on 2026-08-30 — so the tier
7
7
  > gets rebuilt rather than topped up. The URL keeps its original slug so existing
@@ -23,7 +23,7 @@ BlockRun's answer: just take them.
23
23
 
24
24
  ---
25
25
 
26
- ## The Lineup: <!-- br:models.free -->7<!-- /br:models.free --> Models, $0.00
26
+ ## The Lineup: <!-- br:models.free -->8<!-- /br:models.free --> Models, $0.00
27
27
 
28
28
  Through [ClawRouter](https://github.com/BlockRunAI/ClawRouter) — BlockRun's local AI routing proxy — you get zero-cost access to the following (checked against the live catalog 2026-09-29):
29
29
 
@@ -32,7 +32,9 @@ Through [ClawRouter](https://github.com/BlockRunAI/ClawRouter) — BlockRun's lo
32
32
  | **Nemotron 3.5 Lightning** | 1M | ✅ | The free default — thinking-mode reasoning |
33
33
  | **Nemotron 3 Ultra 550B** | 1M | ✅ | Largest free model — 550B / 55B active MoE |
34
34
  | **Nemotron 3 Nano Omni 30B** | 256K | ✅ | Strong generalist (text only in practice) |
35
- | **Llama 3.2 11B Vision** | 128K | — | Meta Llama (text only in practice) |
35
+ | **Nemotron 3 Super 120B** | 131K | ✅ | Reasoning |
36
+ | **Nemotron 3.5 Bolt** | 131K | — | About a second to answer, reads images |
37
+ | **Muse Glimmer 30B** | 131K | ✅ | Meta's open model, text only |
36
38
  | **Cohere North Mini Code** | 256K | ✅ | Coding, sub-second responses |
37
39
  | **Poolside Laguna XS 2.1** | 131K | — | Coding, ~161 tok/s |
38
40
 
@@ -110,11 +112,23 @@ A 30B-A3B mixture-of-experts model with a **1M-token context** and thinking-mode
110
112
 
111
113
  **Best for:** General reasoning at 256K context, for free.
112
114
 
113
- ### Llama 3.2 11B Vision — The Free Llama
115
+ ### Nemotron 3.5 Bolt — The One That Reads Images
114
116
 
115
- Meta's Llama 3.2 11B with a 128K window. It is older than everything else here, and that is the point: a 12-model sweep of what NVIDIA still serves free found this was the only Llama that actually finishes a real completion. The name promises image input; the gateway does not deliver it (see below).
117
+ Small and fast: about a second to answer, 131K context, no thinking pass. It's the only free model ClawRouter flags for vision, having got 8 of 8 right on solid-colour PNGs across Base and Solana.
116
118
 
117
- **Best for:** Anyone who needs a Llama specifically.
119
+ **Best for:** Quick answers, and image turns you don't want to pay for.
120
+
121
+ ### Nemotron 3 Super 120B — The Other Reasoner
122
+
123
+ 12B active parameters with thinking mode and a 131K window. Under heavy load the gateway often answers from another free model instead, so check the response's `model` field if it matters which one replied.
124
+
125
+ **Best for:** Reasoning when your prompt fits in 131K.
126
+
127
+ ### Muse Glimmer 30B — The Free Meta Model
128
+
129
+ Meta's open line after Llama, 29.6B dense with a 131K window. It's a reasoning model, so give it a real token budget: at 300 `max_tokens` it can spend everything on reasoning and return an empty answer. Text only. NVIDIA retired the last free Llama on 2026-11-02, so this is the closest free option.
130
+
131
+ **Best for:** Anyone who wants a free Meta model.
118
132
 
119
133
  ### Cohere North Mini Code — The Fast Coder
120
134
 
@@ -170,8 +184,10 @@ If you're using Claude Code, one command switches you to any free model:
170
184
  ```
171
185
  /model free → Nemotron 3.5 Lightning (1M ctx, the default)
172
186
  /model ultra-550b → Nemotron 3 Ultra 550B (largest)
173
- /model vision-free → Nemotron 3 Nano Omni (text only, see below)
174
- /model llama-vision → Llama 3.2 11B Vision (text only, see below)
187
+ /model vision-free → Nemotron 3.5 Bolt (reads images)
188
+ /model nemotron-omni → Nemotron 3 Nano Omni (text only, see below)
189
+ /model super-120b → Nemotron 3 Super 120B
190
+ /model muse → Muse Glimmer 30B
175
191
  /model north-mini → Cohere North Mini Code
176
192
  /model laguna → Poolside Laguna XS 2.1
177
193
  ```
@@ -190,13 +206,13 @@ The gateway will return structured tool calls from these models, but ClawRouter
190
206
 
191
207
  ### 2. Reasoning Has a Ceiling
192
208
 
193
- Four of the six are reasoning-capable and handle most tasks well. On the hardest problems — competition-level math, formal proofs, deep multi-step planning — they don't match Claude Opus 5 or Sonnet 5. That's why ClawRouter's REASONING tier doesn't use free models.
209
+ Six of the eight are reasoning-capable and handle most tasks well. On the hardest problems — competition-level math, formal proofs, deep multi-step planning — they don't match Claude Opus 5 or Sonnet 5. That's why ClawRouter's REASONING tier doesn't use free models.
194
210
 
195
- ### 3. There Is No Working Free Vision
211
+ ### 3. Only One Free Model Reads Images Reliably
196
212
 
197
- Two of the six are catalogued as vision-capable, and neither survives a real probe. On a 64×64 solid-red PNG, `nemotron-3-nano-omni` answered correctly 1 time in 4 on Base and returned "white" on Solana — where the response's own `model` field revealed a silent fallback to a text model. `llama-3.2-11b-vision` replied "I'm unable to see the image" on 3 of 3 attempts while answering plain text fine. Every one of those failures is an **HTTP 200**: the image is dropped and a confident wrong answer comes back with no error to branch on.
213
+ `nemotron-3.5-bolt` got 8 of 8 right on 64×64 solid-colour PNGs across Base and Solana on 2026-11-05. The others don't hold up the same way: `nemotron-3-nano-omni` answered correctly 1 time in 4 on Base in August, and only 2 of 8 probes of `nemotron-3-super-120b` were answered by that model.
198
214
 
199
- ClawRouter therefore ships no `vision` flag on any free model, so requests carrying an image route to a paid vision model instead. The general lesson is worth more than the specific finding: **a catalog's capability list is a claim, not a measurement** — and one passing sample is not a measurement either. The first probe here returned the right colour; it took four to see that was luck.
215
+ ClawRouter therefore flags only Bolt for vision. Pin it with `/model vision-free`; otherwise requests carrying an image route to a paid vision model. The general lesson is worth more than the specific finding: **a catalog's capability list is a claim, not a measurement** — and one passing sample is not a measurement either. The first probe here returned the right colour; it took four to see that was luck.
200
216
 
201
217
  ### 4. Free Hosting Is Volatile
202
218
 
@@ -216,7 +232,8 @@ Code generation → North Mini Code or Laguna XS 2.1
216
232
  Reasoning required → Nemotron 3.5 Lightning (1M ctx)
217
233
  Hardest free reasoning → Nemotron 3 Ultra 550B
218
234
  Long-context reasoning → Nemotron 3.5 Lightning (1M)
219
- A Llama specifically → Llama 3.2 11B Vision
235
+ Free image turns → Nemotron 3.5 Bolt
236
+ A free Meta model → Muse Glimmer 30B
220
237
  ```
221
238
 
222
239
  ### Strategy 2: Free for 80%, Paid for 20%
@@ -236,13 +253,13 @@ Look at the cost trajectory over the past three years:
236
253
  - **2023:** GPT-4 dominates alone at $30/$60 per M tokens
237
254
  - **2024:** Open-source models surge, prices halve repeatedly
238
255
  - **2025:** DeepSeek, Qwen push top-tier inference below $1/M
239
- - **2026:** BlockRun offers <!-- br:models.free -->7<!-- /br:models.free --> free models through a single API
256
+ - **2026:** BlockRun offers <!-- br:models.free -->8<!-- /br:models.free --> free models through a single API
240
257
 
241
258
  **A free tier that gets rebuilt rather than retired isn't just a product feature — it's a signal.** Baseline AI capability is becoming infrastructure. Like internet bandwidth before it, the cost of "good enough" AI inference is converging toward zero.
242
259
 
243
260
  BlockRun and ClawRouter exist to be the **routing layer** in this transition: not locked to any single provider, not bound to any single model, always giving developers the lowest-cost path to the right capability.
244
261
 
245
- Today it's <!-- br:models.free -->7<!-- /br:models.free --> free models, and they are not the same seven as last month. Tomorrow it could be 50. Prices will only drop. Capabilities will only improve. The names will keep churning.
262
+ Today it's <!-- br:models.free -->8<!-- /br:models.free --> free models, and they are not the same seven as last month. Tomorrow it could be 50. Prices will only drop. Capabilities will only improve. The names will keep churning.
246
263
 
247
264
  **The one constant: your code doesn't need to change.**
248
265
 
@@ -257,7 +274,7 @@ clawrouter start
257
274
 
258
275
  Point your `base_url` to `http://localhost:8402/v1`. That's the whole setup.
259
276
 
260
- <!-- br:models.free -->7<!-- /br:models.free --> free models. Up to 1M context. Unlimited calls. Zero cost.
277
+ <!-- br:models.free -->8<!-- /br:models.free --> free models. Up to 1M context. Unlimited calls. Zero cost.
261
278
 
262
279
  Go build something.
263
280