@blockrun/llm 3.25.0 → 3.26.3

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
@@ -634,6 +634,17 @@ console.log(res.usage?.server_side_tool_usage); // { x_posts_fetched, ... }
634
634
  console.log(res.costUsd, res.settlement); // what you paid, and the tx
635
635
  ```
636
636
 
637
+ Reasoning models take `reasoningEffort` on any chat call. Unset, the model's
638
+ own default applies, and some default to their highest effort (Reflection Beam
639
+ defaults to `"max"`); reasoning tokens bill as output:
640
+
641
+ ```typescript
642
+ const quick = await client.chatCompletion('reflection/beam-1.0-501b-a23b', messages, {
643
+ reasoningEffort: 'low', // none | minimal | low | medium | high | xhigh | max, per model
644
+ maxTokens: 8192, // reasoning counts toward max_tokens
645
+ });
646
+ ```
647
+
637
648
  `costUsd`, `settlement` and the per-call `timeout` work the same on `LLMClient`
638
649
  (Base / Arc). Both clients default to a 600 s request timeout
639
650
  (`BLOCKRUN_CHAT_TIMEOUT`, in seconds, overrides it; the `timeout` option, in
package/dist/index.cjs CHANGED
@@ -269,6 +269,18 @@ function validateApiUrl(url) {
269
269
  );
270
270
  }
271
271
  }
272
+ var PAYMENT_FACT_FIELDS = ["payment_status", "tx_hash", "payment_note"];
273
+ function paymentFactsNote(errorBody) {
274
+ if (typeof errorBody !== "object" || errorBody === null) return "";
275
+ const { payment_status: status2, tx_hash: txHash } = errorBody;
276
+ if (status2 === "settled") {
277
+ const tx = typeof txHash === "string" && txHash ? ` (tx ${txHash})` : "";
278
+ return `. Payment settled${tx}. Do not pay for this job again.`;
279
+ }
280
+ if (status2 === "unknown") return ". Payment state unknown. Check your wallet before paying again.";
281
+ if (status2 === "not_charged" || status2 === "settlement_failed") return ". No payment was taken.";
282
+ return "";
283
+ }
272
284
  function sanitizeErrorResponse(errorBody) {
273
285
  if (typeof errorBody !== "object" || errorBody === null) {
274
286
  return { message: "API request failed" };
@@ -279,7 +291,10 @@ function sanitizeErrorResponse(errorBody) {
279
291
  message: typeof body.error === "string" ? body.error : "API request failed",
280
292
  code: typeof body.code === "string" ? body.code : void 0,
281
293
  ...detail ? { detail } : {},
282
- ...typeof body.hint === "string" ? { hint: body.hint } : {}
294
+ ...typeof body.hint === "string" ? { hint: body.hint } : {},
295
+ ...Object.fromEntries(
296
+ PAYMENT_FACT_FIELDS.filter((field) => typeof body[field] === "string").map((field) => [field, body[field]])
297
+ )
283
298
  };
284
299
  }
285
300
  function validateResourceUrl(url, baseUrl) {
@@ -5049,10 +5064,16 @@ function parsePaymentRequired(headerValue) {
5049
5064
  }
5050
5065
  }
5051
5066
  function extractPaymentDetails(paymentRequired, preferredNetwork) {
5052
- const accepts = paymentRequired.accepts || [];
5053
- if (accepts.length === 0) {
5067
+ const offered = paymentRequired.accepts || [];
5068
+ if (offered.length === 0) {
5054
5069
  throw new Error("No payment options in payment required response");
5055
5070
  }
5071
+ const accepts = offered.filter((opt) => !opt.scheme || opt.scheme === "exact");
5072
+ if (accepts.length === 0) {
5073
+ throw new Error(
5074
+ `This client signs the exact scheme, but the 402 only offers ${offered.map((opt) => JSON.stringify(opt.scheme)).join(", ")}`
5075
+ );
5076
+ }
5056
5077
  let option = null;
5057
5078
  if (preferredNetwork) {
5058
5079
  option = accepts.find((opt) => opt.network === preferredNetwork) || null;
@@ -5122,7 +5143,7 @@ function getCostSummary() {
5122
5143
  }
5123
5144
 
5124
5145
  // src/version.ts
5125
- var SDK_VERSION = "3.25.0";
5146
+ var SDK_VERSION = "3.26.3";
5126
5147
  var USER_AGENT = `blockrun-ts/${SDK_VERSION}`;
5127
5148
 
5128
5149
  // src/client.ts
@@ -5251,6 +5272,7 @@ var LLMClient = class _LLMClient {
5251
5272
  searchParameters: options?.searchParameters,
5252
5273
  responseFormat: options?.responseFormat,
5253
5274
  stop: options?.stop,
5275
+ reasoningEffort: options?.reasoningEffort,
5254
5276
  fallbackModels: options?.fallbackModels
5255
5277
  });
5256
5278
  return result.choices[0].message.content || "";
@@ -5323,6 +5345,7 @@ var LLMClient = class _LLMClient {
5323
5345
  searchParameters: options?.searchParameters,
5324
5346
  responseFormat: options?.responseFormat,
5325
5347
  stop: options?.stop,
5348
+ reasoningEffort: options?.reasoningEffort,
5326
5349
  // An explicit caller-supplied chain wins over the routed one.
5327
5350
  fallbackModels: options?.fallbackModels ?? decision.fallbacks
5328
5351
  });
@@ -5360,6 +5383,7 @@ var LLMClient = class _LLMClient {
5360
5383
  toolChoice: options.toolChoice,
5361
5384
  responseFormat: options.responseFormat,
5362
5385
  stop: options.stop,
5386
+ reasoningEffort: options.reasoningEffort,
5363
5387
  timeout: options.timeout,
5364
5388
  // An explicit caller-supplied chain wins over the routed one.
5365
5389
  fallbackModels: options.fallbackModels ?? decision.fallbacks
@@ -5446,6 +5470,7 @@ var LLMClient = class _LLMClient {
5446
5470
  if (options?.toolChoice !== void 0) body.tool_choice = options.toolChoice;
5447
5471
  if (options?.responseFormat !== void 0) body.response_format = options.responseFormat;
5448
5472
  if (options?.stop !== void 0) body.stop = options.stop;
5473
+ if (options?.reasoningEffort !== void 0) body.reasoning_effort = options.reasoningEffort;
5449
5474
  return body;
5450
5475
  };
5451
5476
  const chain = [model, ...options?.fallbackModels ?? []];
@@ -5819,6 +5844,7 @@ var LLMClient = class _LLMClient {
5819
5844
  if (options?.toolChoice !== void 0) body.tool_choice = options.toolChoice;
5820
5845
  if (options?.responseFormat !== void 0) body.response_format = options.responseFormat;
5821
5846
  if (options?.stop !== void 0) body.stop = options.stop;
5847
+ if (options?.reasoningEffort !== void 0) body.reasoning_effort = options.reasoningEffort;
5822
5848
  const cacheKey2 = `/v1/chat/completions:${requestModel}`;
5823
5849
  const requestBody = JSON.stringify(body);
5824
5850
  const cached = this.preAuthCache.get(cacheKey2);
@@ -7073,6 +7099,9 @@ var import_accounts4 = require("viem/accounts");
7073
7099
  var DEFAULT_API_URL3 = "https://blockrun.ai/api";
7074
7100
  var DEFAULT_MODEL2 = "minimax/music-2.5+";
7075
7101
  var DEFAULT_TIMEOUT3 = 21e4;
7102
+ var POLL_INTERVAL_MS2 = 5e3;
7103
+ var POLL_MAX_DURATION_MS2 = 3e5;
7104
+ var TRANSIENT_POLL_STATUSES = /* @__PURE__ */ new Set([502, 503, 504]);
7076
7105
  var MusicClient = class {
7077
7106
  _account;
7078
7107
  get account() {
@@ -7214,15 +7243,79 @@ var MusicClient = class {
7214
7243
  }
7215
7244
  throw new APIError(`API error after payment: ${retryResponse.status}`, retryResponse.status, sanitizeErrorResponse(errorBody));
7216
7245
  }
7246
+ const costUsd = Number(details.amount) / 1e6;
7217
7247
  const data = await retryResponse.json();
7218
- if (!settlementSkipped(retryResponse)) {
7248
+ if (retryResponse.status === 202 || data.status === "queued" || data.status === "in_progress") {
7249
+ if (!data.poll_url) {
7250
+ throw new APIError(
7251
+ `Server returned ${retryResponse.status} but no poll_url to follow.`,
7252
+ retryResponse.status,
7253
+ sanitizeErrorResponse(data)
7254
+ );
7255
+ }
7256
+ return this.pollMusicJob(data.poll_url, paymentPayload, costUsd);
7257
+ }
7258
+ return this.finishPaidResponse(retryResponse, data, costUsd);
7259
+ }
7260
+ finishPaidResponse(response, data, costUsd) {
7261
+ if (!settlementSkipped(response)) {
7219
7262
  this.sessionCalls++;
7220
- this.sessionTotalUsd += 0.1575;
7263
+ this.sessionTotalUsd += costUsd;
7221
7264
  }
7222
- const txHash = retryResponse.headers.get("x-payment-receipt") || retryResponse.headers.get("X-Payment-Receipt");
7265
+ const txHash = response.headers.get("x-payment-receipt");
7223
7266
  if (txHash) data.txHash = txHash;
7224
7267
  return data;
7225
7268
  }
7269
+ /**
7270
+ * Poll a slow track until it completes, sending the SAME payment header each
7271
+ * time: the server binds the payer to the job and settles on the first poll
7272
+ * that sees it completed.
7273
+ *
7274
+ * Network errors and 502/503/504 keep polling. A response lost on the settling
7275
+ * poll would otherwise drop a track that was paid for, and polling again returns
7276
+ * it as already settled, with no second charge.
7277
+ */
7278
+ async pollMusicJob(pollPath, paymentHeader, costUsd) {
7279
+ const pollUrl = pollPath.startsWith("/api/") ? `${this.apiUrl.replace(/\/api$/, "")}${pollPath}` : `${this.apiUrl}${pollPath.startsWith("/") ? "" : "/"}${pollPath}`;
7280
+ const startedAt = Date.now();
7281
+ while (Date.now() - startedAt < POLL_MAX_DURATION_MS2) {
7282
+ await new Promise((resolve2) => setTimeout(resolve2, POLL_INTERVAL_MS2));
7283
+ let pollResp;
7284
+ try {
7285
+ pollResp = await this.fetchWithTimeout(pollUrl, {
7286
+ method: "GET",
7287
+ headers: { "PAYMENT-SIGNATURE": paymentHeader }
7288
+ });
7289
+ } catch {
7290
+ continue;
7291
+ }
7292
+ if (pollResp.status === 202 || TRANSIENT_POLL_STATUSES.has(pollResp.status)) continue;
7293
+ const pollBody = await pollResp.json().catch(() => ({}));
7294
+ if (!pollResp.ok) {
7295
+ throw new APIError(
7296
+ `API error during poll of ${pollPath}: ${pollResp.status}`,
7297
+ pollResp.status,
7298
+ sanitizeErrorResponse(pollBody)
7299
+ );
7300
+ }
7301
+ if (pollBody.status === "failed") {
7302
+ throw new APIError(
7303
+ pollBody.error || "Upstream music generation failed",
7304
+ 200,
7305
+ sanitizeErrorResponse(pollBody)
7306
+ );
7307
+ }
7308
+ if (pollBody.data) {
7309
+ if (!pollBody.txHash && pollBody.payment?.tx_hash) pollBody.txHash = pollBody.payment.tx_hash;
7310
+ return this.finishPaidResponse(pollResp, pollBody, costUsd);
7311
+ }
7312
+ }
7313
+ throw new APIError(
7314
+ `Music generation did not finish within ${POLL_MAX_DURATION_MS2 / 1e3}s. The job may still complete: poll poll_url with the same payment header before paying again.`,
7315
+ 504,
7316
+ { error: "poll_timeout", poll_url: pollPath }
7317
+ );
7318
+ }
7226
7319
  async fetchWithTimeout(url, options) {
7227
7320
  const controller = new AbortController();
7228
7321
  const timeoutId = setTimeout(() => controller.abort(), this.timeout);
@@ -7462,7 +7555,7 @@ var import_accounts6 = require("viem/accounts");
7462
7555
  var DEFAULT_API_URL5 = "https://blockrun.ai/api";
7463
7556
  var DEFAULT_MODEL4 = "xai/grok-imagine-video";
7464
7557
  var DEFAULT_TIMEOUT5 = 12e4;
7465
- var POLL_INTERVAL_MS2 = 5e3;
7558
+ var POLL_INTERVAL_MS3 = 5e3;
7466
7559
  var DEFAULT_GENERATE_BUDGET_MS = 9e5;
7467
7560
  var MAX_TIMEOUT_SECONDS = 600;
7468
7561
  var MAX_POLL_RESIGNS = 2;
@@ -7673,7 +7766,7 @@ var VideoClient = class {
7673
7766
  headers: { "Content-Type": "application/json" },
7674
7767
  body: JSON.stringify(body)
7675
7768
  });
7676
- if (this.apiAuth) return this.apiAuth.poll(resp402, budgetMs, POLL_INTERVAL_MS2);
7769
+ if (this.apiAuth) return this.apiAuth.poll(resp402, budgetMs, POLL_INTERVAL_MS3);
7677
7770
  if (resp402.status !== 402) {
7678
7771
  await this.throwApiError(resp402, "Expected 402 on first POST");
7679
7772
  }
@@ -7708,7 +7801,7 @@ var VideoClient = class {
7708
7801
  let lastStatus = submitData.status || "queued";
7709
7802
  let resignsLeft = MAX_POLL_RESIGNS;
7710
7803
  while (Date.now() < deadline) {
7711
- await new Promise((r) => setTimeout(r, POLL_INTERVAL_MS2));
7804
+ await new Promise((r) => setTimeout(r, POLL_INTERVAL_MS3));
7712
7805
  const pollResp = await this.fetchWithTimeout(pollUrl, {
7713
7806
  method: "GET",
7714
7807
  headers: { "PAYMENT-SIGNATURE": paymentPayload }
@@ -9441,7 +9534,7 @@ var BlockrunClient = class {
9441
9534
  }
9442
9535
  if (lastStatus === "failed") {
9443
9536
  throw new APIError(
9444
- `Upstream job failed: ${pollData.error || "unknown"}`,
9537
+ `Upstream job failed: ${pollData.error || "unknown"}${paymentFactsNote(pollData)}`,
9445
9538
  pollResp.status,
9446
9539
  sanitizeErrorResponse(pollData)
9447
9540
  );
@@ -9952,11 +10045,11 @@ var WALLET_DIR = path4.join(os3.homedir(), ".blockrun");
9952
10045
  var SOLANA_WALLET_FILE = path4.join(WALLET_DIR, ".solana-session");
9953
10046
  async function createSolanaWallet() {
9954
10047
  const { Keypair } = await loadSolanaWeb3("Solana wallet operations");
9955
- const bs583 = await import("bs58");
10048
+ const bs582 = await import("bs58");
9956
10049
  const keypair = Keypair.generate();
9957
10050
  return {
9958
10051
  address: keypair.publicKey.toBase58(),
9959
- privateKey: (bs583.default ?? bs583).encode(keypair.secretKey)
10052
+ privateKey: (bs582.default ?? bs582).encode(keypair.secretKey)
9960
10053
  };
9961
10054
  }
9962
10055
  async function solanaKeyToBytes(privateKey) {
@@ -9994,8 +10087,8 @@ async function solanaKeyToBytes(privateKey) {
9994
10087
  return bytes;
9995
10088
  }
9996
10089
  try {
9997
- const bs583 = await import("bs58");
9998
- const bytes = (bs583.default ?? bs583).decode(key);
10090
+ const bs582 = await import("bs58");
10091
+ const bytes = (bs582.default ?? bs582).decode(key);
9999
10092
  if (bytes.length !== 64) {
10000
10093
  throw new Error(`Invalid Solana key length: expected 64 bytes, got ${bytes.length}`);
10001
10094
  }
@@ -10176,7 +10269,19 @@ async function getOrCreateSolanaWallet() {
10176
10269
 
10177
10270
  // src/poll-ownership.ts
10178
10271
  var import_crypto = require("crypto");
10272
+
10273
+ // src/bs58.ts
10179
10274
  var import_bs58 = __toESM(require("bs58"), 1);
10275
+ function unwrapBs58(mod) {
10276
+ const m = mod;
10277
+ if (typeof m?.encode === "function") return m;
10278
+ const inner = m?.default;
10279
+ if (typeof inner?.encode === "function") return inner;
10280
+ throw new Error("bs58: no encode() on the module or its default export");
10281
+ }
10282
+ var bs58 = unwrapBs58(import_bs58.default);
10283
+
10284
+ // src/poll-ownership.ts
10180
10285
  var POLL_AUTH_HEADERS = {
10181
10286
  wallet: "x-poll-wallet",
10182
10287
  timestamp: "x-poll-timestamp",
@@ -10208,9 +10313,9 @@ function signPollOwnership(secretKey, kind, jobId, nowMs = Date.now()) {
10208
10313
  const timestampS = Math.floor(nowMs / 1e3);
10209
10314
  const signature = (0, import_crypto.sign)(null, Buffer.from(pollAuthMessage(kind, jobId, timestampS), "utf8"), privateKey);
10210
10315
  return {
10211
- [POLL_AUTH_HEADERS.wallet]: import_bs58.default.encode(publicKey),
10316
+ [POLL_AUTH_HEADERS.wallet]: bs58.encode(publicKey),
10212
10317
  [POLL_AUTH_HEADERS.timestamp]: String(timestampS),
10213
- [POLL_AUTH_HEADERS.signature]: import_bs58.default.encode(signature)
10318
+ [POLL_AUTH_HEADERS.signature]: bs58.encode(signature)
10214
10319
  };
10215
10320
  }
10216
10321
 
@@ -10219,7 +10324,6 @@ var import_async_hooks = require("async_hooks");
10219
10324
  var import_crypto2 = require("crypto");
10220
10325
  var fs6 = __toESM(require("fs"), 1);
10221
10326
  var path5 = __toESM(require("path"), 1);
10222
- var import_bs582 = __toESM(require("bs58"), 1);
10223
10327
  var BATCH_SCHEME = "batch-settlement";
10224
10328
  var BLOCKRUN_SOL_OPERATOR = "5YKPQUFjw5WQqhSUkEGKNNfYYVqnRRNbpYyL71qQ1vm3";
10225
10329
  var DEFAULT_BATCH_RATE_LIMIT = { maxAttempts: 3, maxWaitMs: 6e4 };
@@ -10798,7 +10902,7 @@ function decodeChannelAccount(owner, data) {
10798
10902
  return void 0;
10799
10903
  }
10800
10904
  const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
10801
- const key = (offset) => import_bs582.default.encode(data.subarray(offset, offset + 32));
10905
+ const key = (offset) => bs58.encode(data.subarray(offset, offset + 32));
10802
10906
  return {
10803
10907
  deposit: view.getBigUint64(CHANNEL.deposit, true),
10804
10908
  settled: view.getBigUint64(CHANNEL.settled, true),
@@ -13069,6 +13173,7 @@ var SolanaLLMClient = class {
13069
13173
  searchParameters: options?.searchParameters,
13070
13174
  responseFormat: options?.responseFormat,
13071
13175
  stop: options?.stop,
13176
+ reasoningEffort: options?.reasoningEffort,
13072
13177
  fallbackModels: options?.fallbackModels
13073
13178
  });
13074
13179
  return result.choices[0].message.content || "";
@@ -13097,6 +13202,7 @@ var SolanaLLMClient = class {
13097
13202
  if (options?.toolChoice !== void 0) body.tool_choice = options.toolChoice;
13098
13203
  if (options?.responseFormat !== void 0) body.response_format = options.responseFormat;
13099
13204
  if (options?.stop !== void 0) body.stop = options.stop;
13205
+ if (options?.reasoningEffort !== void 0) body.reasoning_effort = options.reasoningEffort;
13100
13206
  return body;
13101
13207
  };
13102
13208
  const chain = [model, ...options?.fallbackModels ?? []];
@@ -13201,6 +13307,7 @@ var SolanaLLMClient = class {
13201
13307
  toolChoice: options.toolChoice,
13202
13308
  responseFormat: options.responseFormat,
13203
13309
  stop: options.stop,
13310
+ reasoningEffort: options.reasoningEffort,
13204
13311
  timeout: options.timeout,
13205
13312
  // An explicit caller-supplied chain wins over the routed one.
13206
13313
  fallbackModels: options.fallbackModels ?? decision.fallbacks
@@ -13399,7 +13506,8 @@ var SolanaLLMClient = class {
13399
13506
  *
13400
13507
  * The POST is verified, not charged. The job is then polled with a wallet
13401
13508
  * signature (no payment) until it finishes, and ONE payment is signed for
13402
- * the finished video; a failed job is never charged. If the gateway does not
13509
+ * the finished video; a job that fails before completing is not charged. A paid
13510
+ * job can still fail, and its APIError then carries `payment_status`. If the gateway does not
13403
13511
  * accept poll signatures for the job, it is polled with a payment per poll
13404
13512
  * instead, which is likewise only charged on completion.
13405
13513
  *
@@ -13767,7 +13875,8 @@ var SolanaLLMClient = class {
13767
13875
  * cost at POST; this loop only fetches the result and never signs a payment.
13768
13876
  * A batch-billed image job still answers its proof poll with 402: that job
13769
13877
  * falls back to the per-poll payment below.
13770
- * - video: settles on completion, and a failed job is never charged. A
13878
+ * - video: settles on completion. A job that fails before completing is not
13879
+ * charged; one that fails after payment says so in `payment_status`. A
13771
13880
  * finished, unpaid job answers the proof poll with 402 `{status:"completed"}`
13772
13881
  * and a normal x402 challenge; ONE payment is signed from that challenge and
13773
13882
  * the same poll is re-sent with it. The cost is recorded here, on delivery.
@@ -13814,7 +13923,7 @@ var SolanaLLMClient = class {
13814
13923
  const failIfFailed = (data, status2) => {
13815
13924
  if (lastStatus === "failed") {
13816
13925
  throw new APIError(
13817
- `Upstream job failed: ${data.error || "unknown"}`,
13926
+ `Upstream job failed: ${data.error || "unknown"}${paymentFactsNote(data)}`,
13818
13927
  status2,
13819
13928
  sanitizeErrorResponse(data)
13820
13929
  );
@@ -14560,7 +14669,8 @@ var ChatCompletions = class {
14560
14669
  tools: params.tools,
14561
14670
  toolChoice: params.tool_choice,
14562
14671
  responseFormat: params.response_format,
14563
- stop: params.stop
14672
+ stop: params.stop,
14673
+ reasoningEffort: params.reasoning_effort
14564
14674
  }
14565
14675
  );
14566
14676
  return this.transformResponse(response);
@@ -14576,7 +14686,8 @@ var ChatCompletions = class {
14576
14686
  tools: params.tools,
14577
14687
  toolChoice: params.tool_choice,
14578
14688
  responseFormat: params.response_format,
14579
- stop: params.stop
14689
+ stop: params.stop,
14690
+ reasoningEffort: params.reasoning_effort
14580
14691
  }
14581
14692
  );
14582
14693
  return new StreamingResponse(response, params.model);
package/dist/index.d.cts CHANGED
@@ -520,6 +520,12 @@ type ResponseFormat = {
520
520
  type: "json_schema";
521
521
  json_schema: Record<string, unknown>;
522
522
  };
523
+ /**
524
+ * `reasoning_effort` values. The gateway passes the value through, and each
525
+ * model accepts its own subset; xhigh/max exist on a few (e.g. Reflection
526
+ * Beam, Z.ai GLM), none/minimal only on models that can stop reasoning.
527
+ */
528
+ type ReasoningEffort = "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
523
529
  interface ChatOptions {
524
530
  /** System prompt */
525
531
  system?: string;
@@ -537,6 +543,15 @@ interface ChatOptions {
537
543
  responseFormat?: ResponseFormat;
538
544
  /** Up to 4 stop sequences (forwarded natively / mapped to stop_sequences) */
539
545
  stop?: string | string[];
546
+ /**
547
+ * Reasoning effort for reasoning models, sent as `reasoning_effort`. Omitted
548
+ * when unset, so the model's own default applies (some default to their
549
+ * HIGHEST effort, e.g. Reflection Beam defaults to "max"). Accepted values
550
+ * are per model; the gateway maps "none"/"minimal" to the lowest effort a
551
+ * model accepts when it cannot turn reasoning off. Reasoning tokens bill as
552
+ * output tokens.
553
+ */
554
+ reasoningEffort?: ReasoningEffort;
540
555
  /**
541
556
  * Models to try in order if the primary returns a transient error
542
557
  * (timeout, network, 5xx). 4xx and PaymentError still propagate
@@ -564,6 +579,15 @@ interface ChatCompletionOptions {
564
579
  responseFormat?: ResponseFormat;
565
580
  /** Up to 4 stop sequences (forwarded natively / mapped to stop_sequences) */
566
581
  stop?: string | string[];
582
+ /**
583
+ * Reasoning effort for reasoning models, sent as `reasoning_effort`. Omitted
584
+ * when unset, so the model's own default applies (some default to their
585
+ * HIGHEST effort, e.g. Reflection Beam defaults to "max"). Accepted values
586
+ * are per model; the gateway maps "none"/"minimal" to the lowest effort a
587
+ * model accepts when it cannot turn reasoning off. Reasoning tokens bill as
588
+ * output tokens.
589
+ */
590
+ reasoningEffort?: ReasoningEffort;
567
591
  /**
568
592
  * Models to try in order if the primary returns a transient error
569
593
  * (timeout, network, 5xx). 4xx and PaymentError still propagate
@@ -1974,6 +1998,17 @@ declare class MusicClient {
1974
1998
  generate(prompt: string, options?: MusicGenerateOptions): Promise<MusicResponse>;
1975
1999
  private requestWithPayment;
1976
2000
  private handlePaymentAndRetry;
2001
+ private finishPaidResponse;
2002
+ /**
2003
+ * Poll a slow track until it completes, sending the SAME payment header each
2004
+ * time: the server binds the payer to the job and settles on the first poll
2005
+ * that sees it completed.
2006
+ *
2007
+ * Network errors and 502/503/504 keep polling. A response lost on the settling
2008
+ * poll would otherwise drop a track that was paid for, and polling again returns
2009
+ * it as already settled, with no second charge.
2010
+ */
2011
+ private pollMusicJob;
1977
2012
  private fetchWithTimeout;
1978
2013
  getWalletAddress(): string;
1979
2014
  getSpending(): Spending;
@@ -3877,7 +3912,8 @@ declare class SolanaLLMClient {
3877
3912
  *
3878
3913
  * The POST is verified, not charged. The job is then polled with a wallet
3879
3914
  * signature (no payment) until it finishes, and ONE payment is signed for
3880
- * the finished video; a failed job is never charged. If the gateway does not
3915
+ * the finished video; a job that fails before completing is not charged. A paid
3916
+ * job can still fail, and its APIError then carries `payment_status`. If the gateway does not
3881
3917
  * accept poll signatures for the job, it is polled with a payment per poll
3882
3918
  * instead, which is likewise only charged on completion.
3883
3919
  *
@@ -4062,7 +4098,8 @@ declare class SolanaLLMClient {
4062
4098
  * cost at POST; this loop only fetches the result and never signs a payment.
4063
4099
  * A batch-billed image job still answers its proof poll with 402: that job
4064
4100
  * falls back to the per-poll payment below.
4065
- * - video: settles on completion, and a failed job is never charged. A
4101
+ * - video: settles on completion. A job that fails before completing is not
4102
+ * charged; one that fails after payment says so in `payment_status`. A
4066
4103
  * finished, unpaid job answers the proof poll with 402 `{status:"completed"}`
4067
4104
  * and a normal x402 challenge; ONE payment is signed from that challenge and
4068
4105
  * the same poll is re-sent with it. The cost is recorded here, on delivery.
@@ -4315,6 +4352,7 @@ interface OpenAIChatCompletionParams {
4315
4352
  user?: string;
4316
4353
  tools?: Tool[];
4317
4354
  tool_choice?: ToolChoice;
4355
+ reasoning_effort?: ReasoningEffort;
4318
4356
  }
4319
4357
  interface OpenAIChatCompletionChoice {
4320
4358
  index: number;
@@ -4546,4 +4584,4 @@ declare function readSettlement(response: Response, quotedUsd: number, scheme: S
4546
4584
  settlement: Settlement;
4547
4585
  };
4548
4586
 
4549
- export { APIError, API_KEY_URL, ARC_CHAIN_ID, AnthropicClient, type AnyTool, type ApiKeyOptions, type AudioModel, type AudioTrack, BASE_CHAIN_ID, BLOCKRUN_SOL_OPERATOR, type BarResolution, type BatchAttempt, BatchChannelLockedError, BatchCloseDeferredError, type BatchPayloadKind, BatchPaymentUnresolvedError, type BatchUnresolvedReason, 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, DEFAULT_BATCH_IN_DOUBT, DEFAULT_BATCH_LOCK_WAIT_MS, DEFAULT_BATCH_RATE_LIMIT, EVM_NETWORKS, type EvmNetwork, 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, PORTAL_URL, 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 Rechallenge, type ResponseFormat, RetiredEndpointError, type RetryDisposition, type RoutingDecision, type RoutingProfile, type RoutingTaskType, type RoutingTier, type RoutingTierConfig, 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 Settlement, type SmartChatCompletionOptions, type SmartChatCompletionResponse, type SmartChatOptions, type SmartChatResponse, type SolanaBatchEvent, type SolanaBatchOptions, SolanaBatchPayer, type SolanaBatchPayerInit, type SolanaBatchStats, 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_ARC, USDC_BASE, USDC_BASE_CONTRACT, USDC_SOLANA, type UrlCitation, 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 WebSearchTool, type X402ClientLike, type X402HookContext, type XSearchSource, type XSearchTool, clearCache, createPaymentPayload, createSolanaPaymentPayload, createSolanaWallet, createWallet, LLMClient as default, evmNetwork, extractPaymentDetails, formatFundingMessageCompact, formatNeedsFundingMessage, formatSolanaWalletMigrationNotice, formatWalletCreatedMessage, formatWalletMigrationNotice, getCached, getCachedByRequest, getCostLogSummary, getCostSummary, getEip681Uri, getOrCreateSolanaWallet, getOrCreateWallet, getPaymentLinks, getWalletAddress, importSolanaWallet, importWallet, listDiscoveredSolanaWallets, listDiscoveredWallets, loadSolanaWallet, loadWallet, logCost, parsePaymentRequired, readSettlement, retryDisposition, saveSolanaWallet, saveToCache, saveWallet, scanSolanaWallets, scanWallets, setCache, setupAgentClient, setupAgentSolanaWallet, setupAgentWallet, solanaClient, solanaKeyToBytes, solanaPublicKey, status, toWireSearchParameters, toWireTools, validateMaxTokens, validateModel, validateTemperature, validateTopP };
4587
+ export { APIError, API_KEY_URL, ARC_CHAIN_ID, AnthropicClient, type AnyTool, type ApiKeyOptions, type AudioModel, type AudioTrack, BASE_CHAIN_ID, BLOCKRUN_SOL_OPERATOR, type BarResolution, type BatchAttempt, BatchChannelLockedError, BatchCloseDeferredError, type BatchPayloadKind, BatchPaymentUnresolvedError, type BatchUnresolvedReason, 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, DEFAULT_BATCH_IN_DOUBT, DEFAULT_BATCH_LOCK_WAIT_MS, DEFAULT_BATCH_RATE_LIMIT, EVM_NETWORKS, type EvmNetwork, 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, PORTAL_URL, 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 ReasoningEffort, type Rechallenge, type ResponseFormat, RetiredEndpointError, type RetryDisposition, type RoutingDecision, type RoutingProfile, type RoutingTaskType, type RoutingTier, type RoutingTierConfig, 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 Settlement, type SmartChatCompletionOptions, type SmartChatCompletionResponse, type SmartChatOptions, type SmartChatResponse, type SolanaBatchEvent, type SolanaBatchOptions, SolanaBatchPayer, type SolanaBatchPayerInit, type SolanaBatchStats, 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_ARC, USDC_BASE, USDC_BASE_CONTRACT, USDC_SOLANA, type UrlCitation, 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 WebSearchTool, type X402ClientLike, type X402HookContext, type XSearchSource, type XSearchTool, clearCache, createPaymentPayload, createSolanaPaymentPayload, createSolanaWallet, createWallet, LLMClient as default, evmNetwork, extractPaymentDetails, formatFundingMessageCompact, formatNeedsFundingMessage, formatSolanaWalletMigrationNotice, formatWalletCreatedMessage, formatWalletMigrationNotice, getCached, getCachedByRequest, getCostLogSummary, getCostSummary, getEip681Uri, getOrCreateSolanaWallet, getOrCreateWallet, getPaymentLinks, getWalletAddress, importSolanaWallet, importWallet, listDiscoveredSolanaWallets, listDiscoveredWallets, loadSolanaWallet, loadWallet, logCost, parsePaymentRequired, readSettlement, retryDisposition, saveSolanaWallet, saveToCache, saveWallet, scanSolanaWallets, scanWallets, setCache, setupAgentClient, setupAgentSolanaWallet, setupAgentWallet, solanaClient, solanaKeyToBytes, solanaPublicKey, status, toWireSearchParameters, toWireTools, validateMaxTokens, validateModel, validateTemperature, validateTopP };
package/dist/index.d.ts CHANGED
@@ -520,6 +520,12 @@ type ResponseFormat = {
520
520
  type: "json_schema";
521
521
  json_schema: Record<string, unknown>;
522
522
  };
523
+ /**
524
+ * `reasoning_effort` values. The gateway passes the value through, and each
525
+ * model accepts its own subset; xhigh/max exist on a few (e.g. Reflection
526
+ * Beam, Z.ai GLM), none/minimal only on models that can stop reasoning.
527
+ */
528
+ type ReasoningEffort = "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
523
529
  interface ChatOptions {
524
530
  /** System prompt */
525
531
  system?: string;
@@ -537,6 +543,15 @@ interface ChatOptions {
537
543
  responseFormat?: ResponseFormat;
538
544
  /** Up to 4 stop sequences (forwarded natively / mapped to stop_sequences) */
539
545
  stop?: string | string[];
546
+ /**
547
+ * Reasoning effort for reasoning models, sent as `reasoning_effort`. Omitted
548
+ * when unset, so the model's own default applies (some default to their
549
+ * HIGHEST effort, e.g. Reflection Beam defaults to "max"). Accepted values
550
+ * are per model; the gateway maps "none"/"minimal" to the lowest effort a
551
+ * model accepts when it cannot turn reasoning off. Reasoning tokens bill as
552
+ * output tokens.
553
+ */
554
+ reasoningEffort?: ReasoningEffort;
540
555
  /**
541
556
  * Models to try in order if the primary returns a transient error
542
557
  * (timeout, network, 5xx). 4xx and PaymentError still propagate
@@ -564,6 +579,15 @@ interface ChatCompletionOptions {
564
579
  responseFormat?: ResponseFormat;
565
580
  /** Up to 4 stop sequences (forwarded natively / mapped to stop_sequences) */
566
581
  stop?: string | string[];
582
+ /**
583
+ * Reasoning effort for reasoning models, sent as `reasoning_effort`. Omitted
584
+ * when unset, so the model's own default applies (some default to their
585
+ * HIGHEST effort, e.g. Reflection Beam defaults to "max"). Accepted values
586
+ * are per model; the gateway maps "none"/"minimal" to the lowest effort a
587
+ * model accepts when it cannot turn reasoning off. Reasoning tokens bill as
588
+ * output tokens.
589
+ */
590
+ reasoningEffort?: ReasoningEffort;
567
591
  /**
568
592
  * Models to try in order if the primary returns a transient error
569
593
  * (timeout, network, 5xx). 4xx and PaymentError still propagate
@@ -1974,6 +1998,17 @@ declare class MusicClient {
1974
1998
  generate(prompt: string, options?: MusicGenerateOptions): Promise<MusicResponse>;
1975
1999
  private requestWithPayment;
1976
2000
  private handlePaymentAndRetry;
2001
+ private finishPaidResponse;
2002
+ /**
2003
+ * Poll a slow track until it completes, sending the SAME payment header each
2004
+ * time: the server binds the payer to the job and settles on the first poll
2005
+ * that sees it completed.
2006
+ *
2007
+ * Network errors and 502/503/504 keep polling. A response lost on the settling
2008
+ * poll would otherwise drop a track that was paid for, and polling again returns
2009
+ * it as already settled, with no second charge.
2010
+ */
2011
+ private pollMusicJob;
1977
2012
  private fetchWithTimeout;
1978
2013
  getWalletAddress(): string;
1979
2014
  getSpending(): Spending;
@@ -3877,7 +3912,8 @@ declare class SolanaLLMClient {
3877
3912
  *
3878
3913
  * The POST is verified, not charged. The job is then polled with a wallet
3879
3914
  * signature (no payment) until it finishes, and ONE payment is signed for
3880
- * the finished video; a failed job is never charged. If the gateway does not
3915
+ * the finished video; a job that fails before completing is not charged. A paid
3916
+ * job can still fail, and its APIError then carries `payment_status`. If the gateway does not
3881
3917
  * accept poll signatures for the job, it is polled with a payment per poll
3882
3918
  * instead, which is likewise only charged on completion.
3883
3919
  *
@@ -4062,7 +4098,8 @@ declare class SolanaLLMClient {
4062
4098
  * cost at POST; this loop only fetches the result and never signs a payment.
4063
4099
  * A batch-billed image job still answers its proof poll with 402: that job
4064
4100
  * falls back to the per-poll payment below.
4065
- * - video: settles on completion, and a failed job is never charged. A
4101
+ * - video: settles on completion. A job that fails before completing is not
4102
+ * charged; one that fails after payment says so in `payment_status`. A
4066
4103
  * finished, unpaid job answers the proof poll with 402 `{status:"completed"}`
4067
4104
  * and a normal x402 challenge; ONE payment is signed from that challenge and
4068
4105
  * the same poll is re-sent with it. The cost is recorded here, on delivery.
@@ -4315,6 +4352,7 @@ interface OpenAIChatCompletionParams {
4315
4352
  user?: string;
4316
4353
  tools?: Tool[];
4317
4354
  tool_choice?: ToolChoice;
4355
+ reasoning_effort?: ReasoningEffort;
4318
4356
  }
4319
4357
  interface OpenAIChatCompletionChoice {
4320
4358
  index: number;
@@ -4546,4 +4584,4 @@ declare function readSettlement(response: Response, quotedUsd: number, scheme: S
4546
4584
  settlement: Settlement;
4547
4585
  };
4548
4586
 
4549
- export { APIError, API_KEY_URL, ARC_CHAIN_ID, AnthropicClient, type AnyTool, type ApiKeyOptions, type AudioModel, type AudioTrack, BASE_CHAIN_ID, BLOCKRUN_SOL_OPERATOR, type BarResolution, type BatchAttempt, BatchChannelLockedError, BatchCloseDeferredError, type BatchPayloadKind, BatchPaymentUnresolvedError, type BatchUnresolvedReason, 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, DEFAULT_BATCH_IN_DOUBT, DEFAULT_BATCH_LOCK_WAIT_MS, DEFAULT_BATCH_RATE_LIMIT, EVM_NETWORKS, type EvmNetwork, 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, PORTAL_URL, 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 Rechallenge, type ResponseFormat, RetiredEndpointError, type RetryDisposition, type RoutingDecision, type RoutingProfile, type RoutingTaskType, type RoutingTier, type RoutingTierConfig, 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 Settlement, type SmartChatCompletionOptions, type SmartChatCompletionResponse, type SmartChatOptions, type SmartChatResponse, type SolanaBatchEvent, type SolanaBatchOptions, SolanaBatchPayer, type SolanaBatchPayerInit, type SolanaBatchStats, 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_ARC, USDC_BASE, USDC_BASE_CONTRACT, USDC_SOLANA, type UrlCitation, 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 WebSearchTool, type X402ClientLike, type X402HookContext, type XSearchSource, type XSearchTool, clearCache, createPaymentPayload, createSolanaPaymentPayload, createSolanaWallet, createWallet, LLMClient as default, evmNetwork, extractPaymentDetails, formatFundingMessageCompact, formatNeedsFundingMessage, formatSolanaWalletMigrationNotice, formatWalletCreatedMessage, formatWalletMigrationNotice, getCached, getCachedByRequest, getCostLogSummary, getCostSummary, getEip681Uri, getOrCreateSolanaWallet, getOrCreateWallet, getPaymentLinks, getWalletAddress, importSolanaWallet, importWallet, listDiscoveredSolanaWallets, listDiscoveredWallets, loadSolanaWallet, loadWallet, logCost, parsePaymentRequired, readSettlement, retryDisposition, saveSolanaWallet, saveToCache, saveWallet, scanSolanaWallets, scanWallets, setCache, setupAgentClient, setupAgentSolanaWallet, setupAgentWallet, solanaClient, solanaKeyToBytes, solanaPublicKey, status, toWireSearchParameters, toWireTools, validateMaxTokens, validateModel, validateTemperature, validateTopP };
4587
+ export { APIError, API_KEY_URL, ARC_CHAIN_ID, AnthropicClient, type AnyTool, type ApiKeyOptions, type AudioModel, type AudioTrack, BASE_CHAIN_ID, BLOCKRUN_SOL_OPERATOR, type BarResolution, type BatchAttempt, BatchChannelLockedError, BatchCloseDeferredError, type BatchPayloadKind, BatchPaymentUnresolvedError, type BatchUnresolvedReason, 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, DEFAULT_BATCH_IN_DOUBT, DEFAULT_BATCH_LOCK_WAIT_MS, DEFAULT_BATCH_RATE_LIMIT, EVM_NETWORKS, type EvmNetwork, 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, PORTAL_URL, 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 ReasoningEffort, type Rechallenge, type ResponseFormat, RetiredEndpointError, type RetryDisposition, type RoutingDecision, type RoutingProfile, type RoutingTaskType, type RoutingTier, type RoutingTierConfig, 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 Settlement, type SmartChatCompletionOptions, type SmartChatCompletionResponse, type SmartChatOptions, type SmartChatResponse, type SolanaBatchEvent, type SolanaBatchOptions, SolanaBatchPayer, type SolanaBatchPayerInit, type SolanaBatchStats, 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_ARC, USDC_BASE, USDC_BASE_CONTRACT, USDC_SOLANA, type UrlCitation, 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 WebSearchTool, type X402ClientLike, type X402HookContext, type XSearchSource, type XSearchTool, clearCache, createPaymentPayload, createSolanaPaymentPayload, createSolanaWallet, createWallet, LLMClient as default, evmNetwork, extractPaymentDetails, formatFundingMessageCompact, formatNeedsFundingMessage, formatSolanaWalletMigrationNotice, formatWalletCreatedMessage, formatWalletMigrationNotice, getCached, getCachedByRequest, getCostLogSummary, getCostSummary, getEip681Uri, getOrCreateSolanaWallet, getOrCreateWallet, getPaymentLinks, getWalletAddress, importSolanaWallet, importWallet, listDiscoveredSolanaWallets, listDiscoveredWallets, loadSolanaWallet, loadWallet, logCost, parsePaymentRequired, readSettlement, retryDisposition, saveSolanaWallet, saveToCache, saveWallet, scanSolanaWallets, scanWallets, setCache, setupAgentClient, setupAgentSolanaWallet, setupAgentWallet, solanaClient, solanaKeyToBytes, solanaPublicKey, status, toWireSearchParameters, toWireTools, validateMaxTokens, validateModel, validateTemperature, validateTopP };
package/dist/index.js CHANGED
@@ -136,6 +136,18 @@ function validateApiUrl(url) {
136
136
  );
137
137
  }
138
138
  }
139
+ var PAYMENT_FACT_FIELDS = ["payment_status", "tx_hash", "payment_note"];
140
+ function paymentFactsNote(errorBody) {
141
+ if (typeof errorBody !== "object" || errorBody === null) return "";
142
+ const { payment_status: status2, tx_hash: txHash } = errorBody;
143
+ if (status2 === "settled") {
144
+ const tx = typeof txHash === "string" && txHash ? ` (tx ${txHash})` : "";
145
+ return `. Payment settled${tx}. Do not pay for this job again.`;
146
+ }
147
+ if (status2 === "unknown") return ". Payment state unknown. Check your wallet before paying again.";
148
+ if (status2 === "not_charged" || status2 === "settlement_failed") return ". No payment was taken.";
149
+ return "";
150
+ }
139
151
  function sanitizeErrorResponse(errorBody) {
140
152
  if (typeof errorBody !== "object" || errorBody === null) {
141
153
  return { message: "API request failed" };
@@ -146,7 +158,10 @@ function sanitizeErrorResponse(errorBody) {
146
158
  message: typeof body.error === "string" ? body.error : "API request failed",
147
159
  code: typeof body.code === "string" ? body.code : void 0,
148
160
  ...detail ? { detail } : {},
149
- ...typeof body.hint === "string" ? { hint: body.hint } : {}
161
+ ...typeof body.hint === "string" ? { hint: body.hint } : {},
162
+ ...Object.fromEntries(
163
+ PAYMENT_FACT_FIELDS.filter((field) => typeof body[field] === "string").map((field) => [field, body[field]])
164
+ )
150
165
  };
151
166
  }
152
167
  function validateResourceUrl(url, baseUrl) {
@@ -4916,10 +4931,16 @@ function parsePaymentRequired(headerValue) {
4916
4931
  }
4917
4932
  }
4918
4933
  function extractPaymentDetails(paymentRequired, preferredNetwork) {
4919
- const accepts = paymentRequired.accepts || [];
4920
- if (accepts.length === 0) {
4934
+ const offered = paymentRequired.accepts || [];
4935
+ if (offered.length === 0) {
4921
4936
  throw new Error("No payment options in payment required response");
4922
4937
  }
4938
+ const accepts = offered.filter((opt) => !opt.scheme || opt.scheme === "exact");
4939
+ if (accepts.length === 0) {
4940
+ throw new Error(
4941
+ `This client signs the exact scheme, but the 402 only offers ${offered.map((opt) => JSON.stringify(opt.scheme)).join(", ")}`
4942
+ );
4943
+ }
4923
4944
  let option = null;
4924
4945
  if (preferredNetwork) {
4925
4946
  option = accepts.find((opt) => opt.network === preferredNetwork) || null;
@@ -4989,7 +5010,7 @@ function getCostSummary() {
4989
5010
  }
4990
5011
 
4991
5012
  // src/version.ts
4992
- var SDK_VERSION = "3.25.0";
5013
+ var SDK_VERSION = "3.26.3";
4993
5014
  var USER_AGENT = `blockrun-ts/${SDK_VERSION}`;
4994
5015
 
4995
5016
  // src/client.ts
@@ -5118,6 +5139,7 @@ var LLMClient = class _LLMClient {
5118
5139
  searchParameters: options?.searchParameters,
5119
5140
  responseFormat: options?.responseFormat,
5120
5141
  stop: options?.stop,
5142
+ reasoningEffort: options?.reasoningEffort,
5121
5143
  fallbackModels: options?.fallbackModels
5122
5144
  });
5123
5145
  return result.choices[0].message.content || "";
@@ -5190,6 +5212,7 @@ var LLMClient = class _LLMClient {
5190
5212
  searchParameters: options?.searchParameters,
5191
5213
  responseFormat: options?.responseFormat,
5192
5214
  stop: options?.stop,
5215
+ reasoningEffort: options?.reasoningEffort,
5193
5216
  // An explicit caller-supplied chain wins over the routed one.
5194
5217
  fallbackModels: options?.fallbackModels ?? decision.fallbacks
5195
5218
  });
@@ -5227,6 +5250,7 @@ var LLMClient = class _LLMClient {
5227
5250
  toolChoice: options.toolChoice,
5228
5251
  responseFormat: options.responseFormat,
5229
5252
  stop: options.stop,
5253
+ reasoningEffort: options.reasoningEffort,
5230
5254
  timeout: options.timeout,
5231
5255
  // An explicit caller-supplied chain wins over the routed one.
5232
5256
  fallbackModels: options.fallbackModels ?? decision.fallbacks
@@ -5313,6 +5337,7 @@ var LLMClient = class _LLMClient {
5313
5337
  if (options?.toolChoice !== void 0) body.tool_choice = options.toolChoice;
5314
5338
  if (options?.responseFormat !== void 0) body.response_format = options.responseFormat;
5315
5339
  if (options?.stop !== void 0) body.stop = options.stop;
5340
+ if (options?.reasoningEffort !== void 0) body.reasoning_effort = options.reasoningEffort;
5316
5341
  return body;
5317
5342
  };
5318
5343
  const chain = [model, ...options?.fallbackModels ?? []];
@@ -5686,6 +5711,7 @@ var LLMClient = class _LLMClient {
5686
5711
  if (options?.toolChoice !== void 0) body.tool_choice = options.toolChoice;
5687
5712
  if (options?.responseFormat !== void 0) body.response_format = options.responseFormat;
5688
5713
  if (options?.stop !== void 0) body.stop = options.stop;
5714
+ if (options?.reasoningEffort !== void 0) body.reasoning_effort = options.reasoningEffort;
5689
5715
  const cacheKey2 = `/v1/chat/completions:${requestModel}`;
5690
5716
  const requestBody = JSON.stringify(body);
5691
5717
  const cached = this.preAuthCache.get(cacheKey2);
@@ -6940,6 +6966,9 @@ import { privateKeyToAccount as privateKeyToAccount3 } from "viem/accounts";
6940
6966
  var DEFAULT_API_URL3 = "https://blockrun.ai/api";
6941
6967
  var DEFAULT_MODEL2 = "minimax/music-2.5+";
6942
6968
  var DEFAULT_TIMEOUT3 = 21e4;
6969
+ var POLL_INTERVAL_MS2 = 5e3;
6970
+ var POLL_MAX_DURATION_MS2 = 3e5;
6971
+ var TRANSIENT_POLL_STATUSES = /* @__PURE__ */ new Set([502, 503, 504]);
6943
6972
  var MusicClient = class {
6944
6973
  _account;
6945
6974
  get account() {
@@ -7081,15 +7110,79 @@ var MusicClient = class {
7081
7110
  }
7082
7111
  throw new APIError(`API error after payment: ${retryResponse.status}`, retryResponse.status, sanitizeErrorResponse(errorBody));
7083
7112
  }
7113
+ const costUsd = Number(details.amount) / 1e6;
7084
7114
  const data = await retryResponse.json();
7085
- if (!settlementSkipped(retryResponse)) {
7115
+ if (retryResponse.status === 202 || data.status === "queued" || data.status === "in_progress") {
7116
+ if (!data.poll_url) {
7117
+ throw new APIError(
7118
+ `Server returned ${retryResponse.status} but no poll_url to follow.`,
7119
+ retryResponse.status,
7120
+ sanitizeErrorResponse(data)
7121
+ );
7122
+ }
7123
+ return this.pollMusicJob(data.poll_url, paymentPayload, costUsd);
7124
+ }
7125
+ return this.finishPaidResponse(retryResponse, data, costUsd);
7126
+ }
7127
+ finishPaidResponse(response, data, costUsd) {
7128
+ if (!settlementSkipped(response)) {
7086
7129
  this.sessionCalls++;
7087
- this.sessionTotalUsd += 0.1575;
7130
+ this.sessionTotalUsd += costUsd;
7088
7131
  }
7089
- const txHash = retryResponse.headers.get("x-payment-receipt") || retryResponse.headers.get("X-Payment-Receipt");
7132
+ const txHash = response.headers.get("x-payment-receipt");
7090
7133
  if (txHash) data.txHash = txHash;
7091
7134
  return data;
7092
7135
  }
7136
+ /**
7137
+ * Poll a slow track until it completes, sending the SAME payment header each
7138
+ * time: the server binds the payer to the job and settles on the first poll
7139
+ * that sees it completed.
7140
+ *
7141
+ * Network errors and 502/503/504 keep polling. A response lost on the settling
7142
+ * poll would otherwise drop a track that was paid for, and polling again returns
7143
+ * it as already settled, with no second charge.
7144
+ */
7145
+ async pollMusicJob(pollPath, paymentHeader, costUsd) {
7146
+ const pollUrl = pollPath.startsWith("/api/") ? `${this.apiUrl.replace(/\/api$/, "")}${pollPath}` : `${this.apiUrl}${pollPath.startsWith("/") ? "" : "/"}${pollPath}`;
7147
+ const startedAt = Date.now();
7148
+ while (Date.now() - startedAt < POLL_MAX_DURATION_MS2) {
7149
+ await new Promise((resolve2) => setTimeout(resolve2, POLL_INTERVAL_MS2));
7150
+ let pollResp;
7151
+ try {
7152
+ pollResp = await this.fetchWithTimeout(pollUrl, {
7153
+ method: "GET",
7154
+ headers: { "PAYMENT-SIGNATURE": paymentHeader }
7155
+ });
7156
+ } catch {
7157
+ continue;
7158
+ }
7159
+ if (pollResp.status === 202 || TRANSIENT_POLL_STATUSES.has(pollResp.status)) continue;
7160
+ const pollBody = await pollResp.json().catch(() => ({}));
7161
+ if (!pollResp.ok) {
7162
+ throw new APIError(
7163
+ `API error during poll of ${pollPath}: ${pollResp.status}`,
7164
+ pollResp.status,
7165
+ sanitizeErrorResponse(pollBody)
7166
+ );
7167
+ }
7168
+ if (pollBody.status === "failed") {
7169
+ throw new APIError(
7170
+ pollBody.error || "Upstream music generation failed",
7171
+ 200,
7172
+ sanitizeErrorResponse(pollBody)
7173
+ );
7174
+ }
7175
+ if (pollBody.data) {
7176
+ if (!pollBody.txHash && pollBody.payment?.tx_hash) pollBody.txHash = pollBody.payment.tx_hash;
7177
+ return this.finishPaidResponse(pollResp, pollBody, costUsd);
7178
+ }
7179
+ }
7180
+ throw new APIError(
7181
+ `Music generation did not finish within ${POLL_MAX_DURATION_MS2 / 1e3}s. The job may still complete: poll poll_url with the same payment header before paying again.`,
7182
+ 504,
7183
+ { error: "poll_timeout", poll_url: pollPath }
7184
+ );
7185
+ }
7093
7186
  async fetchWithTimeout(url, options) {
7094
7187
  const controller = new AbortController();
7095
7188
  const timeoutId = setTimeout(() => controller.abort(), this.timeout);
@@ -7329,7 +7422,7 @@ import { privateKeyToAccount as privateKeyToAccount5 } from "viem/accounts";
7329
7422
  var DEFAULT_API_URL5 = "https://blockrun.ai/api";
7330
7423
  var DEFAULT_MODEL4 = "xai/grok-imagine-video";
7331
7424
  var DEFAULT_TIMEOUT5 = 12e4;
7332
- var POLL_INTERVAL_MS2 = 5e3;
7425
+ var POLL_INTERVAL_MS3 = 5e3;
7333
7426
  var DEFAULT_GENERATE_BUDGET_MS = 9e5;
7334
7427
  var MAX_TIMEOUT_SECONDS = 600;
7335
7428
  var MAX_POLL_RESIGNS = 2;
@@ -7540,7 +7633,7 @@ var VideoClient = class {
7540
7633
  headers: { "Content-Type": "application/json" },
7541
7634
  body: JSON.stringify(body)
7542
7635
  });
7543
- if (this.apiAuth) return this.apiAuth.poll(resp402, budgetMs, POLL_INTERVAL_MS2);
7636
+ if (this.apiAuth) return this.apiAuth.poll(resp402, budgetMs, POLL_INTERVAL_MS3);
7544
7637
  if (resp402.status !== 402) {
7545
7638
  await this.throwApiError(resp402, "Expected 402 on first POST");
7546
7639
  }
@@ -7575,7 +7668,7 @@ var VideoClient = class {
7575
7668
  let lastStatus = submitData.status || "queued";
7576
7669
  let resignsLeft = MAX_POLL_RESIGNS;
7577
7670
  while (Date.now() < deadline) {
7578
- await new Promise((r) => setTimeout(r, POLL_INTERVAL_MS2));
7671
+ await new Promise((r) => setTimeout(r, POLL_INTERVAL_MS3));
7579
7672
  const pollResp = await this.fetchWithTimeout(pollUrl, {
7580
7673
  method: "GET",
7581
7674
  headers: { "PAYMENT-SIGNATURE": paymentPayload }
@@ -9308,7 +9401,7 @@ var BlockrunClient = class {
9308
9401
  }
9309
9402
  if (lastStatus === "failed") {
9310
9403
  throw new APIError(
9311
- `Upstream job failed: ${pollData.error || "unknown"}`,
9404
+ `Upstream job failed: ${pollData.error || "unknown"}${paymentFactsNote(pollData)}`,
9312
9405
  pollResp.status,
9313
9406
  sanitizeErrorResponse(pollData)
9314
9407
  );
@@ -9819,11 +9912,11 @@ var WALLET_DIR = path4.join(os3.homedir(), ".blockrun");
9819
9912
  var SOLANA_WALLET_FILE = path4.join(WALLET_DIR, ".solana-session");
9820
9913
  async function createSolanaWallet() {
9821
9914
  const { Keypair } = await loadSolanaWeb3("Solana wallet operations");
9822
- const bs583 = await import("bs58");
9915
+ const bs582 = await import("bs58");
9823
9916
  const keypair = Keypair.generate();
9824
9917
  return {
9825
9918
  address: keypair.publicKey.toBase58(),
9826
- privateKey: (bs583.default ?? bs583).encode(keypair.secretKey)
9919
+ privateKey: (bs582.default ?? bs582).encode(keypair.secretKey)
9827
9920
  };
9828
9921
  }
9829
9922
  async function solanaKeyToBytes(privateKey) {
@@ -9861,8 +9954,8 @@ async function solanaKeyToBytes(privateKey) {
9861
9954
  return bytes;
9862
9955
  }
9863
9956
  try {
9864
- const bs583 = await import("bs58");
9865
- const bytes = (bs583.default ?? bs583).decode(key);
9957
+ const bs582 = await import("bs58");
9958
+ const bytes = (bs582.default ?? bs582).decode(key);
9866
9959
  if (bytes.length !== 64) {
9867
9960
  throw new Error(`Invalid Solana key length: expected 64 bytes, got ${bytes.length}`);
9868
9961
  }
@@ -10043,7 +10136,19 @@ async function getOrCreateSolanaWallet() {
10043
10136
 
10044
10137
  // src/poll-ownership.ts
10045
10138
  import { createPrivateKey, createPublicKey, sign as ed25519Sign } from "crypto";
10046
- import bs58 from "bs58";
10139
+
10140
+ // src/bs58.ts
10141
+ import bs58Import from "bs58";
10142
+ function unwrapBs58(mod) {
10143
+ const m = mod;
10144
+ if (typeof m?.encode === "function") return m;
10145
+ const inner = m?.default;
10146
+ if (typeof inner?.encode === "function") return inner;
10147
+ throw new Error("bs58: no encode() on the module or its default export");
10148
+ }
10149
+ var bs58 = unwrapBs58(bs58Import);
10150
+
10151
+ // src/poll-ownership.ts
10047
10152
  var POLL_AUTH_HEADERS = {
10048
10153
  wallet: "x-poll-wallet",
10049
10154
  timestamp: "x-poll-timestamp",
@@ -10086,7 +10191,6 @@ import { AsyncLocalStorage } from "async_hooks";
10086
10191
  import { randomUUID } from "crypto";
10087
10192
  import * as fs6 from "fs";
10088
10193
  import * as path5 from "path";
10089
- import bs582 from "bs58";
10090
10194
  var BATCH_SCHEME = "batch-settlement";
10091
10195
  var BLOCKRUN_SOL_OPERATOR = "5YKPQUFjw5WQqhSUkEGKNNfYYVqnRRNbpYyL71qQ1vm3";
10092
10196
  var DEFAULT_BATCH_RATE_LIMIT = { maxAttempts: 3, maxWaitMs: 6e4 };
@@ -10665,7 +10769,7 @@ function decodeChannelAccount(owner, data) {
10665
10769
  return void 0;
10666
10770
  }
10667
10771
  const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
10668
- const key = (offset) => bs582.encode(data.subarray(offset, offset + 32));
10772
+ const key = (offset) => bs58.encode(data.subarray(offset, offset + 32));
10669
10773
  return {
10670
10774
  deposit: view.getBigUint64(CHANNEL.deposit, true),
10671
10775
  settled: view.getBigUint64(CHANNEL.settled, true),
@@ -12936,6 +13040,7 @@ var SolanaLLMClient = class {
12936
13040
  searchParameters: options?.searchParameters,
12937
13041
  responseFormat: options?.responseFormat,
12938
13042
  stop: options?.stop,
13043
+ reasoningEffort: options?.reasoningEffort,
12939
13044
  fallbackModels: options?.fallbackModels
12940
13045
  });
12941
13046
  return result.choices[0].message.content || "";
@@ -12964,6 +13069,7 @@ var SolanaLLMClient = class {
12964
13069
  if (options?.toolChoice !== void 0) body.tool_choice = options.toolChoice;
12965
13070
  if (options?.responseFormat !== void 0) body.response_format = options.responseFormat;
12966
13071
  if (options?.stop !== void 0) body.stop = options.stop;
13072
+ if (options?.reasoningEffort !== void 0) body.reasoning_effort = options.reasoningEffort;
12967
13073
  return body;
12968
13074
  };
12969
13075
  const chain = [model, ...options?.fallbackModels ?? []];
@@ -13068,6 +13174,7 @@ var SolanaLLMClient = class {
13068
13174
  toolChoice: options.toolChoice,
13069
13175
  responseFormat: options.responseFormat,
13070
13176
  stop: options.stop,
13177
+ reasoningEffort: options.reasoningEffort,
13071
13178
  timeout: options.timeout,
13072
13179
  // An explicit caller-supplied chain wins over the routed one.
13073
13180
  fallbackModels: options.fallbackModels ?? decision.fallbacks
@@ -13266,7 +13373,8 @@ var SolanaLLMClient = class {
13266
13373
  *
13267
13374
  * The POST is verified, not charged. The job is then polled with a wallet
13268
13375
  * signature (no payment) until it finishes, and ONE payment is signed for
13269
- * the finished video; a failed job is never charged. If the gateway does not
13376
+ * the finished video; a job that fails before completing is not charged. A paid
13377
+ * job can still fail, and its APIError then carries `payment_status`. If the gateway does not
13270
13378
  * accept poll signatures for the job, it is polled with a payment per poll
13271
13379
  * instead, which is likewise only charged on completion.
13272
13380
  *
@@ -13634,7 +13742,8 @@ var SolanaLLMClient = class {
13634
13742
  * cost at POST; this loop only fetches the result and never signs a payment.
13635
13743
  * A batch-billed image job still answers its proof poll with 402: that job
13636
13744
  * falls back to the per-poll payment below.
13637
- * - video: settles on completion, and a failed job is never charged. A
13745
+ * - video: settles on completion. A job that fails before completing is not
13746
+ * charged; one that fails after payment says so in `payment_status`. A
13638
13747
  * finished, unpaid job answers the proof poll with 402 `{status:"completed"}`
13639
13748
  * and a normal x402 challenge; ONE payment is signed from that challenge and
13640
13749
  * the same poll is re-sent with it. The cost is recorded here, on delivery.
@@ -13681,7 +13790,7 @@ var SolanaLLMClient = class {
13681
13790
  const failIfFailed = (data, status2) => {
13682
13791
  if (lastStatus === "failed") {
13683
13792
  throw new APIError(
13684
- `Upstream job failed: ${data.error || "unknown"}`,
13793
+ `Upstream job failed: ${data.error || "unknown"}${paymentFactsNote(data)}`,
13685
13794
  status2,
13686
13795
  sanitizeErrorResponse(data)
13687
13796
  );
@@ -14427,7 +14536,8 @@ var ChatCompletions = class {
14427
14536
  tools: params.tools,
14428
14537
  toolChoice: params.tool_choice,
14429
14538
  responseFormat: params.response_format,
14430
- stop: params.stop
14539
+ stop: params.stop,
14540
+ reasoningEffort: params.reasoning_effort
14431
14541
  }
14432
14542
  );
14433
14543
  return this.transformResponse(response);
@@ -14443,7 +14553,8 @@ var ChatCompletions = class {
14443
14553
  tools: params.tools,
14444
14554
  toolChoice: params.tool_choice,
14445
14555
  responseFormat: params.response_format,
14446
- stop: params.stop
14556
+ stop: params.stop,
14557
+ reasoningEffort: params.reasoning_effort
14447
14558
  }
14448
14559
  );
14449
14560
  return new StreamingResponse(response, params.model);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockrun/llm",
3
- "version": "3.25.0",
3
+ "version": "3.26.3",
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",