@blockrun/llm 2.12.0 → 2.13.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/dist/index.cjs CHANGED
@@ -39,6 +39,7 @@ __export(index_exports, {
39
39
  KNOWN_PROVIDERS: () => KNOWN_PROVIDERS,
40
40
  LLMClient: () => LLMClient,
41
41
  MusicClient: () => MusicClient,
42
+ NETWORK_ALIASES: () => NETWORK_ALIASES,
42
43
  OpenAI: () => OpenAI,
43
44
  PHONE_PRICES: () => PHONE_PRICES,
44
45
  PORTRAIT_ENROLLMENT_PRICE_USD: () => PORTRAIT_ENROLLMENT_PRICE_USD,
@@ -46,8 +47,11 @@ __export(index_exports, {
46
47
  PhoneClient: () => PhoneClient,
47
48
  PortraitClient: () => PortraitClient,
48
49
  PriceClient: () => PriceClient,
50
+ RPC_PRICE_USD: () => RPC_PRICE_USD,
51
+ RpcClient: () => RpcClient,
49
52
  SOLANA_NETWORK: () => SOLANA_NETWORK,
50
53
  SOLANA_WALLET_FILE_PATH: () => SOLANA_WALLET_FILE,
54
+ SUPPORTED_NETWORKS: () => SUPPORTED_NETWORKS,
51
55
  SearchClient: () => SearchClient,
52
56
  SolanaLLMClient: () => SolanaLLMClient,
53
57
  SpeechClient: () => SpeechClient,
@@ -2650,11 +2654,33 @@ var VideoClient = class {
2650
2654
  "realFaceAssetId must be a Token360 asset id matching 'ta_[A-Za-z0-9]+' (e.g. 'ta_abc123xyz')"
2651
2655
  );
2652
2656
  }
2657
+ if (options?.lastFrameUrl && !options?.imageUrl) {
2658
+ throw new Error(
2659
+ "lastFrameUrl requires imageUrl: imageUrl seeds the FIRST frame and lastFrameUrl the FINAL frame \u2014 send both."
2660
+ );
2661
+ }
2662
+ if (options?.lastFrameUrl && options?.realFaceAssetId) {
2663
+ throw new Error(
2664
+ "lastFrameUrl and realFaceAssetId are mutually exclusive; first-and-last-frame uses imageUrl + lastFrameUrl."
2665
+ );
2666
+ }
2667
+ if (options?.referenceImageUrls?.length) {
2668
+ if (options.imageUrl || options.lastFrameUrl || options.realFaceAssetId) {
2669
+ throw new Error(
2670
+ "referenceImageUrls is mutually exclusive with imageUrl, lastFrameUrl, and realFaceAssetId."
2671
+ );
2672
+ }
2673
+ if (options.referenceImageUrls.length > 9) {
2674
+ throw new Error("referenceImageUrls accepts at most 9 images.");
2675
+ }
2676
+ }
2653
2677
  const body = {
2654
2678
  model: options?.model || DEFAULT_MODEL4,
2655
2679
  prompt
2656
2680
  };
2657
2681
  if (options?.imageUrl) body.image_url = options.imageUrl;
2682
+ if (options?.lastFrameUrl) body.last_frame_url = options.lastFrameUrl;
2683
+ if (options?.referenceImageUrls?.length) body.reference_image_urls = options.referenceImageUrls;
2658
2684
  if (options?.realFaceAssetId) body.real_face_asset_id = options.realFaceAssetId;
2659
2685
  if (options?.durationSeconds !== void 0) body.duration_seconds = options.durationSeconds;
2660
2686
  if (options?.aspectRatio) body.aspect_ratio = options.aspectRatio;
@@ -4084,10 +4110,263 @@ var SurfClient = class {
4084
4110
  }
4085
4111
  };
4086
4112
 
4087
- // src/blockrun.ts
4113
+ // src/rpc.ts
4088
4114
  var import_accounts14 = require("viem/accounts");
4089
4115
  var DEFAULT_API_URL13 = "https://blockrun.ai/api";
4090
4116
  var DEFAULT_TIMEOUT13 = 6e4;
4117
+ var RPC_PRICE_USD = 2e-3;
4118
+ var SUPPORTED_NETWORKS = [
4119
+ // EVM
4120
+ "ethereum",
4121
+ "base",
4122
+ "arbitrum",
4123
+ "arbitrum-nova",
4124
+ "optimism",
4125
+ "polygon",
4126
+ "bsc",
4127
+ "avalanche",
4128
+ "fantom",
4129
+ "cronos",
4130
+ "celo",
4131
+ "gnosis",
4132
+ "zksync",
4133
+ "berachain",
4134
+ "unichain",
4135
+ "monad",
4136
+ "chiliz",
4137
+ "moonbeam",
4138
+ "aurora",
4139
+ "flare",
4140
+ "oasis",
4141
+ "kaia",
4142
+ "sonic",
4143
+ "xdc",
4144
+ "abstract",
4145
+ "hyperevm",
4146
+ "plume",
4147
+ "ronin",
4148
+ "rootstock",
4149
+ // Non-EVM (JSON-RPC-compatible)
4150
+ "solana",
4151
+ "bitcoin",
4152
+ "litecoin",
4153
+ "dogecoin",
4154
+ "bitcoin-cash",
4155
+ "near",
4156
+ "sui",
4157
+ "ripple",
4158
+ "polkadot",
4159
+ "kusama",
4160
+ "zcash"
4161
+ ];
4162
+ var NETWORK_ALIASES = {
4163
+ eth: "ethereum",
4164
+ arb: "arbitrum",
4165
+ "arbitrum-one": "arbitrum",
4166
+ "arb-one": "arbitrum",
4167
+ "arb-nova": "arbitrum-nova",
4168
+ op: "optimism",
4169
+ matic: "polygon",
4170
+ pol: "polygon",
4171
+ bnb: "bsc",
4172
+ binance: "bsc",
4173
+ "binance-smart-chain": "bsc",
4174
+ avax: "avalanche",
4175
+ ftm: "fantom",
4176
+ bera: "berachain",
4177
+ klaytn: "kaia",
4178
+ chz: "chiliz",
4179
+ hyperliquid: "hyperevm",
4180
+ rsk: "rootstock",
4181
+ sol: "solana",
4182
+ btc: "bitcoin",
4183
+ ltc: "litecoin",
4184
+ doge: "dogecoin",
4185
+ bch: "bitcoin-cash",
4186
+ xrp: "ripple",
4187
+ xrpl: "ripple",
4188
+ dot: "polkadot",
4189
+ zec: "zcash"
4190
+ };
4191
+ var RpcClient = class {
4192
+ account;
4193
+ privateKey;
4194
+ apiUrl;
4195
+ timeout;
4196
+ sessionTotalUsd = 0;
4197
+ sessionCalls = 0;
4198
+ constructor(options = {}) {
4199
+ const envKey = typeof process !== "undefined" && process.env ? process.env.BLOCKRUN_WALLET_KEY || process.env.BASE_CHAIN_WALLET_KEY : void 0;
4200
+ const privateKey = options.privateKey || envKey;
4201
+ if (!privateKey) {
4202
+ throw new Error(
4203
+ "Private key required. Pass privateKey in options or set BLOCKRUN_WALLET_KEY environment variable."
4204
+ );
4205
+ }
4206
+ validatePrivateKey(privateKey);
4207
+ this.privateKey = privateKey;
4208
+ this.account = (0, import_accounts14.privateKeyToAccount)(privateKey);
4209
+ const apiUrl = options.apiUrl || DEFAULT_API_URL13;
4210
+ validateApiUrl(apiUrl);
4211
+ this.apiUrl = apiUrl.replace(/\/$/, "");
4212
+ this.timeout = options.timeout || DEFAULT_TIMEOUT13;
4213
+ }
4214
+ /**
4215
+ * Make a single JSON-RPC 2.0 call. Flat $0.002.
4216
+ *
4217
+ * @param network - Chain name (e.g. "ethereum", "base", "solana") or a
4218
+ * common alias ("eth", "sol", "matic", ...). See
4219
+ * SUPPORTED_NETWORKS / NETWORK_ALIASES.
4220
+ * @param method - Chain RPC method, e.g. "eth_blockNumber", "eth_call",
4221
+ * "eth_getBalance" (EVM) or "getSlot", "getAccountInfo"
4222
+ * (Solana).
4223
+ * @param params - Method-specific params array (optional).
4224
+ * @returns RpcResponse with `result` (or JSON-RPC `error`), plus
4225
+ * `network`, `cacheHit` and `txHash` metadata.
4226
+ *
4227
+ * @example
4228
+ * const block = await client.call('ethereum', 'eth_blockNumber');
4229
+ * console.log(parseInt(block.result as string, 16));
4230
+ */
4231
+ async call(network, method, params) {
4232
+ const body = { jsonrpc: "2.0", id: 1, method };
4233
+ if (params !== void 0) body.params = params;
4234
+ const { data, headers } = await this.requestWithPayment(network, body);
4235
+ return this.toResponse(data, headers);
4236
+ }
4237
+ /**
4238
+ * Make a JSON-RPC 2.0 batch call. Priced per element ($0.002 x N).
4239
+ *
4240
+ * @param network - Chain name or alias (see {@link call}).
4241
+ * @param requests - Requests, each with a `method` and optional
4242
+ * `params` / `id`. `jsonrpc` and missing ids are
4243
+ * filled in automatically.
4244
+ * @returns Array of RpcResponse, in upstream order.
4245
+ *
4246
+ * @example
4247
+ * const out = await client.batch('base', [
4248
+ * { method: 'eth_blockNumber' },
4249
+ * { method: 'eth_gasPrice' },
4250
+ * ]);
4251
+ */
4252
+ async batch(network, requests) {
4253
+ if (!requests.length) {
4254
+ throw new Error("batch requires at least one request");
4255
+ }
4256
+ const body = requests.map((req, i) => {
4257
+ if (!req.method) throw new Error(`batch request ${i} is missing 'method'`);
4258
+ return { jsonrpc: "2.0", id: i + 1, ...req };
4259
+ });
4260
+ const { data, headers } = await this.requestWithPayment(network, body);
4261
+ const items = Array.isArray(data) ? data : [data];
4262
+ return items.map((item) => this.toResponse(item, headers));
4263
+ }
4264
+ toResponse(data, headers) {
4265
+ const base = data !== null && typeof data === "object" && !Array.isArray(data) ? { ...data } : { result: data };
4266
+ const network = headers.get("x-network");
4267
+ if (network) base.network = network;
4268
+ base.cacheHit = (headers.get("x-cache") || "").toUpperCase() === "HIT";
4269
+ const txHash = headers.get("x-payment-receipt") || headers.get("X-Payment-Receipt");
4270
+ if (txHash) base.txHash = txHash;
4271
+ return base;
4272
+ }
4273
+ async requestWithPayment(network, body) {
4274
+ const endpoint = `/v1/rpc/${network}`;
4275
+ const url = `${this.apiUrl}${endpoint}`;
4276
+ const response = await this.fetchWithTimeout(url, {
4277
+ method: "POST",
4278
+ headers: { "Content-Type": "application/json" },
4279
+ body: JSON.stringify(body)
4280
+ });
4281
+ if (response.status === 402) {
4282
+ return this.handlePaymentAndRetry(url, endpoint, body, response);
4283
+ }
4284
+ if (!response.ok) {
4285
+ let errorBody;
4286
+ try {
4287
+ errorBody = await response.json();
4288
+ } catch {
4289
+ errorBody = { error: "Request failed" };
4290
+ }
4291
+ throw new APIError(`API error: ${response.status}`, response.status, sanitizeErrorResponse(errorBody));
4292
+ }
4293
+ return { data: await response.json(), headers: response.headers };
4294
+ }
4295
+ async handlePaymentAndRetry(url, endpoint, body, response) {
4296
+ let paymentHeader = response.headers.get("payment-required");
4297
+ if (!paymentHeader) {
4298
+ try {
4299
+ const respBody = await response.json();
4300
+ if (respBody.x402 || respBody.accepts) {
4301
+ paymentHeader = btoa(JSON.stringify(respBody));
4302
+ }
4303
+ } catch {
4304
+ }
4305
+ }
4306
+ if (!paymentHeader) {
4307
+ throw new PaymentError("402 response but no payment requirements found");
4308
+ }
4309
+ const paymentRequired = parsePaymentRequired(paymentHeader);
4310
+ const details = extractPaymentDetails(paymentRequired);
4311
+ const paymentPayload = await createPaymentPayload(
4312
+ this.privateKey,
4313
+ this.account.address,
4314
+ details.recipient,
4315
+ details.amount,
4316
+ details.network || "eip155:8453",
4317
+ {
4318
+ resourceUrl: details.resource?.url || `${this.apiUrl}${endpoint}`,
4319
+ resourceDescription: details.resource?.description || "BlockRun Multi-chain RPC",
4320
+ maxTimeoutSeconds: details.maxTimeoutSeconds || 300,
4321
+ extra: details.extra
4322
+ }
4323
+ );
4324
+ const retryResponse = await this.fetchWithTimeout(url, {
4325
+ method: "POST",
4326
+ headers: {
4327
+ "Content-Type": "application/json",
4328
+ "PAYMENT-SIGNATURE": paymentPayload
4329
+ },
4330
+ body: JSON.stringify(body)
4331
+ });
4332
+ if (retryResponse.status === 402) {
4333
+ throw new PaymentError("Payment was rejected. Check your wallet balance.");
4334
+ }
4335
+ if (!retryResponse.ok) {
4336
+ let errorBody;
4337
+ try {
4338
+ errorBody = await retryResponse.json();
4339
+ } catch {
4340
+ errorBody = { error: "Request failed" };
4341
+ }
4342
+ throw new APIError(`API error after payment: ${retryResponse.status}`, retryResponse.status, sanitizeErrorResponse(errorBody));
4343
+ }
4344
+ this.sessionCalls++;
4345
+ const paidUsd = Number(details.amount) / 1e6;
4346
+ if (Number.isFinite(paidUsd)) this.sessionTotalUsd += paidUsd;
4347
+ return { data: await retryResponse.json(), headers: retryResponse.headers };
4348
+ }
4349
+ async fetchWithTimeout(url, options) {
4350
+ const controller = new AbortController();
4351
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
4352
+ try {
4353
+ return await fetch(url, { ...options, signal: controller.signal });
4354
+ } finally {
4355
+ clearTimeout(timeoutId);
4356
+ }
4357
+ }
4358
+ getWalletAddress() {
4359
+ return this.account.address;
4360
+ }
4361
+ getSpending() {
4362
+ return { totalUsd: this.sessionTotalUsd, calls: this.sessionCalls };
4363
+ }
4364
+ };
4365
+
4366
+ // src/blockrun.ts
4367
+ var import_accounts15 = require("viem/accounts");
4368
+ var DEFAULT_API_URL14 = "https://blockrun.ai/api";
4369
+ var DEFAULT_TIMEOUT14 = 6e4;
4091
4370
  var DEFAULT_POLL_INTERVAL_MS = 5e3;
4092
4371
  var DEFAULT_POLL_BUDGET_MS = 3e5;
4093
4372
  var MAX_SIGNED_AUTH_SECONDS = 600;
@@ -4108,11 +4387,11 @@ var BlockrunClient = class {
4108
4387
  }
4109
4388
  validatePrivateKey(privateKey);
4110
4389
  this.privateKey = privateKey;
4111
- this.account = (0, import_accounts14.privateKeyToAccount)(privateKey);
4112
- const apiUrl = options.apiUrl || DEFAULT_API_URL13;
4390
+ this.account = (0, import_accounts15.privateKeyToAccount)(privateKey);
4391
+ const apiUrl = options.apiUrl || DEFAULT_API_URL14;
4113
4392
  validateApiUrl(apiUrl);
4114
4393
  this.apiUrl = apiUrl.replace(/\/$/, "");
4115
- this.timeout = options.timeout || DEFAULT_TIMEOUT13;
4394
+ this.timeout = options.timeout || DEFAULT_TIMEOUT14;
4116
4395
  }
4117
4396
  /**
4118
4397
  * GET a BlockRun endpoint. `path` is everything after `/api` (a leading
@@ -4463,7 +4742,7 @@ function sleep(ms) {
4463
4742
  }
4464
4743
 
4465
4744
  // src/wallet.ts
4466
- var import_accounts15 = require("viem/accounts");
4745
+ var import_accounts16 = require("viem/accounts");
4467
4746
  var fs2 = __toESM(require("fs"), 1);
4468
4747
  var path2 = __toESM(require("path"), 1);
4469
4748
  var os2 = __toESM(require("os"), 1);
@@ -4472,8 +4751,8 @@ var BASE_CHAIN_ID2 = "8453";
4472
4751
  var WALLET_DIR = path2.join(os2.homedir(), ".blockrun");
4473
4752
  var WALLET_FILE = path2.join(WALLET_DIR, ".session");
4474
4753
  function createWallet() {
4475
- const privateKey = (0, import_accounts15.generatePrivateKey)();
4476
- const account = (0, import_accounts15.privateKeyToAccount)(privateKey);
4754
+ const privateKey = (0, import_accounts16.generatePrivateKey)();
4755
+ const account = (0, import_accounts16.privateKeyToAccount)(privateKey);
4477
4756
  return {
4478
4757
  address: account.address,
4479
4758
  privateKey
@@ -4529,12 +4808,12 @@ function loadWallet() {
4529
4808
  function getOrCreateWallet() {
4530
4809
  const envKey = typeof process !== "undefined" && process.env ? process.env.BLOCKRUN_WALLET_KEY || process.env.BASE_CHAIN_WALLET_KEY : void 0;
4531
4810
  if (envKey) {
4532
- const account = (0, import_accounts15.privateKeyToAccount)(envKey);
4811
+ const account = (0, import_accounts16.privateKeyToAccount)(envKey);
4533
4812
  return { address: account.address, privateKey: envKey, isNew: false };
4534
4813
  }
4535
4814
  const fileKey = loadWallet();
4536
4815
  if (fileKey) {
4537
- const account = (0, import_accounts15.privateKeyToAccount)(fileKey);
4816
+ const account = (0, import_accounts16.privateKeyToAccount)(fileKey);
4538
4817
  return { address: account.address, privateKey: fileKey, isNew: false };
4539
4818
  }
4540
4819
  const { address, privateKey } = createWallet();
@@ -4544,11 +4823,11 @@ function getOrCreateWallet() {
4544
4823
  function getWalletAddress() {
4545
4824
  const envKey = typeof process !== "undefined" && process.env ? process.env.BLOCKRUN_WALLET_KEY || process.env.BASE_CHAIN_WALLET_KEY : void 0;
4546
4825
  if (envKey) {
4547
- return (0, import_accounts15.privateKeyToAccount)(envKey).address;
4826
+ return (0, import_accounts16.privateKeyToAccount)(envKey).address;
4548
4827
  }
4549
4828
  const fileKey = loadWallet();
4550
4829
  if (fileKey) {
4551
- return (0, import_accounts15.privateKeyToAccount)(fileKey).address;
4830
+ return (0, import_accounts16.privateKeyToAccount)(fileKey).address;
4552
4831
  }
4553
4832
  return null;
4554
4833
  }
@@ -4728,7 +5007,7 @@ async function getOrCreateSolanaWallet() {
4728
5007
  // src/solana-client.ts
4729
5008
  var SOLANA_API_URL = "https://sol.blockrun.ai/api";
4730
5009
  var DEFAULT_MAX_TOKENS2 = 1024;
4731
- var DEFAULT_TIMEOUT14 = 6e4;
5010
+ var DEFAULT_TIMEOUT15 = 6e4;
4732
5011
  var SDK_VERSION2 = "0.3.0";
4733
5012
  var USER_AGENT2 = `blockrun-ts/${SDK_VERSION2}`;
4734
5013
  var DEFAULT_SOLANA_RPC_URL = "https://sol.blockrun.ai/api/v1/solana/rpc";
@@ -4778,7 +5057,7 @@ var SolanaLLMClient = class {
4778
5057
  const rpc = resolveRpcConfig(options.rpcUrl, options.rpcHeaders);
4779
5058
  this.rpcUrl = rpc.url;
4780
5059
  this.rpcHeaders = rpc.headers;
4781
- this.timeout = options.timeout || DEFAULT_TIMEOUT14;
5060
+ this.timeout = options.timeout || DEFAULT_TIMEOUT15;
4782
5061
  }
4783
5062
  /** Get Solana wallet address (public key in base58). */
4784
5063
  async getWalletAddress() {
@@ -5692,7 +5971,7 @@ var OpenAI = class {
5692
5971
  };
5693
5972
 
5694
5973
  // src/anthropic-compat.ts
5695
- var import_accounts16 = require("viem/accounts");
5974
+ var import_accounts17 = require("viem/accounts");
5696
5975
  var AnthropicClient = class {
5697
5976
  _client = null;
5698
5977
  _clientPromise = null;
@@ -5705,7 +5984,7 @@ var AnthropicClient = class {
5705
5984
  const key = options.privateKey ?? wallet.privateKey;
5706
5985
  validatePrivateKey(key);
5707
5986
  this._privateKey = key;
5708
- this._account = (0, import_accounts16.privateKeyToAccount)(this._privateKey);
5987
+ this._account = (0, import_accounts17.privateKeyToAccount)(this._privateKey);
5709
5988
  const apiUrl = options.apiUrl ?? "https://blockrun.ai/api";
5710
5989
  validateApiUrl(apiUrl);
5711
5990
  this._apiUrl = apiUrl.replace(/\/$/, "");
@@ -5810,6 +6089,7 @@ var AnthropicClient = class {
5810
6089
  KNOWN_PROVIDERS,
5811
6090
  LLMClient,
5812
6091
  MusicClient,
6092
+ NETWORK_ALIASES,
5813
6093
  OpenAI,
5814
6094
  PHONE_PRICES,
5815
6095
  PORTRAIT_ENROLLMENT_PRICE_USD,
@@ -5817,8 +6097,11 @@ var AnthropicClient = class {
5817
6097
  PhoneClient,
5818
6098
  PortraitClient,
5819
6099
  PriceClient,
6100
+ RPC_PRICE_USD,
6101
+ RpcClient,
5820
6102
  SOLANA_NETWORK,
5821
6103
  SOLANA_WALLET_FILE_PATH,
6104
+ SUPPORTED_NETWORKS,
5822
6105
  SearchClient,
5823
6106
  SolanaLLMClient,
5824
6107
  SpeechClient,
package/dist/index.d.cts CHANGED
@@ -460,6 +460,45 @@ interface VoiceInfo {
460
460
  preview_url?: string;
461
461
  [key: string]: unknown;
462
462
  }
463
+ interface RpcClientOptions {
464
+ /** EVM wallet private key (hex string starting with 0x) */
465
+ privateKey?: `0x${string}` | string;
466
+ /** API endpoint URL (default: https://blockrun.ai/api) */
467
+ apiUrl?: string;
468
+ /** Request timeout in milliseconds (default: 60000 — upstream gateway timeout is 20s) */
469
+ timeout?: number;
470
+ }
471
+ /** A JSON-RPC 2.0 error object. */
472
+ interface RpcError {
473
+ code?: number;
474
+ message?: string;
475
+ data?: unknown;
476
+ }
477
+ /**
478
+ * Response from a multi-chain JSON-RPC call.
479
+ *
480
+ * Standard JSON-RPC 2.0 envelope plus BlockRun gateway metadata pulled
481
+ * from response headers (X-Network / X-Cache / X-Payment-Receipt).
482
+ */
483
+ interface RpcResponse<T = unknown> {
484
+ jsonrpc?: string;
485
+ id?: string | number | null;
486
+ result?: T;
487
+ error?: RpcError;
488
+ /** Canonical network key, e.g. "ethereum" (from X-Network) */
489
+ network?: string;
490
+ /** Served from the gateway's method-aware cache (from X-Cache) */
491
+ cacheHit?: boolean;
492
+ /** x402 settlement tx hash (single calls) */
493
+ txHash?: string;
494
+ }
495
+ /** A single request in a JSON-RPC batch (jsonrpc/id auto-filled if omitted). */
496
+ interface RpcBatchRequest {
497
+ method: string;
498
+ params?: unknown[];
499
+ id?: string | number;
500
+ jsonrpc?: string;
501
+ }
463
502
  /** Built-in Bland.ai voice presets. Any string is accepted (custom voice IDs work too). */
464
503
  type VoicePreset = "nat" | "josh" | "maya" | "june" | "paige" | "derek" | "florian";
465
504
  /** Bland.ai conversation model tier. */
@@ -578,6 +617,22 @@ interface VideoGenerateOptions {
578
617
  * with `imageUrl`. Real-person likeness is not supported on BlockRun.
579
618
  */
580
619
  realFaceAssetId?: string;
620
+ /**
621
+ * First-and-last-frame interpolation: a second image that seeds the FINAL
622
+ * frame so the model tweens from `imageUrl` → `lastFrameUrl`. Requires
623
+ * `imageUrl` (the first frame) and a Seedance model
624
+ * (bytedance/seedance-1.5-pro, seedance-2.0, or seedance-2.0-fast).
625
+ * Priced identically to image-to-video. Mutually exclusive with
626
+ * `realFaceAssetId`.
627
+ */
628
+ lastFrameUrl?: string;
629
+ /**
630
+ * Omni / multi-reference: up to 9 reference image URLs for character/style
631
+ * consistency (**Seedance 2.0 only**). Cite them as "image 1", "image 2"
632
+ * in the prompt. Mutually exclusive with `imageUrl` / `lastFrameUrl` /
633
+ * `realFaceAssetId`.
634
+ */
635
+ referenceImageUrls?: string[];
581
636
  /** Duration to bill for (defaults to model's default duration) */
582
637
  durationSeconds?: number;
583
638
  /** Output aspect ratio. Token360 / Seedance only — silently ignored by xAI Grok. */
@@ -2296,6 +2351,125 @@ declare class SurfClient {
2296
2351
  getWalletAddress(): string;
2297
2352
  }
2298
2353
 
2354
+ /**
2355
+ * BlockRun RPC Client - Multi-chain JSON-RPC (Tatum gateway) via x402 micropayments.
2356
+ *
2357
+ * One endpoint, 40+ chains: Ethereum, Base, Solana, Polygon, BSC, Arbitrum,
2358
+ * Optimism, Avalanche, Bitcoin, Sui, and more. Standard JSON-RPC 2.0
2359
+ * passthrough — no API key, pay-per-call in USDC.
2360
+ *
2361
+ * SECURITY NOTE - Private Key Handling:
2362
+ * Your private key NEVER leaves your machine. Here's what happens:
2363
+ * 1. Key stays local - only used to sign an EIP-712 typed data message
2364
+ * 2. Only the SIGNATURE is sent in the PAYMENT-SIGNATURE header
2365
+ * 3. BlockRun verifies the signature on-chain via Coinbase CDP facilitator
2366
+ *
2367
+ * Usage:
2368
+ * import { RpcClient } from '@blockrun/llm';
2369
+ *
2370
+ * const client = new RpcClient({ privateKey: '0x...' });
2371
+ *
2372
+ * // EVM chains speak eth_* JSON-RPC
2373
+ * const block = await client.call('ethereum', 'eth_blockNumber');
2374
+ * console.log(block.result); // e.g. "0x1499f7c"
2375
+ *
2376
+ * const balance = await client.call('base', 'eth_getBalance', [
2377
+ * '0x4200000000000000000000000000000000000006',
2378
+ * 'latest',
2379
+ * ]);
2380
+ *
2381
+ * // Non-EVM chains speak their native JSON-RPC
2382
+ * const slot = await client.call('solana', 'getSlot');
2383
+ *
2384
+ * // Batch: one payment, per-element pricing ($0.002 x N)
2385
+ * const out = await client.batch('polygon', [
2386
+ * { method: 'eth_blockNumber' },
2387
+ * { method: 'eth_gasPrice' },
2388
+ * ]);
2389
+ *
2390
+ * Pricing:
2391
+ * Flat $0.002 per JSON-RPC call; a batch charges per element.
2392
+ *
2393
+ * Networks:
2394
+ * 40 curated chains (see SUPPORTED_NETWORKS) plus common aliases
2395
+ * (eth, arb, op, matic, bnb, avax, sol, btc, xrp, dot, ...). Unknown but
2396
+ * well-formed slugs fall through to a generic `{slug}-mainnet` gateway
2397
+ * attempt, so new Tatum chains work without an SDK update.
2398
+ */
2399
+
2400
+ /**
2401
+ * Flat price per JSON-RPC call (batch = N x this). Informational only —
2402
+ * the actual quote always comes from the 402 challenge.
2403
+ */
2404
+ declare const RPC_PRICE_USD = 0.002;
2405
+ /**
2406
+ * Curated chains accepted by /v1/rpc/{network}. Mirrors the backend chain
2407
+ * registry (verified live 2026-06-07). EVM chains use eth_* JSON-RPC;
2408
+ * non-EVM (Solana / UTXO / NEAR / Sui / XRP Ledger / Polkadot) speak their
2409
+ * own JSON-RPC dialect.
2410
+ */
2411
+ declare const SUPPORTED_NETWORKS: readonly ["ethereum", "base", "arbitrum", "arbitrum-nova", "optimism", "polygon", "bsc", "avalanche", "fantom", "cronos", "celo", "gnosis", "zksync", "berachain", "unichain", "monad", "chiliz", "moonbeam", "aurora", "flare", "oasis", "kaia", "sonic", "xdc", "abstract", "hyperevm", "plume", "ronin", "rootstock", "solana", "bitcoin", "litecoin", "dogecoin", "bitcoin-cash", "near", "sui", "ripple", "polkadot", "kusama", "zcash"];
2412
+ type RpcNetwork = (typeof SUPPORTED_NETWORKS)[number] | (string & {});
2413
+ /** Common short names the gateway also accepts (resolved server-side). */
2414
+ declare const NETWORK_ALIASES: Record<string, string>;
2415
+ /**
2416
+ * BlockRun Multi-chain RPC Client.
2417
+ *
2418
+ * Standard JSON-RPC 2.0 access to 40+ chains through BlockRun's Tatum
2419
+ * gateway with automatic x402 micropayments on Base chain.
2420
+ *
2421
+ * Flat $0.002 per call; a JSON-RPC batch charges per element.
2422
+ */
2423
+ declare class RpcClient {
2424
+ private account;
2425
+ private privateKey;
2426
+ private apiUrl;
2427
+ private timeout;
2428
+ private sessionTotalUsd;
2429
+ private sessionCalls;
2430
+ constructor(options?: RpcClientOptions);
2431
+ /**
2432
+ * Make a single JSON-RPC 2.0 call. Flat $0.002.
2433
+ *
2434
+ * @param network - Chain name (e.g. "ethereum", "base", "solana") or a
2435
+ * common alias ("eth", "sol", "matic", ...). See
2436
+ * SUPPORTED_NETWORKS / NETWORK_ALIASES.
2437
+ * @param method - Chain RPC method, e.g. "eth_blockNumber", "eth_call",
2438
+ * "eth_getBalance" (EVM) or "getSlot", "getAccountInfo"
2439
+ * (Solana).
2440
+ * @param params - Method-specific params array (optional).
2441
+ * @returns RpcResponse with `result` (or JSON-RPC `error`), plus
2442
+ * `network`, `cacheHit` and `txHash` metadata.
2443
+ *
2444
+ * @example
2445
+ * const block = await client.call('ethereum', 'eth_blockNumber');
2446
+ * console.log(parseInt(block.result as string, 16));
2447
+ */
2448
+ call<T = unknown>(network: RpcNetwork, method: string, params?: unknown[]): Promise<RpcResponse<T>>;
2449
+ /**
2450
+ * Make a JSON-RPC 2.0 batch call. Priced per element ($0.002 x N).
2451
+ *
2452
+ * @param network - Chain name or alias (see {@link call}).
2453
+ * @param requests - Requests, each with a `method` and optional
2454
+ * `params` / `id`. `jsonrpc` and missing ids are
2455
+ * filled in automatically.
2456
+ * @returns Array of RpcResponse, in upstream order.
2457
+ *
2458
+ * @example
2459
+ * const out = await client.batch('base', [
2460
+ * { method: 'eth_blockNumber' },
2461
+ * { method: 'eth_gasPrice' },
2462
+ * ]);
2463
+ */
2464
+ batch(network: RpcNetwork, requests: RpcBatchRequest[]): Promise<RpcResponse[]>;
2465
+ private toResponse;
2466
+ private requestWithPayment;
2467
+ private handlePaymentAndRetry;
2468
+ private fetchWithTimeout;
2469
+ getWalletAddress(): string;
2470
+ getSpending(): Spending;
2471
+ }
2472
+
2299
2473
  /**
2300
2474
  * BlockrunClient — the x402-paying HTTP primitive for the BlockRun gateway.
2301
2475
  *
@@ -3083,4 +3257,4 @@ declare function validateTemperature(temperature?: number): void;
3083
3257
  */
3084
3258
  declare function validateTopP(topP?: number): void;
3085
3259
 
3086
- export { APIError, AnthropicClient, type AudioModel, type AudioTrack, BASE_CHAIN_ID, type BarResolution, type BlockRunAnthropicOptions, BlockrunClient, type BlockrunClientOptions, BlockrunError, type CallInitiatedResponse, type CallModel, type CallOptions, type CallStatusResponse, type ChatChoice, type ChatCompletionOptions, type ChatMessage, type ChatOptions, type ChatResponse, type ChatResponseWithCost, type ChatUsage, type CostEntry, type CostEstimate, type CreatePaymentOptions, type FunctionCall, type FunctionDefinition, type HistoryOptions, ImageClient, type ImageClientOptions, type ImageData, type ImageEditOptions, type ImageGenerateOptions, type ImageModel, type ImageResponse, KNOWN_PROVIDERS, LLMClient, type LLMClientOptions, type ListOptions, type MarketSession, type Model, MusicClient, type MusicClientOptions, type MusicGenerateOptions, type MusicResponse, type NewsSearchSource, OpenAI, type OpenAIChatCompletionChoice, type OpenAIChatCompletionChunk, type OpenAIChatCompletionParams, type OpenAIChatCompletionResponse, type OpenAIClientOptions, PHONE_PRICES, PORTRAIT_ENROLLMENT_PRICE_USD, PaymentError, type PaymentLinks, type PhoneBuyOptions, type PhoneBuyResponse, PhoneClient, type PhoneClientOptions, type PhoneListResponse, type PhoneLookupResponse, type PhoneNumberRecord, type PhoneReleaseResponse, type PhoneRenewResponse, type PollOptions, PortraitClient, type PortraitClientOptions, type PortraitEnrollOptions, type PortraitEnrollResponse, type PriceBar, type PriceCategory, PriceClient, type PriceClientOptions, type PriceHistoryResponse, type PriceOptions, type PricePoint, type ResponseFormat, type RoutingDecision, type RoutingProfile, type RoutingTier, type RssSearchSource, SOLANA_NETWORK, SOLANA_WALLET_FILE as SOLANA_WALLET_FILE_PATH, SearchClient, type SearchClientOptions, type SearchOptions, type SearchParameters, type SearchResult, type SearchSource, type SearchUsage, type SmartChatOptions, type SmartChatResponse, SolanaLLMClient, type SolanaLLMClientOptions, type SolanaWalletInfo, type SoundEffectOptions, type SpeechAudio, SpeechClient, type SpeechClientOptions, type SpeechGenerateOptions, type SpeechModel, type SpeechResponse, type SpeechVoice, type Spending, type SpendingReport, type StockMarket, SurfClient, type SurfClientOptions, type SymbolListResponse, type Tool, type ToolCall, type ToolChoice, USDC_BASE, USDC_BASE_CONTRACT, USDC_SOLANA, VideoClient, type VideoClientOptions, type VideoClip, type VideoGenerateOptions, type VideoModel, type VideoResponse, VoiceClient, type VoiceClientOptions, type VoiceInfo, type VoicePreset, WALLET_DIR_PATH, WALLET_FILE_PATH, type WalletInfo, type WebSearchSource, type XArticlesRisingResponse, type XAuthorAnalyticsResponse, XClient, type XClientOptions, type XCompareAuthorsResponse, type XFollower, type XFollowersResponse, type XFollowingsResponse, type XMentionsOptions, type XMentionsResponse, type XSearchOptions, type XSearchResponse, type XSearchSource, type XTrendingResponse, type XTweet, type XTweetLookupResponse, type XTweetRepliesOptions, type XTweetRepliesResponse, type XTweetThreadResponse, type XTweetsResponse, type XUser, type XUserInfoResponse, type XUserLookupResponse, type XUserTweetsOptions, type XVerifiedFollowersResponse, clearCache, createPaymentPayload, createSolanaPaymentPayload, createSolanaWallet, createWallet, LLMClient as default, extractPaymentDetails, formatFundingMessageCompact, formatNeedsFundingMessage, formatWalletCreatedMessage, getCached, getCachedByRequest, getCostLogSummary, getCostSummary, getEip681Uri, getOrCreateSolanaWallet, getOrCreateWallet, getPaymentLinks, getWalletAddress, loadSolanaWallet, loadWallet, logCost, parsePaymentRequired, saveSolanaWallet, saveToCache, saveWallet, scanSolanaWallets, scanWallets, setCache, setupAgentSolanaWallet, setupAgentWallet, solanaClient, solanaKeyToBytes, solanaPublicKey, status, validateMaxTokens, validateModel, validateTemperature, validateTopP };
3260
+ export { APIError, AnthropicClient, type AudioModel, type AudioTrack, BASE_CHAIN_ID, type BarResolution, type BlockRunAnthropicOptions, BlockrunClient, type BlockrunClientOptions, BlockrunError, type CallInitiatedResponse, type CallModel, type CallOptions, type CallStatusResponse, type ChatChoice, type ChatCompletionOptions, type ChatMessage, type ChatOptions, type ChatResponse, type ChatResponseWithCost, type ChatUsage, type CostEntry, type CostEstimate, type CreatePaymentOptions, type FunctionCall, type FunctionDefinition, type HistoryOptions, ImageClient, type ImageClientOptions, type ImageData, type ImageEditOptions, type ImageGenerateOptions, type ImageModel, type ImageResponse, KNOWN_PROVIDERS, LLMClient, type LLMClientOptions, type ListOptions, type MarketSession, type Model, MusicClient, type MusicClientOptions, type MusicGenerateOptions, type MusicResponse, NETWORK_ALIASES, type NewsSearchSource, OpenAI, type OpenAIChatCompletionChoice, type OpenAIChatCompletionChunk, type OpenAIChatCompletionParams, type OpenAIChatCompletionResponse, type OpenAIClientOptions, PHONE_PRICES, PORTRAIT_ENROLLMENT_PRICE_USD, PaymentError, type PaymentLinks, type PhoneBuyOptions, type PhoneBuyResponse, PhoneClient, type PhoneClientOptions, type PhoneListResponse, type PhoneLookupResponse, type PhoneNumberRecord, type PhoneReleaseResponse, type PhoneRenewResponse, type PollOptions, PortraitClient, type PortraitClientOptions, type PortraitEnrollOptions, type PortraitEnrollResponse, type PriceBar, type PriceCategory, PriceClient, type PriceClientOptions, type PriceHistoryResponse, type PriceOptions, type PricePoint, RPC_PRICE_USD, type ResponseFormat, type RoutingDecision, type RoutingProfile, type RoutingTier, type RpcBatchRequest, RpcClient, type RpcClientOptions, type RpcError, type RpcNetwork, type RpcResponse, type RssSearchSource, SOLANA_NETWORK, SOLANA_WALLET_FILE as SOLANA_WALLET_FILE_PATH, SUPPORTED_NETWORKS, SearchClient, type SearchClientOptions, type SearchOptions, type SearchParameters, type SearchResult, type SearchSource, type SearchUsage, type SmartChatOptions, type SmartChatResponse, SolanaLLMClient, type SolanaLLMClientOptions, type SolanaWalletInfo, type SoundEffectOptions, type SpeechAudio, SpeechClient, type SpeechClientOptions, type SpeechGenerateOptions, type SpeechModel, type SpeechResponse, type SpeechVoice, type Spending, type SpendingReport, type StockMarket, SurfClient, type SurfClientOptions, type SymbolListResponse, type Tool, type ToolCall, type ToolChoice, USDC_BASE, USDC_BASE_CONTRACT, USDC_SOLANA, VideoClient, type VideoClientOptions, type VideoClip, type VideoGenerateOptions, type VideoModel, type VideoResponse, VoiceClient, type VoiceClientOptions, type VoiceInfo, type VoicePreset, WALLET_DIR_PATH, WALLET_FILE_PATH, type WalletInfo, type WebSearchSource, type XArticlesRisingResponse, type XAuthorAnalyticsResponse, XClient, type XClientOptions, type XCompareAuthorsResponse, type XFollower, type XFollowersResponse, type XFollowingsResponse, type XMentionsOptions, type XMentionsResponse, type XSearchOptions, type XSearchResponse, type XSearchSource, type XTrendingResponse, type XTweet, type XTweetLookupResponse, type XTweetRepliesOptions, type XTweetRepliesResponse, type XTweetThreadResponse, type XTweetsResponse, type XUser, type XUserInfoResponse, type XUserLookupResponse, type XUserTweetsOptions, type XVerifiedFollowersResponse, clearCache, createPaymentPayload, createSolanaPaymentPayload, createSolanaWallet, createWallet, LLMClient as default, extractPaymentDetails, formatFundingMessageCompact, formatNeedsFundingMessage, formatWalletCreatedMessage, getCached, getCachedByRequest, getCostLogSummary, getCostSummary, getEip681Uri, getOrCreateSolanaWallet, getOrCreateWallet, getPaymentLinks, getWalletAddress, loadSolanaWallet, loadWallet, logCost, parsePaymentRequired, saveSolanaWallet, saveToCache, saveWallet, scanSolanaWallets, scanWallets, setCache, setupAgentSolanaWallet, setupAgentWallet, solanaClient, solanaKeyToBytes, solanaPublicKey, status, validateMaxTokens, validateModel, validateTemperature, validateTopP };