@blockrun/llm 4.0.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/index.cjs +350 -48
- package/dist/index.d.cts +110 -6
- package/dist/index.d.ts +110 -6
- package/dist/index.js +345 -48
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -985,10 +985,9 @@ interface VideoGenerateOptions {
|
|
|
985
985
|
/**
|
|
986
986
|
* Whether the model should produce a synced audio track. Token360 / Seedance
|
|
987
987
|
* only — silently ignored by xAI Grok. When omitted, the gateway defaults to
|
|
988
|
-
* `true` for text-to-video
|
|
989
|
-
*
|
|
990
|
-
*
|
|
991
|
-
* surcharge upstream, so callers should expose this as a visible toggle.
|
|
988
|
+
* `true` for every input: text, image-to-video, first/last frame, reference
|
|
989
|
+
* images/video/audio and RealFace. Pass `false` for a silent clip. The price
|
|
990
|
+
* is the same either way.
|
|
992
991
|
*/
|
|
993
992
|
generateAudio?: boolean;
|
|
994
993
|
/** Reproducibility seed when supported by the model. */
|
|
@@ -1335,7 +1334,60 @@ declare class RetiredEndpointError extends BlockrunError {
|
|
|
1335
1334
|
constructor(message: string);
|
|
1336
1335
|
}
|
|
1337
1336
|
declare class PaymentError extends BlockrunError {
|
|
1338
|
-
|
|
1337
|
+
/** HTTP status of the refusal, when it came from the gateway. */
|
|
1338
|
+
statusCode?: number;
|
|
1339
|
+
/** The gateway's refusal body, sanitized; recovery fields kept verbatim. */
|
|
1340
|
+
response?: Record<string, unknown>;
|
|
1341
|
+
constructor(message: string, options?: {
|
|
1342
|
+
statusCode?: number;
|
|
1343
|
+
response?: Record<string, unknown>;
|
|
1344
|
+
});
|
|
1345
|
+
}
|
|
1346
|
+
/** The gateway's `code` for a payment authorization it has already seen. */
|
|
1347
|
+
declare const PAYMENT_REPLAY: "PAYMENT_REPLAY";
|
|
1348
|
+
/**
|
|
1349
|
+
* The EIP-191 challenge the gateway issues for a settled authorization:
|
|
1350
|
+
* sign `message` with the paying wallet and resend the same request with the
|
|
1351
|
+
* headers named in `headers` (`X-Wallet-Address`, `X-Wallet-Timestamp`,
|
|
1352
|
+
* `X-Wallet-Signature`) to get the earlier request's `poll_url`.
|
|
1353
|
+
*/
|
|
1354
|
+
interface WalletAuthChallenge {
|
|
1355
|
+
timestamp: string;
|
|
1356
|
+
message: string;
|
|
1357
|
+
headers: string[];
|
|
1358
|
+
expires_in: number;
|
|
1359
|
+
[key: string]: unknown;
|
|
1360
|
+
}
|
|
1361
|
+
/**
|
|
1362
|
+
* The gateway refused the payment as already used (`code: "PAYMENT_REPLAY"`).
|
|
1363
|
+
*
|
|
1364
|
+
* Not a balance problem. The same signed authorization was already submitted
|
|
1365
|
+
* once (usually a retry or a proxy re-sent it), and that earlier request may
|
|
1366
|
+
* already have been served and charged. The SDK throws this without signing
|
|
1367
|
+
* anything new: a fresh authorization for the same request can be a second
|
|
1368
|
+
* charge.
|
|
1369
|
+
*
|
|
1370
|
+
* Every field the gateway sent is kept verbatim: `serverMessage` / `details`
|
|
1371
|
+
* (its `message` and `details`), `pollUrl` / `jobId` (where the earlier
|
|
1372
|
+
* result can be collected), `walletAuth` (the EIP-191 challenge for a settled
|
|
1373
|
+
* authorization; the SDK does not answer it for you yet) and `payer`.
|
|
1374
|
+
* `response` carries the same fields under the gateway's own key names.
|
|
1375
|
+
* Extends {@link PaymentError}, so existing `instanceof PaymentError` checks
|
|
1376
|
+
* keep working.
|
|
1377
|
+
*/
|
|
1378
|
+
declare class PaymentReplayError extends PaymentError {
|
|
1379
|
+
readonly code: "PAYMENT_REPLAY";
|
|
1380
|
+
serverMessage?: string;
|
|
1381
|
+
details?: string;
|
|
1382
|
+
pollUrl?: string;
|
|
1383
|
+
jobId?: string;
|
|
1384
|
+
recoverable?: boolean;
|
|
1385
|
+
walletAuth?: WalletAuthChallenge;
|
|
1386
|
+
payer?: string;
|
|
1387
|
+
constructor(message: string, options?: {
|
|
1388
|
+
statusCode?: number;
|
|
1389
|
+
response?: Record<string, unknown>;
|
|
1390
|
+
});
|
|
1339
1391
|
}
|
|
1340
1392
|
declare class APIError extends BlockrunError {
|
|
1341
1393
|
statusCode: number;
|
|
@@ -3879,6 +3931,27 @@ declare class SolanaLLMClient {
|
|
|
3879
3931
|
* @returns a response whose body has not been read.
|
|
3880
3932
|
*/
|
|
3881
3933
|
private openPaidStream;
|
|
3934
|
+
/**
|
|
3935
|
+
* Pay a stream with batch-settlement, when the gateway offers it.
|
|
3936
|
+
*
|
|
3937
|
+
* A stream's charge is committed after its headers are sent, so its receipt
|
|
3938
|
+
* cannot be the `PAYMENT-RESPONSE` header the batch payer reconciles a
|
|
3939
|
+
* buffered call with. The request asks for it as a final SSE event instead
|
|
3940
|
+
* ({@link STREAM_RECEIPT_HEADER}). The body is split in two: the caller gets
|
|
3941
|
+
* its branch at once, live, with the receipt event taken out; the payer reads
|
|
3942
|
+
* the other branch to that event and is handed the answer with the receipt
|
|
3943
|
+
* restored as its header, so the channel advances exactly as it does for a
|
|
3944
|
+
* buffered call. A stream that ends without the event (cut, failed upstream,
|
|
3945
|
+
* an older gateway) is looked up at `POST /v1/batch/receipt`.
|
|
3946
|
+
*
|
|
3947
|
+
* The payer's branch reads to the receipt even when the caller stops early,
|
|
3948
|
+
* so the connection stays open: the gateway charges for what the model
|
|
3949
|
+
* generates either way, and only an open stream brings its receipt back.
|
|
3950
|
+
*
|
|
3951
|
+
* @returns the caller's stream, or the requirements to pay `exact` against
|
|
3952
|
+
* when batch is unavailable for this call.
|
|
3953
|
+
*/
|
|
3954
|
+
private openBatchStream;
|
|
3882
3955
|
/**
|
|
3883
3956
|
* Resolve an endpoint path against this client's API root.
|
|
3884
3957
|
*
|
|
@@ -4544,6 +4617,37 @@ declare function validateTemperature(temperature?: number): void;
|
|
|
4544
4617
|
* validateTopP(0.9);
|
|
4545
4618
|
*/
|
|
4546
4619
|
declare function validateTopP(topP?: number): void;
|
|
4620
|
+
/**
|
|
4621
|
+
* Does this response body say `code: "PAYMENT_REPLAY"`? The gateway sends it
|
|
4622
|
+
* when the signed authorization was already submitted once. The earlier
|
|
4623
|
+
* request may have been served and charged, so the answer is never "sign a new
|
|
4624
|
+
* payment and try again".
|
|
4625
|
+
*/
|
|
4626
|
+
declare function isPaymentReplay(body: unknown): boolean;
|
|
4627
|
+
/**
|
|
4628
|
+
* Turn a refused payment's body into the error to throw.
|
|
4629
|
+
*
|
|
4630
|
+
* - `code: "PAYMENT_REPLAY"` (or `replay: true`, for a caller with its own
|
|
4631
|
+
* evidence) gives a {@link PaymentReplayError} carrying the gateway's
|
|
4632
|
+
* `message`, `details`, `poll_url`, `job_id`, `wallet_auth` and `payer`
|
|
4633
|
+
* verbatim. Callers must not answer it by signing again.
|
|
4634
|
+
* - Anything else gives a {@link PaymentError} whose message is the gateway's
|
|
4635
|
+
* reason. Clients used to throw "Payment was rejected. Check your wallet
|
|
4636
|
+
* balance." for every 402, which hid `PAYMENT_MALFORMED`, facilitator
|
|
4637
|
+
* reasons and already-used authorizations behind a balance guess.
|
|
4638
|
+
*
|
|
4639
|
+
* Mirrors the Python SDK's `validation.build_payment_rejected_error`.
|
|
4640
|
+
*/
|
|
4641
|
+
declare function paymentRejectedErrorFromBody(body: unknown, statusCode?: number, options?: {
|
|
4642
|
+
replay?: boolean;
|
|
4643
|
+
}): PaymentError;
|
|
4644
|
+
/**
|
|
4645
|
+
* Read a refused payment's response and turn it into the error to throw. See
|
|
4646
|
+
* {@link paymentRejectedErrorFromBody}. Consumes the body.
|
|
4647
|
+
*/
|
|
4648
|
+
declare function buildPaymentRejectedError(response: Response, options?: {
|
|
4649
|
+
replay?: (body: unknown) => boolean;
|
|
4650
|
+
}): Promise<PaymentError>;
|
|
4547
4651
|
|
|
4548
4652
|
/**
|
|
4549
4653
|
* Wire format for xAI search on the BlockRun gateways.
|
|
@@ -4591,4 +4695,4 @@ declare function readSettlement(response: Response, quotedUsd: number, scheme: S
|
|
|
4591
4695
|
settlement: Settlement;
|
|
4592
4696
|
};
|
|
4593
4697
|
|
|
4594
|
-
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 };
|
|
4698
|
+
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, PAYMENT_REPLAY, PHONE_PRICES, PORTAL_URL, PORTRAIT_ENROLLMENT_PRICE_USD, PaymentError, type PaymentLinks, PaymentReplayError, 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 WalletAuthChallenge, type WalletInfo, type WebSearchSource, type WebSearchTool, type X402ClientLike, type X402HookContext, type XSearchSource, type XSearchTool, buildPaymentRejectedError, 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, isPaymentReplay, listDiscoveredSolanaWallets, listDiscoveredWallets, loadSolanaWallet, loadWallet, logCost, parsePaymentRequired, paymentRejectedErrorFromBody, 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
|
@@ -985,10 +985,9 @@ interface VideoGenerateOptions {
|
|
|
985
985
|
/**
|
|
986
986
|
* Whether the model should produce a synced audio track. Token360 / Seedance
|
|
987
987
|
* only — silently ignored by xAI Grok. When omitted, the gateway defaults to
|
|
988
|
-
* `true` for text-to-video
|
|
989
|
-
*
|
|
990
|
-
*
|
|
991
|
-
* surcharge upstream, so callers should expose this as a visible toggle.
|
|
988
|
+
* `true` for every input: text, image-to-video, first/last frame, reference
|
|
989
|
+
* images/video/audio and RealFace. Pass `false` for a silent clip. The price
|
|
990
|
+
* is the same either way.
|
|
992
991
|
*/
|
|
993
992
|
generateAudio?: boolean;
|
|
994
993
|
/** Reproducibility seed when supported by the model. */
|
|
@@ -1335,7 +1334,60 @@ declare class RetiredEndpointError extends BlockrunError {
|
|
|
1335
1334
|
constructor(message: string);
|
|
1336
1335
|
}
|
|
1337
1336
|
declare class PaymentError extends BlockrunError {
|
|
1338
|
-
|
|
1337
|
+
/** HTTP status of the refusal, when it came from the gateway. */
|
|
1338
|
+
statusCode?: number;
|
|
1339
|
+
/** The gateway's refusal body, sanitized; recovery fields kept verbatim. */
|
|
1340
|
+
response?: Record<string, unknown>;
|
|
1341
|
+
constructor(message: string, options?: {
|
|
1342
|
+
statusCode?: number;
|
|
1343
|
+
response?: Record<string, unknown>;
|
|
1344
|
+
});
|
|
1345
|
+
}
|
|
1346
|
+
/** The gateway's `code` for a payment authorization it has already seen. */
|
|
1347
|
+
declare const PAYMENT_REPLAY: "PAYMENT_REPLAY";
|
|
1348
|
+
/**
|
|
1349
|
+
* The EIP-191 challenge the gateway issues for a settled authorization:
|
|
1350
|
+
* sign `message` with the paying wallet and resend the same request with the
|
|
1351
|
+
* headers named in `headers` (`X-Wallet-Address`, `X-Wallet-Timestamp`,
|
|
1352
|
+
* `X-Wallet-Signature`) to get the earlier request's `poll_url`.
|
|
1353
|
+
*/
|
|
1354
|
+
interface WalletAuthChallenge {
|
|
1355
|
+
timestamp: string;
|
|
1356
|
+
message: string;
|
|
1357
|
+
headers: string[];
|
|
1358
|
+
expires_in: number;
|
|
1359
|
+
[key: string]: unknown;
|
|
1360
|
+
}
|
|
1361
|
+
/**
|
|
1362
|
+
* The gateway refused the payment as already used (`code: "PAYMENT_REPLAY"`).
|
|
1363
|
+
*
|
|
1364
|
+
* Not a balance problem. The same signed authorization was already submitted
|
|
1365
|
+
* once (usually a retry or a proxy re-sent it), and that earlier request may
|
|
1366
|
+
* already have been served and charged. The SDK throws this without signing
|
|
1367
|
+
* anything new: a fresh authorization for the same request can be a second
|
|
1368
|
+
* charge.
|
|
1369
|
+
*
|
|
1370
|
+
* Every field the gateway sent is kept verbatim: `serverMessage` / `details`
|
|
1371
|
+
* (its `message` and `details`), `pollUrl` / `jobId` (where the earlier
|
|
1372
|
+
* result can be collected), `walletAuth` (the EIP-191 challenge for a settled
|
|
1373
|
+
* authorization; the SDK does not answer it for you yet) and `payer`.
|
|
1374
|
+
* `response` carries the same fields under the gateway's own key names.
|
|
1375
|
+
* Extends {@link PaymentError}, so existing `instanceof PaymentError` checks
|
|
1376
|
+
* keep working.
|
|
1377
|
+
*/
|
|
1378
|
+
declare class PaymentReplayError extends PaymentError {
|
|
1379
|
+
readonly code: "PAYMENT_REPLAY";
|
|
1380
|
+
serverMessage?: string;
|
|
1381
|
+
details?: string;
|
|
1382
|
+
pollUrl?: string;
|
|
1383
|
+
jobId?: string;
|
|
1384
|
+
recoverable?: boolean;
|
|
1385
|
+
walletAuth?: WalletAuthChallenge;
|
|
1386
|
+
payer?: string;
|
|
1387
|
+
constructor(message: string, options?: {
|
|
1388
|
+
statusCode?: number;
|
|
1389
|
+
response?: Record<string, unknown>;
|
|
1390
|
+
});
|
|
1339
1391
|
}
|
|
1340
1392
|
declare class APIError extends BlockrunError {
|
|
1341
1393
|
statusCode: number;
|
|
@@ -3879,6 +3931,27 @@ declare class SolanaLLMClient {
|
|
|
3879
3931
|
* @returns a response whose body has not been read.
|
|
3880
3932
|
*/
|
|
3881
3933
|
private openPaidStream;
|
|
3934
|
+
/**
|
|
3935
|
+
* Pay a stream with batch-settlement, when the gateway offers it.
|
|
3936
|
+
*
|
|
3937
|
+
* A stream's charge is committed after its headers are sent, so its receipt
|
|
3938
|
+
* cannot be the `PAYMENT-RESPONSE` header the batch payer reconciles a
|
|
3939
|
+
* buffered call with. The request asks for it as a final SSE event instead
|
|
3940
|
+
* ({@link STREAM_RECEIPT_HEADER}). The body is split in two: the caller gets
|
|
3941
|
+
* its branch at once, live, with the receipt event taken out; the payer reads
|
|
3942
|
+
* the other branch to that event and is handed the answer with the receipt
|
|
3943
|
+
* restored as its header, so the channel advances exactly as it does for a
|
|
3944
|
+
* buffered call. A stream that ends without the event (cut, failed upstream,
|
|
3945
|
+
* an older gateway) is looked up at `POST /v1/batch/receipt`.
|
|
3946
|
+
*
|
|
3947
|
+
* The payer's branch reads to the receipt even when the caller stops early,
|
|
3948
|
+
* so the connection stays open: the gateway charges for what the model
|
|
3949
|
+
* generates either way, and only an open stream brings its receipt back.
|
|
3950
|
+
*
|
|
3951
|
+
* @returns the caller's stream, or the requirements to pay `exact` against
|
|
3952
|
+
* when batch is unavailable for this call.
|
|
3953
|
+
*/
|
|
3954
|
+
private openBatchStream;
|
|
3882
3955
|
/**
|
|
3883
3956
|
* Resolve an endpoint path against this client's API root.
|
|
3884
3957
|
*
|
|
@@ -4544,6 +4617,37 @@ declare function validateTemperature(temperature?: number): void;
|
|
|
4544
4617
|
* validateTopP(0.9);
|
|
4545
4618
|
*/
|
|
4546
4619
|
declare function validateTopP(topP?: number): void;
|
|
4620
|
+
/**
|
|
4621
|
+
* Does this response body say `code: "PAYMENT_REPLAY"`? The gateway sends it
|
|
4622
|
+
* when the signed authorization was already submitted once. The earlier
|
|
4623
|
+
* request may have been served and charged, so the answer is never "sign a new
|
|
4624
|
+
* payment and try again".
|
|
4625
|
+
*/
|
|
4626
|
+
declare function isPaymentReplay(body: unknown): boolean;
|
|
4627
|
+
/**
|
|
4628
|
+
* Turn a refused payment's body into the error to throw.
|
|
4629
|
+
*
|
|
4630
|
+
* - `code: "PAYMENT_REPLAY"` (or `replay: true`, for a caller with its own
|
|
4631
|
+
* evidence) gives a {@link PaymentReplayError} carrying the gateway's
|
|
4632
|
+
* `message`, `details`, `poll_url`, `job_id`, `wallet_auth` and `payer`
|
|
4633
|
+
* verbatim. Callers must not answer it by signing again.
|
|
4634
|
+
* - Anything else gives a {@link PaymentError} whose message is the gateway's
|
|
4635
|
+
* reason. Clients used to throw "Payment was rejected. Check your wallet
|
|
4636
|
+
* balance." for every 402, which hid `PAYMENT_MALFORMED`, facilitator
|
|
4637
|
+
* reasons and already-used authorizations behind a balance guess.
|
|
4638
|
+
*
|
|
4639
|
+
* Mirrors the Python SDK's `validation.build_payment_rejected_error`.
|
|
4640
|
+
*/
|
|
4641
|
+
declare function paymentRejectedErrorFromBody(body: unknown, statusCode?: number, options?: {
|
|
4642
|
+
replay?: boolean;
|
|
4643
|
+
}): PaymentError;
|
|
4644
|
+
/**
|
|
4645
|
+
* Read a refused payment's response and turn it into the error to throw. See
|
|
4646
|
+
* {@link paymentRejectedErrorFromBody}. Consumes the body.
|
|
4647
|
+
*/
|
|
4648
|
+
declare function buildPaymentRejectedError(response: Response, options?: {
|
|
4649
|
+
replay?: (body: unknown) => boolean;
|
|
4650
|
+
}): Promise<PaymentError>;
|
|
4547
4651
|
|
|
4548
4652
|
/**
|
|
4549
4653
|
* Wire format for xAI search on the BlockRun gateways.
|
|
@@ -4591,4 +4695,4 @@ declare function readSettlement(response: Response, quotedUsd: number, scheme: S
|
|
|
4591
4695
|
settlement: Settlement;
|
|
4592
4696
|
};
|
|
4593
4697
|
|
|
4594
|
-
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 };
|
|
4698
|
+
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, PAYMENT_REPLAY, PHONE_PRICES, PORTAL_URL, PORTRAIT_ENROLLMENT_PRICE_USD, PaymentError, type PaymentLinks, PaymentReplayError, 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 WalletAuthChallenge, type WalletInfo, type WebSearchSource, type WebSearchTool, type X402ClientLike, type X402HookContext, type XSearchSource, type XSearchTool, buildPaymentRejectedError, 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, isPaymentReplay, listDiscoveredSolanaWallets, listDiscoveredWallets, loadSolanaWallet, loadWallet, logCost, parsePaymentRequired, paymentRejectedErrorFromBody, readSettlement, retryDisposition, saveSolanaWallet, saveToCache, saveWallet, scanSolanaWallets, scanWallets, setCache, setupAgentClient, setupAgentSolanaWallet, setupAgentWallet, solanaClient, solanaKeyToBytes, solanaPublicKey, status, toWireSearchParameters, toWireTools, validateMaxTokens, validateModel, validateTemperature, validateTopP };
|