@blockrun/llm 2.11.1 → 2.12.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.js CHANGED
@@ -2295,11 +2295,210 @@ var MusicClient = class {
2295
2295
  }
2296
2296
  };
2297
2297
 
2298
- // src/video.ts
2298
+ // src/speech.ts
2299
2299
  import { privateKeyToAccount as privateKeyToAccount4 } from "viem/accounts";
2300
2300
  var DEFAULT_API_URL4 = "https://blockrun.ai/api";
2301
- var DEFAULT_MODEL3 = "xai/grok-imagine-video";
2301
+ var DEFAULT_MODEL3 = "elevenlabs/flash-v2.5";
2302
+ var DEFAULT_SOUNDFX_MODEL = "elevenlabs/sound-effects";
2302
2303
  var DEFAULT_TIMEOUT4 = 12e4;
2304
+ var SpeechClient = class {
2305
+ account;
2306
+ privateKey;
2307
+ apiUrl;
2308
+ timeout;
2309
+ sessionTotalUsd = 0;
2310
+ sessionCalls = 0;
2311
+ constructor(options = {}) {
2312
+ const envKey = typeof process !== "undefined" && process.env ? process.env.BLOCKRUN_WALLET_KEY || process.env.BASE_CHAIN_WALLET_KEY : void 0;
2313
+ const privateKey = options.privateKey || envKey;
2314
+ if (!privateKey) {
2315
+ throw new Error(
2316
+ "Private key required. Pass privateKey in options or set BLOCKRUN_WALLET_KEY environment variable."
2317
+ );
2318
+ }
2319
+ validatePrivateKey(privateKey);
2320
+ this.privateKey = privateKey;
2321
+ this.account = privateKeyToAccount4(privateKey);
2322
+ const apiUrl = options.apiUrl || DEFAULT_API_URL4;
2323
+ validateApiUrl(apiUrl);
2324
+ this.apiUrl = apiUrl.replace(/\/$/, "");
2325
+ this.timeout = options.timeout || DEFAULT_TIMEOUT4;
2326
+ }
2327
+ /**
2328
+ * Synthesize speech from text (OpenAI-compatible TTS).
2329
+ *
2330
+ * Price scales with character count: (chars / 1000) x model rate,
2331
+ * minimum $0.001/request. Synthesis is synchronous.
2332
+ *
2333
+ * @param input - Text to synthesize. Per-model character caps apply
2334
+ * (flash/turbo 40k, multilingual-v2 10k, v3 5k).
2335
+ * @param options - Optional model / voice / format / speed
2336
+ * @returns SpeechResponse with audio URL, format, and character count
2337
+ *
2338
+ * @example
2339
+ * const result = await client.generate('Welcome to BlockRun.', { voice: 'george' });
2340
+ * console.log(result.data[0].url); // audio URL (mp3 by default)
2341
+ */
2342
+ async generate(input, options) {
2343
+ const body = {
2344
+ model: options?.model || DEFAULT_MODEL3,
2345
+ input
2346
+ };
2347
+ if (options?.voice) body.voice = options.voice;
2348
+ if (options?.responseFormat) body.response_format = options.responseFormat;
2349
+ if (options?.speed !== void 0) body.speed = options.speed;
2350
+ return this.requestWithPayment("/v1/audio/speech", body);
2351
+ }
2352
+ /** OpenAI-style alias for {@link generate}. */
2353
+ speak(input, options) {
2354
+ return this.generate(input, options);
2355
+ }
2356
+ /**
2357
+ * Generate a cinematic sound effect from a text prompt.
2358
+ *
2359
+ * Flat $0.05/generation, up to 22 seconds of audio.
2360
+ *
2361
+ * @param text - Sound effect description (max 1000 chars).
2362
+ * E.g. 'rain on a tin roof', 'sci-fi door whoosh'
2363
+ * @param options - Optional duration / prompt influence / format
2364
+ * @returns SpeechResponse with audio URL and format
2365
+ *
2366
+ * @example
2367
+ * const fx = await client.soundEffect('crackling campfire at night');
2368
+ * console.log(fx.data[0].url);
2369
+ */
2370
+ async soundEffect(text, options) {
2371
+ const body = {
2372
+ model: options?.model || DEFAULT_SOUNDFX_MODEL,
2373
+ text
2374
+ };
2375
+ if (options?.durationSeconds !== void 0) body.duration_seconds = options.durationSeconds;
2376
+ if (options?.promptInfluence !== void 0) body.prompt_influence = options.promptInfluence;
2377
+ if (options?.responseFormat) body.response_format = options.responseFormat;
2378
+ return this.requestWithPayment("/v1/audio/sound-effects", body);
2379
+ }
2380
+ /**
2381
+ * List available voices for TTS (free, rate-limited 60 req/min/IP).
2382
+ *
2383
+ * Pass a voice's `alias` (if present) or `voice_id` as the `voice`
2384
+ * option to {@link generate}.
2385
+ */
2386
+ async listVoices() {
2387
+ const response = await this.fetchWithTimeout(`${this.apiUrl}/v1/audio/voices`, {
2388
+ method: "GET"
2389
+ });
2390
+ if (!response.ok) {
2391
+ let errorBody;
2392
+ try {
2393
+ errorBody = await response.json();
2394
+ } catch {
2395
+ errorBody = { error: "Request failed" };
2396
+ }
2397
+ throw new APIError(`API error: ${response.status}`, response.status, sanitizeErrorResponse(errorBody));
2398
+ }
2399
+ const payload = await response.json();
2400
+ return payload.data || [];
2401
+ }
2402
+ async requestWithPayment(endpoint, body) {
2403
+ const url = `${this.apiUrl}${endpoint}`;
2404
+ const response = await this.fetchWithTimeout(url, {
2405
+ method: "POST",
2406
+ headers: { "Content-Type": "application/json" },
2407
+ body: JSON.stringify(body)
2408
+ });
2409
+ if (response.status === 402) {
2410
+ return this.handlePaymentAndRetry(url, endpoint, body, response);
2411
+ }
2412
+ if (!response.ok) {
2413
+ let errorBody;
2414
+ try {
2415
+ errorBody = await response.json();
2416
+ } catch {
2417
+ errorBody = { error: "Request failed" };
2418
+ }
2419
+ throw new APIError(`API error: ${response.status}`, response.status, sanitizeErrorResponse(errorBody));
2420
+ }
2421
+ return response.json();
2422
+ }
2423
+ async handlePaymentAndRetry(url, endpoint, body, response) {
2424
+ let paymentHeader = response.headers.get("payment-required");
2425
+ if (!paymentHeader) {
2426
+ try {
2427
+ const respBody = await response.json();
2428
+ if (respBody.x402 || respBody.accepts) {
2429
+ paymentHeader = btoa(JSON.stringify(respBody));
2430
+ }
2431
+ } catch {
2432
+ }
2433
+ }
2434
+ if (!paymentHeader) {
2435
+ throw new PaymentError("402 response but no payment requirements found");
2436
+ }
2437
+ const paymentRequired = parsePaymentRequired(paymentHeader);
2438
+ const details = extractPaymentDetails(paymentRequired);
2439
+ const paymentPayload = await createPaymentPayload(
2440
+ this.privateKey,
2441
+ this.account.address,
2442
+ details.recipient,
2443
+ details.amount,
2444
+ details.network || "eip155:8453",
2445
+ {
2446
+ resourceUrl: details.resource?.url || `${this.apiUrl}${endpoint}`,
2447
+ resourceDescription: details.resource?.description || "BlockRun Voice",
2448
+ maxTimeoutSeconds: details.maxTimeoutSeconds || 300,
2449
+ extra: details.extra
2450
+ }
2451
+ );
2452
+ const retryResponse = await this.fetchWithTimeout(url, {
2453
+ method: "POST",
2454
+ headers: {
2455
+ "Content-Type": "application/json",
2456
+ "PAYMENT-SIGNATURE": paymentPayload
2457
+ },
2458
+ body: JSON.stringify(body)
2459
+ });
2460
+ if (retryResponse.status === 402) {
2461
+ throw new PaymentError("Payment was rejected. Check your wallet balance.");
2462
+ }
2463
+ if (!retryResponse.ok) {
2464
+ let errorBody;
2465
+ try {
2466
+ errorBody = await retryResponse.json();
2467
+ } catch {
2468
+ errorBody = { error: "Request failed" };
2469
+ }
2470
+ throw new APIError(`API error after payment: ${retryResponse.status}`, retryResponse.status, sanitizeErrorResponse(errorBody));
2471
+ }
2472
+ const data = await retryResponse.json();
2473
+ this.sessionCalls++;
2474
+ const paidUsd = Number(details.amount) / 1e6;
2475
+ if (Number.isFinite(paidUsd)) this.sessionTotalUsd += paidUsd;
2476
+ const txHash = retryResponse.headers.get("x-payment-receipt") || retryResponse.headers.get("X-Payment-Receipt");
2477
+ if (txHash) data.txHash = txHash;
2478
+ return data;
2479
+ }
2480
+ async fetchWithTimeout(url, options) {
2481
+ const controller = new AbortController();
2482
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
2483
+ try {
2484
+ return await fetch(url, { ...options, signal: controller.signal });
2485
+ } finally {
2486
+ clearTimeout(timeoutId);
2487
+ }
2488
+ }
2489
+ getWalletAddress() {
2490
+ return this.account.address;
2491
+ }
2492
+ getSpending() {
2493
+ return { totalUsd: this.sessionTotalUsd, calls: this.sessionCalls };
2494
+ }
2495
+ };
2496
+
2497
+ // src/video.ts
2498
+ import { privateKeyToAccount as privateKeyToAccount5 } from "viem/accounts";
2499
+ var DEFAULT_API_URL5 = "https://blockrun.ai/api";
2500
+ var DEFAULT_MODEL4 = "xai/grok-imagine-video";
2501
+ var DEFAULT_TIMEOUT5 = 12e4;
2303
2502
  var POLL_INTERVAL_MS2 = 5e3;
2304
2503
  var DEFAULT_GENERATE_BUDGET_MS = 3e5;
2305
2504
  var MAX_TIMEOUT_SECONDS = 600;
@@ -2320,11 +2519,11 @@ var VideoClient = class {
2320
2519
  }
2321
2520
  validatePrivateKey(privateKey);
2322
2521
  this.privateKey = privateKey;
2323
- this.account = privateKeyToAccount4(privateKey);
2324
- const apiUrl = options.apiUrl || DEFAULT_API_URL4;
2522
+ this.account = privateKeyToAccount5(privateKey);
2523
+ const apiUrl = options.apiUrl || DEFAULT_API_URL5;
2325
2524
  validateApiUrl(apiUrl);
2326
2525
  this.apiUrl = apiUrl.replace(/\/$/, "");
2327
- this.timeout = options.timeout || DEFAULT_TIMEOUT4;
2526
+ this.timeout = options.timeout || DEFAULT_TIMEOUT5;
2328
2527
  }
2329
2528
  /**
2330
2529
  * Generate a short video clip from a text prompt (or text + image).
@@ -2348,7 +2547,7 @@ var VideoClient = class {
2348
2547
  );
2349
2548
  }
2350
2549
  const body = {
2351
- model: options?.model || DEFAULT_MODEL3,
2550
+ model: options?.model || DEFAULT_MODEL4,
2352
2551
  prompt
2353
2552
  };
2354
2553
  if (options?.imageUrl) body.image_url = options.imageUrl;
@@ -2506,9 +2705,9 @@ var VideoClient = class {
2506
2705
  };
2507
2706
 
2508
2707
  // src/voice.ts
2509
- import { privateKeyToAccount as privateKeyToAccount5 } from "viem/accounts";
2510
- var DEFAULT_API_URL5 = "https://blockrun.ai/api";
2511
- var DEFAULT_TIMEOUT5 = 6e4;
2708
+ import { privateKeyToAccount as privateKeyToAccount6 } from "viem/accounts";
2709
+ var DEFAULT_API_URL6 = "https://blockrun.ai/api";
2710
+ var DEFAULT_TIMEOUT6 = 6e4;
2512
2711
  var CALL_PRICE_USD = 0.54;
2513
2712
  var VALID_MODELS = /* @__PURE__ */ new Set(["base", "enhanced", "turbo"]);
2514
2713
  var VoiceClient = class {
@@ -2528,11 +2727,11 @@ var VoiceClient = class {
2528
2727
  }
2529
2728
  validatePrivateKey(privateKey);
2530
2729
  this.privateKey = privateKey;
2531
- this.account = privateKeyToAccount5(privateKey);
2532
- const apiUrl = options.apiUrl || DEFAULT_API_URL5;
2730
+ this.account = privateKeyToAccount6(privateKey);
2731
+ const apiUrl = options.apiUrl || DEFAULT_API_URL6;
2533
2732
  validateApiUrl(apiUrl);
2534
2733
  this.apiUrl = apiUrl.replace(/\/$/, "");
2535
- this.timeout = options.timeout || DEFAULT_TIMEOUT5;
2734
+ this.timeout = options.timeout || DEFAULT_TIMEOUT6;
2536
2735
  }
2537
2736
  /**
2538
2737
  * Initiate an AI-powered outbound phone call.
@@ -2707,9 +2906,9 @@ var VoiceClient = class {
2707
2906
  };
2708
2907
 
2709
2908
  // src/phone.ts
2710
- import { privateKeyToAccount as privateKeyToAccount6 } from "viem/accounts";
2711
- var DEFAULT_API_URL6 = "https://blockrun.ai/api";
2712
- var DEFAULT_TIMEOUT6 = 6e4;
2909
+ import { privateKeyToAccount as privateKeyToAccount7 } from "viem/accounts";
2910
+ var DEFAULT_API_URL7 = "https://blockrun.ai/api";
2911
+ var DEFAULT_TIMEOUT7 = 6e4;
2713
2912
  var PHONE_PRICES = Object.freeze({
2714
2913
  lookup: 0.01,
2715
2914
  "lookup/fraud": 0.05,
@@ -2747,11 +2946,11 @@ var PhoneClient = class {
2747
2946
  }
2748
2947
  validatePrivateKey(privateKey);
2749
2948
  this.privateKey = privateKey;
2750
- this.account = privateKeyToAccount6(privateKey);
2751
- const apiUrl = options.apiUrl || DEFAULT_API_URL6;
2949
+ this.account = privateKeyToAccount7(privateKey);
2950
+ const apiUrl = options.apiUrl || DEFAULT_API_URL7;
2752
2951
  validateApiUrl(apiUrl);
2753
2952
  this.apiUrl = apiUrl.replace(/\/$/, "");
2754
- this.timeout = options.timeout || DEFAULT_TIMEOUT6;
2953
+ this.timeout = options.timeout || DEFAULT_TIMEOUT7;
2755
2954
  }
2756
2955
  /** EVM wallet address used for payments. */
2757
2956
  getWalletAddress() {
@@ -2926,9 +3125,9 @@ var PhoneClient = class {
2926
3125
  };
2927
3126
 
2928
3127
  // src/portrait.ts
2929
- import { privateKeyToAccount as privateKeyToAccount7 } from "viem/accounts";
2930
- var DEFAULT_API_URL7 = "https://blockrun.ai/api";
2931
- var DEFAULT_TIMEOUT7 = 6e4;
3128
+ import { privateKeyToAccount as privateKeyToAccount8 } from "viem/accounts";
3129
+ var DEFAULT_API_URL8 = "https://blockrun.ai/api";
3130
+ var DEFAULT_TIMEOUT8 = 6e4;
2932
3131
  var PORTRAIT_ENROLLMENT_PRICE_USD = 0.01;
2933
3132
  var PortraitClient = class {
2934
3133
  account;
@@ -2947,11 +3146,11 @@ var PortraitClient = class {
2947
3146
  }
2948
3147
  validatePrivateKey(privateKey);
2949
3148
  this.privateKey = privateKey;
2950
- this.account = privateKeyToAccount7(privateKey);
2951
- const apiUrl = options.apiUrl || DEFAULT_API_URL7;
3149
+ this.account = privateKeyToAccount8(privateKey);
3150
+ const apiUrl = options.apiUrl || DEFAULT_API_URL8;
2952
3151
  validateApiUrl(apiUrl);
2953
3152
  this.apiUrl = apiUrl.replace(/\/$/, "");
2954
- this.timeout = options.timeout || DEFAULT_TIMEOUT7;
3153
+ this.timeout = options.timeout || DEFAULT_TIMEOUT8;
2955
3154
  }
2956
3155
  /** EVM wallet address used for payments. */
2957
3156
  getWalletAddress() {
@@ -3080,9 +3279,9 @@ var PortraitClient = class {
3080
3279
  };
3081
3280
 
3082
3281
  // src/search.ts
3083
- import { privateKeyToAccount as privateKeyToAccount8 } from "viem/accounts";
3084
- var DEFAULT_API_URL8 = "https://blockrun.ai/api";
3085
- var DEFAULT_TIMEOUT8 = 6e4;
3282
+ import { privateKeyToAccount as privateKeyToAccount9 } from "viem/accounts";
3283
+ var DEFAULT_API_URL9 = "https://blockrun.ai/api";
3284
+ var DEFAULT_TIMEOUT9 = 6e4;
3086
3285
  var SearchClient = class {
3087
3286
  account;
3088
3287
  privateKey;
@@ -3098,11 +3297,11 @@ var SearchClient = class {
3098
3297
  }
3099
3298
  validatePrivateKey(privateKey);
3100
3299
  this.privateKey = privateKey;
3101
- this.account = privateKeyToAccount8(privateKey);
3102
- const apiUrl = options.apiUrl || DEFAULT_API_URL8;
3300
+ this.account = privateKeyToAccount9(privateKey);
3301
+ const apiUrl = options.apiUrl || DEFAULT_API_URL9;
3103
3302
  validateApiUrl(apiUrl);
3104
3303
  this.apiUrl = apiUrl.replace(/\/$/, "");
3105
- this.timeout = options.timeout || DEFAULT_TIMEOUT8;
3304
+ this.timeout = options.timeout || DEFAULT_TIMEOUT9;
3106
3305
  }
3107
3306
  async search(query, options) {
3108
3307
  if (!query || query.length > 1e3) {
@@ -3216,9 +3415,9 @@ var SearchClient = class {
3216
3415
  };
3217
3416
 
3218
3417
  // src/x-client.ts
3219
- import { privateKeyToAccount as privateKeyToAccount9 } from "viem/accounts";
3220
- var DEFAULT_API_URL9 = "https://blockrun.ai/api";
3221
- var DEFAULT_TIMEOUT9 = 6e4;
3418
+ import { privateKeyToAccount as privateKeyToAccount10 } from "viem/accounts";
3419
+ var DEFAULT_API_URL10 = "https://blockrun.ai/api";
3420
+ var DEFAULT_TIMEOUT10 = 6e4;
3222
3421
  var XClient = class _XClient {
3223
3422
  account;
3224
3423
  privateKey;
@@ -3241,11 +3440,11 @@ var XClient = class _XClient {
3241
3440
  }
3242
3441
  validatePrivateKey(privateKey);
3243
3442
  this.privateKey = privateKey;
3244
- this.account = privateKeyToAccount9(privateKey);
3245
- const apiUrl = options.apiUrl || DEFAULT_API_URL9;
3443
+ this.account = privateKeyToAccount10(privateKey);
3444
+ const apiUrl = options.apiUrl || DEFAULT_API_URL10;
3246
3445
  validateApiUrl(apiUrl);
3247
3446
  this.apiUrl = apiUrl.replace(/\/$/, "");
3248
- this.timeout = options.timeout || DEFAULT_TIMEOUT9;
3447
+ this.timeout = options.timeout || DEFAULT_TIMEOUT10;
3249
3448
  }
3250
3449
  // ───────── User endpoints ─────────
3251
3450
  userLookup(usernames) {
@@ -3423,9 +3622,9 @@ var XClient = class _XClient {
3423
3622
  };
3424
3623
 
3425
3624
  // src/price.ts
3426
- import { privateKeyToAccount as privateKeyToAccount10 } from "viem/accounts";
3427
- var DEFAULT_API_URL10 = "https://blockrun.ai/api";
3428
- var DEFAULT_TIMEOUT10 = 3e4;
3625
+ import { privateKeyToAccount as privateKeyToAccount11 } from "viem/accounts";
3626
+ var DEFAULT_API_URL11 = "https://blockrun.ai/api";
3627
+ var DEFAULT_TIMEOUT11 = 3e4;
3429
3628
  var PriceClient = class {
3430
3629
  account = null;
3431
3630
  privateKey = null;
@@ -3443,12 +3642,12 @@ var PriceClient = class {
3443
3642
  if (privateKey) {
3444
3643
  validatePrivateKey(privateKey);
3445
3644
  this.privateKey = privateKey;
3446
- this.account = privateKeyToAccount10(privateKey);
3645
+ this.account = privateKeyToAccount11(privateKey);
3447
3646
  }
3448
- const apiUrl = options.apiUrl || DEFAULT_API_URL10;
3647
+ const apiUrl = options.apiUrl || DEFAULT_API_URL11;
3449
3648
  validateApiUrl(apiUrl);
3450
3649
  this.apiUrl = apiUrl.replace(/\/$/, "");
3451
- this.timeout = options.timeout || DEFAULT_TIMEOUT10;
3650
+ this.timeout = options.timeout || DEFAULT_TIMEOUT11;
3452
3651
  }
3453
3652
  async price(category, symbol, options) {
3454
3653
  if (!symbol) throw new Error("symbol is required");
@@ -3627,9 +3826,9 @@ function buildUrl(base, query) {
3627
3826
  }
3628
3827
 
3629
3828
  // src/surf.ts
3630
- import { privateKeyToAccount as privateKeyToAccount11 } from "viem/accounts";
3631
- var DEFAULT_API_URL11 = "https://blockrun.ai/api";
3632
- var DEFAULT_TIMEOUT11 = 6e4;
3829
+ import { privateKeyToAccount as privateKeyToAccount12 } from "viem/accounts";
3830
+ var DEFAULT_API_URL12 = "https://blockrun.ai/api";
3831
+ var DEFAULT_TIMEOUT12 = 6e4;
3633
3832
  var SURF_PREFIX = "/v1/surf";
3634
3833
  var SurfClient = class {
3635
3834
  account;
@@ -3646,11 +3845,11 @@ var SurfClient = class {
3646
3845
  }
3647
3846
  validatePrivateKey(privateKey);
3648
3847
  this.privateKey = privateKey;
3649
- this.account = privateKeyToAccount11(privateKey);
3650
- const apiUrl = options.apiUrl || DEFAULT_API_URL11;
3848
+ this.account = privateKeyToAccount12(privateKey);
3849
+ const apiUrl = options.apiUrl || DEFAULT_API_URL12;
3651
3850
  validateApiUrl(apiUrl);
3652
3851
  this.apiUrl = apiUrl.replace(/\/$/, "");
3653
- this.timeout = options.timeout || DEFAULT_TIMEOUT11;
3852
+ this.timeout = options.timeout || DEFAULT_TIMEOUT12;
3654
3853
  }
3655
3854
  /**
3656
3855
  * GET a Surf endpoint. `path` is everything after `/v1/surf` (a leading
@@ -3782,9 +3981,9 @@ var SurfClient = class {
3782
3981
  };
3783
3982
 
3784
3983
  // src/blockrun.ts
3785
- import { privateKeyToAccount as privateKeyToAccount12 } from "viem/accounts";
3786
- var DEFAULT_API_URL12 = "https://blockrun.ai/api";
3787
- var DEFAULT_TIMEOUT12 = 6e4;
3984
+ import { privateKeyToAccount as privateKeyToAccount13 } from "viem/accounts";
3985
+ var DEFAULT_API_URL13 = "https://blockrun.ai/api";
3986
+ var DEFAULT_TIMEOUT13 = 6e4;
3788
3987
  var DEFAULT_POLL_INTERVAL_MS = 5e3;
3789
3988
  var DEFAULT_POLL_BUDGET_MS = 3e5;
3790
3989
  var MAX_SIGNED_AUTH_SECONDS = 600;
@@ -3805,11 +4004,11 @@ var BlockrunClient = class {
3805
4004
  }
3806
4005
  validatePrivateKey(privateKey);
3807
4006
  this.privateKey = privateKey;
3808
- this.account = privateKeyToAccount12(privateKey);
3809
- const apiUrl = options.apiUrl || DEFAULT_API_URL12;
4007
+ this.account = privateKeyToAccount13(privateKey);
4008
+ const apiUrl = options.apiUrl || DEFAULT_API_URL13;
3810
4009
  validateApiUrl(apiUrl);
3811
4010
  this.apiUrl = apiUrl.replace(/\/$/, "");
3812
- this.timeout = options.timeout || DEFAULT_TIMEOUT12;
4011
+ this.timeout = options.timeout || DEFAULT_TIMEOUT13;
3813
4012
  }
3814
4013
  /**
3815
4014
  * GET a BlockRun endpoint. `path` is everything after `/api` (a leading
@@ -4160,7 +4359,7 @@ function sleep(ms) {
4160
4359
  }
4161
4360
 
4162
4361
  // src/wallet.ts
4163
- import { privateKeyToAccount as privateKeyToAccount13, generatePrivateKey } from "viem/accounts";
4362
+ import { privateKeyToAccount as privateKeyToAccount14, generatePrivateKey } from "viem/accounts";
4164
4363
  import * as fs2 from "fs";
4165
4364
  import * as path2 from "path";
4166
4365
  import * as os2 from "os";
@@ -4170,7 +4369,7 @@ var WALLET_DIR = path2.join(os2.homedir(), ".blockrun");
4170
4369
  var WALLET_FILE = path2.join(WALLET_DIR, ".session");
4171
4370
  function createWallet() {
4172
4371
  const privateKey = generatePrivateKey();
4173
- const account = privateKeyToAccount13(privateKey);
4372
+ const account = privateKeyToAccount14(privateKey);
4174
4373
  return {
4175
4374
  address: account.address,
4176
4375
  privateKey
@@ -4226,12 +4425,12 @@ function loadWallet() {
4226
4425
  function getOrCreateWallet() {
4227
4426
  const envKey = typeof process !== "undefined" && process.env ? process.env.BLOCKRUN_WALLET_KEY || process.env.BASE_CHAIN_WALLET_KEY : void 0;
4228
4427
  if (envKey) {
4229
- const account = privateKeyToAccount13(envKey);
4428
+ const account = privateKeyToAccount14(envKey);
4230
4429
  return { address: account.address, privateKey: envKey, isNew: false };
4231
4430
  }
4232
4431
  const fileKey = loadWallet();
4233
4432
  if (fileKey) {
4234
- const account = privateKeyToAccount13(fileKey);
4433
+ const account = privateKeyToAccount14(fileKey);
4235
4434
  return { address: account.address, privateKey: fileKey, isNew: false };
4236
4435
  }
4237
4436
  const { address, privateKey } = createWallet();
@@ -4241,11 +4440,11 @@ function getOrCreateWallet() {
4241
4440
  function getWalletAddress() {
4242
4441
  const envKey = typeof process !== "undefined" && process.env ? process.env.BLOCKRUN_WALLET_KEY || process.env.BASE_CHAIN_WALLET_KEY : void 0;
4243
4442
  if (envKey) {
4244
- return privateKeyToAccount13(envKey).address;
4443
+ return privateKeyToAccount14(envKey).address;
4245
4444
  }
4246
4445
  const fileKey = loadWallet();
4247
4446
  if (fileKey) {
4248
- return privateKeyToAccount13(fileKey).address;
4447
+ return privateKeyToAccount14(fileKey).address;
4249
4448
  }
4250
4449
  return null;
4251
4450
  }
@@ -4425,7 +4624,7 @@ async function getOrCreateSolanaWallet() {
4425
4624
  // src/solana-client.ts
4426
4625
  var SOLANA_API_URL = "https://sol.blockrun.ai/api";
4427
4626
  var DEFAULT_MAX_TOKENS2 = 1024;
4428
- var DEFAULT_TIMEOUT13 = 6e4;
4627
+ var DEFAULT_TIMEOUT14 = 6e4;
4429
4628
  var SDK_VERSION2 = "0.3.0";
4430
4629
  var USER_AGENT2 = `blockrun-ts/${SDK_VERSION2}`;
4431
4630
  var DEFAULT_SOLANA_RPC_URL = "https://sol.blockrun.ai/api/v1/solana/rpc";
@@ -4475,7 +4674,7 @@ var SolanaLLMClient = class {
4475
4674
  const rpc = resolveRpcConfig(options.rpcUrl, options.rpcHeaders);
4476
4675
  this.rpcUrl = rpc.url;
4477
4676
  this.rpcHeaders = rpc.headers;
4478
- this.timeout = options.timeout || DEFAULT_TIMEOUT13;
4677
+ this.timeout = options.timeout || DEFAULT_TIMEOUT14;
4479
4678
  }
4480
4679
  /** Get Solana wallet address (public key in base58). */
4481
4680
  async getWalletAddress() {
@@ -5389,7 +5588,7 @@ var OpenAI = class {
5389
5588
  };
5390
5589
 
5391
5590
  // src/anthropic-compat.ts
5392
- import { privateKeyToAccount as privateKeyToAccount14 } from "viem/accounts";
5591
+ import { privateKeyToAccount as privateKeyToAccount15 } from "viem/accounts";
5393
5592
  var AnthropicClient = class {
5394
5593
  _client = null;
5395
5594
  _clientPromise = null;
@@ -5402,7 +5601,7 @@ var AnthropicClient = class {
5402
5601
  const key = options.privateKey ?? wallet.privateKey;
5403
5602
  validatePrivateKey(key);
5404
5603
  this._privateKey = key;
5405
- this._account = privateKeyToAccount14(this._privateKey);
5604
+ this._account = privateKeyToAccount15(this._privateKey);
5406
5605
  const apiUrl = options.apiUrl ?? "https://blockrun.ai/api";
5407
5606
  validateApiUrl(apiUrl);
5408
5607
  this._apiUrl = apiUrl.replace(/\/$/, "");
@@ -5517,6 +5716,7 @@ export {
5517
5716
  SOLANA_WALLET_FILE as SOLANA_WALLET_FILE_PATH,
5518
5717
  SearchClient,
5519
5718
  SolanaLLMClient,
5719
+ SpeechClient,
5520
5720
  SurfClient,
5521
5721
  USDC_BASE,
5522
5722
  USDC_BASE_CONTRACT,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockrun/llm",
3
- "version": "2.11.1",
3
+ "version": "2.12.0",
4
4
  "type": "module",
5
5
  "description": "BlockRun SDK - Pay-per-request AI (LLM, Image, Video, Music, Voice) via x402 on Base and Solana",
6
6
  "main": "dist/index.cjs",