@blockrun/llm 3.26.4 → 4.0.0

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 CHANGED
@@ -44,7 +44,7 @@ console.log(r.response); // the proof
44
44
  ## Why This SDK
45
45
 
46
46
  - 🧠 **Smart routing that pays for itself.** The bundled [Router Core V3](https://github.com/BlockRunAI/router-core) engine (shared with [ClawRouter](https://github.com/BlockRunAI/ClawRouter)) classifies every request locally in <1ms across <!-- br:clawrouter.dimensions -->15<!-- /br:clawrouter.dimensions --> dimensions and routes to the cheapest capable model.
47
- - 🆓 **<!-- br:models.free -->8<!-- /br:models.free --> genuinely free models.** $0 in and out, including two 1M-context Nemotrons, two that accept images, and free coding models from Cohere and Poolside.
47
+ - 🆓 **<!-- br:models.free -->9<!-- /br:models.free --> genuinely free models.** $0 in and out, including two 1M-context Nemotrons, two that accept images, and free coding models from Cohere and Poolside.
48
48
  - 🔐 **Two ways to connect.** A **BlockRun API key** billed against account credit ([sign up](https://user.blockrun.ai), [create a key](https://user.blockrun.ai/dashboard/keys), [add credit](https://user.blockrun.ai/dashboard/credits)), or a wallet signature with x402 micropayments and no account at all. Same code either way.
49
49
  - 💸 **Pay per request in USDC.** x402 micropayments on Solana, Base or Arc. Agents can fund and pay their own way.
50
50
  - 🛡️ **Automatic failover.** Transient errors (timeouts, 429, 5xx) before payment walk the router's ranked fallback chain instead of failing your request; a failure after a payment was sent never buys a second model.
@@ -57,7 +57,7 @@ console.log(r.response); // the proof
57
57
  | ------------------ | -------------- | ----------------- | ---------------- | ----------------------------------------------------------------------- |
58
58
  | **Cost routing** | ✗ one vendor | Manual selection | Manual selection | **Automatic — <!-- br:savings.autoVsBaselinePct -->84<!-- /br:savings.autoVsBaselinePct -->% cheaper** |
59
59
  | **Models** | GPT only | 200+ | 100+ (BYO keys) | **<!-- br:models.chatVisible -->91<!-- /br:models.chatVisible -->, one credential** |
60
- | **Free tier** | ✗ | Rate-limited | ✗ | **<!-- br:models.free -->8<!-- /br:models.free --> models, no signup** |
60
+ | **Free tier** | ✗ | Rate-limited | ✗ | **<!-- br:models.free -->9<!-- /br:models.free --> models, no signup** |
61
61
  | **Auth** | API key | Account + API key | Your API keys | **API key *or* wallet signature** |
62
62
  | **Payment** | Card + invoice | Credit card | BYO keys | **Account credit or USDC per-request** |
63
63
  | **Agent-ready** | ✗ | ✗ | ✗ | **✓ — one key, or agents fund their own wallet** |
@@ -351,7 +351,7 @@ const reply = await client.chat('nvidia/nemotron-3.5-lightning', 'hello', {
351
351
 
352
352
  | Profile | Strategy | Savings vs Opus 5 | Best For |
353
353
  |---------|----------|-------------------|----------|
354
- | `eco` | Cheapest capable model — ranks the <!-- br:models.free -->8<!-- /br:models.free -->-model free tier first | **<!-- br:savings.ecoVsBaselinePct -->98<!-- /br:savings.ecoVsBaselinePct -->%** | Cost-sensitive production, zero-cost testing |
354
+ | `eco` | Cheapest capable model — ranks the <!-- br:models.free -->9<!-- /br:models.free -->-model free tier first | **<!-- br:savings.ecoVsBaselinePct -->98<!-- /br:savings.ecoVsBaselinePct -->%** | Cost-sensitive production, zero-cost testing |
355
355
  | `auto` | Best balance of cost and quality (default) | **<!-- br:savings.autoVsBaselinePct -->84<!-- /br:savings.autoVsBaselinePct -->%** | General use |
356
356
  | `premium` | Highest-quality model per tier | 0% | Quality-critical tasks |
357
357
 
@@ -703,7 +703,7 @@ operator to sign vouchers against the channel, up to `maxDeposit`.
703
703
  Batch mode needs three more optional peers on top of the Solana ones:
704
704
 
705
705
  ```bash
706
- npm install @x402/core@~2.28.0 @x402/svm@~2.28.0 @solana/kit
706
+ npm install @x402/core@~2.30.0 @x402/svm@~2.30.0 @solana/kit@^8
707
707
  ```
708
708
 
709
709
  ```typescript
package/dist/index.cjs CHANGED
@@ -4828,6 +4828,17 @@ async function loadSplToken(what) {
4828
4828
  }
4829
4829
  }
4830
4830
 
4831
+ // src/bs58.ts
4832
+ var import_bs58 = __toESM(require("bs58"), 1);
4833
+ function unwrapBs58(mod) {
4834
+ const m = mod;
4835
+ if (typeof m?.encode === "function") return m;
4836
+ const inner = m?.default;
4837
+ if (typeof inner?.encode === "function") return inner;
4838
+ throw new Error("bs58: no encode() on the module or its default export");
4839
+ }
4840
+ var bs58 = unwrapBs58(import_bs58.default);
4841
+
4831
4842
  // src/x402.ts
4832
4843
  var BASE_CHAIN_ID = 8453;
4833
4844
  var USDC_BASE = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
@@ -4910,6 +4921,15 @@ async function getBlockhashEntry(connection, rpcUrl, forceRefresh) {
4910
4921
  trimOldest(blockhashCache, MAX_TRACKED_ENDPOINTS);
4911
4922
  return entry;
4912
4923
  }
4924
+ function quotedBlockhash(extra) {
4925
+ const value = extra?.recentBlockhash;
4926
+ if (typeof value !== "string" || value.length === 0) return null;
4927
+ try {
4928
+ return bs58.decode(value).length === 32 ? value : null;
4929
+ } catch {
4930
+ return null;
4931
+ }
4932
+ }
4913
4933
  var TRANSFER_TYPES = {
4914
4934
  TransferWithAuthorization: [
4915
4935
  { name: "from", type: "address" },
@@ -5046,7 +5066,8 @@ async function createSolanaPaymentPayload(secretKey, fromAddress, recipient, amo
5046
5066
  }
5047
5067
  return null;
5048
5068
  };
5049
- let entry = await getBlockhashEntry(connection, rpcUrl, options.forceFreshBlockhash ?? false);
5069
+ const quoted = quotedBlockhash(options.extra);
5070
+ let entry = quoted ? { blockhash: quoted, fetchedAt: Date.now() } : await getBlockhashEntry(connection, rpcUrl, options.forceFreshBlockhash ?? false);
5050
5071
  let serializedTx = findDistinctTx(entry);
5051
5072
  if (serializedTx === null) {
5052
5073
  entry = await getBlockhashEntry(connection, rpcUrl, true);
@@ -5181,7 +5202,7 @@ function getCostSummary() {
5181
5202
  }
5182
5203
 
5183
5204
  // src/version.ts
5184
- var SDK_VERSION = "3.26.4";
5205
+ var SDK_VERSION = "4.0.0";
5185
5206
  var USER_AGENT = `blockrun-ts/${SDK_VERSION}`;
5186
5207
 
5187
5208
  // src/client.ts
@@ -9816,7 +9837,7 @@ function sleep(ms) {
9816
9837
  // src/wallet.ts
9817
9838
  var import_accounts16 = require("viem/accounts");
9818
9839
 
9819
- // node_modules/.pnpm/@blockrun+core@0.1.1_bufferutil@4.1.0_typescript@6.0.3_utf-8-validate@6.0.6_zod@3.25.76/node_modules/@blockrun/core/dist/config.js
9840
+ // node_modules/.pnpm/@blockrun+core@0.1.1_bufferutil@4.1.0_typescript@6.0.3_utf-8-validate@6.0.6_zod@4.6.7/node_modules/@blockrun/core/dist/config.js
9820
9841
  var fs2 = __toESM(require("fs"), 1);
9821
9842
  var os2 = __toESM(require("os"), 1);
9822
9843
  var path2 = __toESM(require("path"), 1);
@@ -9838,7 +9859,7 @@ function paths() {
9838
9859
  };
9839
9860
  }
9840
9861
 
9841
- // node_modules/.pnpm/@blockrun+core@0.1.1_bufferutil@4.1.0_typescript@6.0.3_utf-8-validate@6.0.6_zod@3.25.76/node_modules/@blockrun/core/dist/wallet.js
9862
+ // node_modules/.pnpm/@blockrun+core@0.1.1_bufferutil@4.1.0_typescript@6.0.3_utf-8-validate@6.0.6_zod@4.6.7/node_modules/@blockrun/core/dist/wallet.js
9842
9863
  var fs3 = __toESM(require("fs"), 1);
9843
9864
  var path3 = __toESM(require("path"), 1);
9844
9865
  var import_accounts15 = require("viem/accounts");
@@ -10307,19 +10328,6 @@ async function getOrCreateSolanaWallet() {
10307
10328
 
10308
10329
  // src/poll-ownership.ts
10309
10330
  var import_crypto = require("crypto");
10310
-
10311
- // src/bs58.ts
10312
- var import_bs58 = __toESM(require("bs58"), 1);
10313
- function unwrapBs58(mod) {
10314
- const m = mod;
10315
- if (typeof m?.encode === "function") return m;
10316
- const inner = m?.default;
10317
- if (typeof inner?.encode === "function") return inner;
10318
- throw new Error("bs58: no encode() on the module or its default export");
10319
- }
10320
- var bs58 = unwrapBs58(import_bs58.default);
10321
-
10322
- // src/poll-ownership.ts
10323
10331
  var POLL_AUTH_HEADERS = {
10324
10332
  wallet: "x-poll-wallet",
10325
10333
  timestamp: "x-poll-timestamp",
@@ -10429,7 +10437,7 @@ var BatchChannelLockedError = class extends BlockrunError {
10429
10437
  withDisposition(this, "unpaid");
10430
10438
  }
10431
10439
  };
10432
- var INSTALL_HINT2 = "npm install @x402/core@~2.28.0 @x402/svm@~2.28.0 @solana/kit";
10440
+ var INSTALL_HINT2 = "npm install @x402/core@~2.30.0 @x402/svm@~2.30.0 @solana/kit@^8";
10433
10441
  async function load(pkg, importer) {
10434
10442
  try {
10435
10443
  return await importer();
package/dist/index.d.cts CHANGED
@@ -2655,6 +2655,11 @@ interface CreateSolanaPaymentOptions {
2655
2655
  resourceUrl?: string;
2656
2656
  resourceDescription?: string;
2657
2657
  maxTimeoutSeconds?: number;
2658
+ /**
2659
+ * The 402 accept's `extra`, echoed back as `accepted.extra`. When it carries
2660
+ * a valid `recentBlockhash`, the transaction is signed on that blockhash
2661
+ * instead of one fetched from `rpcUrl`.
2662
+ */
2658
2663
  extra?: Record<string, unknown>;
2659
2664
  extensions?: Record<string, unknown>;
2660
2665
  rpcUrl?: string;
package/dist/index.d.ts CHANGED
@@ -2655,6 +2655,11 @@ interface CreateSolanaPaymentOptions {
2655
2655
  resourceUrl?: string;
2656
2656
  resourceDescription?: string;
2657
2657
  maxTimeoutSeconds?: number;
2658
+ /**
2659
+ * The 402 accept's `extra`, echoed back as `accepted.extra`. When it carries
2660
+ * a valid `recentBlockhash`, the transaction is signed on that blockhash
2661
+ * instead of one fetched from `rpcUrl`.
2662
+ */
2658
2663
  extra?: Record<string, unknown>;
2659
2664
  extensions?: Record<string, unknown>;
2660
2665
  rpcUrl?: string;
package/dist/index.js CHANGED
@@ -4695,6 +4695,17 @@ async function loadSplToken(what) {
4695
4695
  }
4696
4696
  }
4697
4697
 
4698
+ // src/bs58.ts
4699
+ import bs58Import from "bs58";
4700
+ function unwrapBs58(mod) {
4701
+ const m = mod;
4702
+ if (typeof m?.encode === "function") return m;
4703
+ const inner = m?.default;
4704
+ if (typeof inner?.encode === "function") return inner;
4705
+ throw new Error("bs58: no encode() on the module or its default export");
4706
+ }
4707
+ var bs58 = unwrapBs58(bs58Import);
4708
+
4698
4709
  // src/x402.ts
4699
4710
  var BASE_CHAIN_ID = 8453;
4700
4711
  var USDC_BASE = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
@@ -4777,6 +4788,15 @@ async function getBlockhashEntry(connection, rpcUrl, forceRefresh) {
4777
4788
  trimOldest(blockhashCache, MAX_TRACKED_ENDPOINTS);
4778
4789
  return entry;
4779
4790
  }
4791
+ function quotedBlockhash(extra) {
4792
+ const value = extra?.recentBlockhash;
4793
+ if (typeof value !== "string" || value.length === 0) return null;
4794
+ try {
4795
+ return bs58.decode(value).length === 32 ? value : null;
4796
+ } catch {
4797
+ return null;
4798
+ }
4799
+ }
4780
4800
  var TRANSFER_TYPES = {
4781
4801
  TransferWithAuthorization: [
4782
4802
  { name: "from", type: "address" },
@@ -4913,7 +4933,8 @@ async function createSolanaPaymentPayload(secretKey, fromAddress, recipient, amo
4913
4933
  }
4914
4934
  return null;
4915
4935
  };
4916
- let entry = await getBlockhashEntry(connection, rpcUrl, options.forceFreshBlockhash ?? false);
4936
+ const quoted = quotedBlockhash(options.extra);
4937
+ let entry = quoted ? { blockhash: quoted, fetchedAt: Date.now() } : await getBlockhashEntry(connection, rpcUrl, options.forceFreshBlockhash ?? false);
4917
4938
  let serializedTx = findDistinctTx(entry);
4918
4939
  if (serializedTx === null) {
4919
4940
  entry = await getBlockhashEntry(connection, rpcUrl, true);
@@ -5048,7 +5069,7 @@ function getCostSummary() {
5048
5069
  }
5049
5070
 
5050
5071
  // src/version.ts
5051
- var SDK_VERSION = "3.26.4";
5072
+ var SDK_VERSION = "4.0.0";
5052
5073
  var USER_AGENT = `blockrun-ts/${SDK_VERSION}`;
5053
5074
 
5054
5075
  // src/client.ts
@@ -9683,7 +9704,7 @@ function sleep(ms) {
9683
9704
  // src/wallet.ts
9684
9705
  import { privateKeyToAccount as privateKeyToAccount15, generatePrivateKey as generatePrivateKey2 } from "viem/accounts";
9685
9706
 
9686
- // node_modules/.pnpm/@blockrun+core@0.1.1_bufferutil@4.1.0_typescript@6.0.3_utf-8-validate@6.0.6_zod@3.25.76/node_modules/@blockrun/core/dist/config.js
9707
+ // node_modules/.pnpm/@blockrun+core@0.1.1_bufferutil@4.1.0_typescript@6.0.3_utf-8-validate@6.0.6_zod@4.6.7/node_modules/@blockrun/core/dist/config.js
9687
9708
  import * as fs2 from "fs";
9688
9709
  import * as os2 from "os";
9689
9710
  import * as path2 from "path";
@@ -9705,7 +9726,7 @@ function paths() {
9705
9726
  };
9706
9727
  }
9707
9728
 
9708
- // node_modules/.pnpm/@blockrun+core@0.1.1_bufferutil@4.1.0_typescript@6.0.3_utf-8-validate@6.0.6_zod@3.25.76/node_modules/@blockrun/core/dist/wallet.js
9729
+ // node_modules/.pnpm/@blockrun+core@0.1.1_bufferutil@4.1.0_typescript@6.0.3_utf-8-validate@6.0.6_zod@4.6.7/node_modules/@blockrun/core/dist/wallet.js
9709
9730
  import * as fs3 from "fs";
9710
9731
  import * as path3 from "path";
9711
9732
  import { privateKeyToAccount as privateKeyToAccount14, generatePrivateKey } from "viem/accounts";
@@ -10174,19 +10195,6 @@ async function getOrCreateSolanaWallet() {
10174
10195
 
10175
10196
  // src/poll-ownership.ts
10176
10197
  import { createPrivateKey, createPublicKey, sign as ed25519Sign } from "crypto";
10177
-
10178
- // src/bs58.ts
10179
- import bs58Import from "bs58";
10180
- function unwrapBs58(mod) {
10181
- const m = mod;
10182
- if (typeof m?.encode === "function") return m;
10183
- const inner = m?.default;
10184
- if (typeof inner?.encode === "function") return inner;
10185
- throw new Error("bs58: no encode() on the module or its default export");
10186
- }
10187
- var bs58 = unwrapBs58(bs58Import);
10188
-
10189
- // src/poll-ownership.ts
10190
10198
  var POLL_AUTH_HEADERS = {
10191
10199
  wallet: "x-poll-wallet",
10192
10200
  timestamp: "x-poll-timestamp",
@@ -10296,7 +10304,7 @@ var BatchChannelLockedError = class extends BlockrunError {
10296
10304
  withDisposition(this, "unpaid");
10297
10305
  }
10298
10306
  };
10299
- var INSTALL_HINT2 = "npm install @x402/core@~2.28.0 @x402/svm@~2.28.0 @solana/kit";
10307
+ var INSTALL_HINT2 = "npm install @x402/core@~2.30.0 @x402/svm@~2.30.0 @solana/kit@^8";
10300
10308
  async function load(pkg, importer) {
10301
10309
  try {
10302
10310
  return await importer();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockrun/llm",
3
- "version": "3.26.4",
3
+ "version": "4.0.0",
4
4
  "type": "module",
5
5
  "description": "TypeScript SDK for BlockRun - every frontier model behind one OpenAI-compatible client. Pay with a BlockRun API key or per-call in USDC. Smart routing picks the cheapest capable model. No rate limits.",
6
6
  "main": "dist/index.cjs",
@@ -60,10 +60,10 @@
60
60
  "@blockrun/core": "^0.1.0",
61
61
  "@blockrun/router-core": "https://codeload.github.com/BlockRunAI/router-core/tar.gz/273c2af0a9abe70212efbad7117b72eb3038cffc",
62
62
  "@eslint/js": "^10.0.1",
63
- "@solana/kit": "^5.5.1",
63
+ "@solana/kit": "^8.4.0",
64
64
  "@types/node": "^26.4.1",
65
- "@x402/core": "2.28.0",
66
- "@x402/svm": "2.28.0",
65
+ "@x402/core": "2.30.0",
66
+ "@x402/svm": "2.30.0",
67
67
  "eslint": "^10.9.1",
68
68
  "tsup": "^8.5.1",
69
69
  "typescript": "^6.0.3",
@@ -84,11 +84,11 @@
84
84
  },
85
85
  "packageManager": "pnpm@9.15.4",
86
86
  "peerDependencies": {
87
- "@solana/kit": ">=5.1.0",
87
+ "@solana/kit": ">=8.0.0",
88
88
  "@solana/spl-token": "^0.4.15",
89
89
  "@solana/web3.js": "^1.98.4",
90
- "@x402/core": "~2.28.0",
91
- "@x402/svm": "~2.28.0"
90
+ "@x402/core": "~2.30.0",
91
+ "@x402/svm": "~2.30.0"
92
92
  },
93
93
  "peerDependenciesMeta": {
94
94
  "@solana/kit": {