@blockrun/llm 3.17.1 → 3.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -770,6 +770,10 @@ interface VideoClip {
770
770
  request_id?: string;
771
771
  /** True when the gateway mirrored the video to its GCS bucket */
772
772
  backed_up?: boolean;
773
+ /** Final frame image when returnLastFrame is requested and the provider returns it. */
774
+ last_frame_url?: string;
775
+ /** Whether the final frame was mirrored to BlockRun storage. */
776
+ last_frame_backed_up?: boolean;
773
777
  }
774
778
  interface VideoResponse {
775
779
  created: number;
@@ -813,18 +817,55 @@ interface VideoGenerateOptions {
813
817
  * First-and-last-frame interpolation: a second image that seeds the FINAL
814
818
  * frame so the model tweens from `imageUrl` → `lastFrameUrl`. Requires
815
819
  * `imageUrl` (the first frame) and a Seedance model
816
- * (bytedance/seedance-1.5-pro, seedance-2.0, or seedance-2.0-fast).
820
+ * (1.5-pro, 2.0 / Fast / Mini, or 2.5).
817
821
  * Priced identically to image-to-video. Mutually exclusive with
818
822
  * `realFaceAssetId`.
819
823
  */
820
824
  lastFrameUrl?: string;
821
825
  /**
822
- * Omni / multi-reference: up to 9 reference image URLs for character/style
823
- * consistency (**Seedance 2.0 only**). Cite them as "image 1", "image 2"
824
- * in the prompt. Mutually exclusive with `imageUrl` / `lastFrameUrl` /
825
- * `realFaceAssetId`.
826
+ * Omni / multi-reference: up to 9 (Seedance 2.0 / Fast / Mini) or 30
827
+ * (Seedance 2.5) reference image URLs for character/style consistency. Cite
828
+ * them as "image 1", "image 2" in the prompt. Mutually exclusive with
829
+ * `imageUrl` / `lastFrameUrl` / `realFaceAssetId`.
830
+ *
831
+ * **Account API key only.** Reference media is served by `api.blockrun.ai`;
832
+ * the wallet gateways (blockrun.ai, sol.blockrun.ai) refuse it with a 400
833
+ * before any payment.
826
834
  */
827
835
  referenceImageUrls?: string[];
836
+ /**
837
+ * Reference-to-video: 1–3 http(s) motion/style video clips (Seedance 2.0 /
838
+ * Fast / Mini). May be combined with `referenceImageUrls`; mutually exclusive
839
+ * with frame seeds. `role` is optional and, when set, must be `"reference"`.
840
+ * Adds a per-clip surcharge. **Account API key only** (see `referenceImageUrls`).
841
+ */
842
+ referenceVideos?: Array<{
843
+ url: string;
844
+ role?: "reference";
845
+ }>;
846
+ /**
847
+ * Reference audio: 1–3 http(s) clips, each ≤15.2s (Seedance 2.0 / Fast /
848
+ * Mini). Requires `referenceImageUrls` or `referenceVideos` alongside it.
849
+ * Adds a per-clip surcharge. **Account API key only** (see `referenceImageUrls`).
850
+ */
851
+ referenceAudios?: Array<{
852
+ url: string;
853
+ role?: "reference";
854
+ }>;
855
+ /** Output bitrate mode. Seedance 2.0 / Fast / Mini / 2.5 only — other models get a 400. */
856
+ bitrateMode?: "standard" | "high";
857
+ /** Output container. Seedance 2.5 only — other models get a 400. */
858
+ outputFormat?: "mp4" | "mov";
859
+ /** Lock the camera. Seedance 1.5-pro only — other models get a 400. */
860
+ cameraFixed?: boolean;
861
+ /** End-user identifier forwarded for upstream abuse monitoring. Seedance only. */
862
+ safetyIdentifier?: string;
863
+ /**
864
+ * Declare the intended mode. The gateway infers it from the media fields
865
+ * anyway; when this is set and disagrees, it answers 400 (with the inferred
866
+ * mode) before payment instead of rendering the wrong thing.
867
+ */
868
+ inputType?: "text" | "image" | "first_last_frame" | "reference";
828
869
  /** Duration to bill for (defaults to model's default duration) */
829
870
  durationSeconds?: number;
830
871
  /** Output aspect ratio. Token360 / Seedance only — silently ignored by xAI Grok. */
@@ -844,7 +885,10 @@ interface VideoGenerateOptions {
844
885
  seed?: number;
845
886
  /** Embed the upstream watermark on the output. Defaults to false at the gateway. */
846
887
  watermark?: boolean;
847
- /** Return the last frame as an image alongside the clip — useful for chaining. */
888
+ /**
889
+ * Return the last frame as an image alongside the clip — useful for chaining.
890
+ * Read it from `data[0].last_frame_url` (absent if the upstream omits it).
891
+ */
848
892
  returnLastFrame?: boolean;
849
893
  }
850
894
  interface SearchOptions {
@@ -1869,8 +1913,11 @@ declare class VideoClient {
1869
1913
  * Generate a video from a standard Seedance `content[]` body.
1870
1914
  *
1871
1915
  * Targets the gateway's `POST /v1/videos` endpoint, which accepts the
1872
- * mainstream multimodal `content` array (text + a single reference image)
1873
- * used by other Seedance APIs — so callers already holding a
1916
+ * mainstream multimodal `content` array used by other Seedance APIs. Items
1917
+ * may carry a `role` — `first_frame`, `last_frame`, `reference_image`,
1918
+ * `reference_video`, `reference_audio` — which the gateway maps to the same
1919
+ * validated fields as {@link generate}; a role-less single image keeps its
1920
+ * first-frame meaning — so callers already holding a
1874
1921
  * `content[]`-shaped request can submit it unchanged. The gateway validates
1875
1922
  * unsupported inputs *before* charging, then delegates to the same x402
1876
1923
  * submit+poll pipeline as {@link generate}.
@@ -1884,7 +1931,8 @@ declare class VideoClient {
1884
1931
  * `{ type: "image_url", image_url: { url: "https://..." } }`.
1885
1932
  * @param options - `model`, `budgetMs`, plus the same camelCase render options
1886
1933
  * as {@link generate} (`durationSeconds`, `aspectRatio`, `resolution`,
1887
- * `generateAudio`, `seed`, `watermark`, `returnLastFrame`). These are mapped
1934
+ * `generateAudio`, `seed`, `watermark`, `returnLastFrame`, `bitrateMode`,
1935
+ * `outputFormat`, `cameraFixed`, `safetyIdentifier`, `inputType`). These are mapped
1888
1936
  * to the gateway's snake_case fields for you. Any other keys you pass are
1889
1937
  * forwarded verbatim (use snake_case for those, since the gateway reads
1890
1938
  * snake_case only).
@@ -1899,6 +1947,11 @@ declare class VideoClient {
1899
1947
  seed?: number;
1900
1948
  watermark?: boolean;
1901
1949
  returnLastFrame?: boolean;
1950
+ bitrateMode?: "standard" | "high";
1951
+ outputFormat?: "mp4" | "mov";
1952
+ cameraFixed?: boolean;
1953
+ safetyIdentifier?: string;
1954
+ inputType?: "text" | "image" | "first_last_frame" | "reference";
1902
1955
  } & Record<string, unknown>): Promise<VideoResponse>;
1903
1956
  private submitAndPoll;
1904
1957
  /**
@@ -2651,6 +2704,31 @@ declare function formatFundingMessageCompact(address: string): string;
2651
2704
  declare const WALLET_FILE_PATH: string;
2652
2705
  declare const WALLET_DIR_PATH: string;
2653
2706
 
2707
+ /** Opt-in configuration for Solana batch-settlement. */
2708
+ interface SolanaBatchOptions {
2709
+ /**
2710
+ * Base58 operator public keys you trust to sign vouchers against your
2711
+ * channel. A batch accept naming any other operator is ignored, and the
2712
+ * call pays with `exact`. Required: there is no built-in default key.
2713
+ */
2714
+ operators: string[];
2715
+ /**
2716
+ * Total escrow, in USD, this client will lock in one channel (the first
2717
+ * deposit plus every top-up). This is the most an operator could take
2718
+ * without another signature from you. Accepts `"$5"`, `"5"` or `5`.
2719
+ * Default `"$1"` (the `@x402/svm` default).
2720
+ */
2721
+ maxDeposit?: string | number;
2722
+ /**
2723
+ * Where open-channel state is persisted between processes.
2724
+ * - default: `~/.blockrun/solana-batch/<wallet address>.json` (mode 0600)
2725
+ * - a path: that file
2726
+ * - `false`: in memory only. On restart the client finds its channel again
2727
+ * by scanning the chain for it.
2728
+ */
2729
+ channelStore?: string | false;
2730
+ }
2731
+
2654
2732
  interface SolanaLLMClientOptions extends ApiKeyOptions {
2655
2733
  /** bs58-encoded Solana secret key (64 bytes). Optional if SOLANA_WALLET_KEY env var is set. */
2656
2734
  privateKey?: string;
@@ -2673,6 +2751,14 @@ interface SolanaLLMClientOptions extends ApiKeyOptions {
2673
2751
  rpcHeaders?: Record<string, string>;
2674
2752
  /** Request timeout in milliseconds (default: 60000) */
2675
2753
  timeout?: number;
2754
+ /**
2755
+ * Opt in to x402 batch-settlement (metered billing) for chat completions.
2756
+ * Each call is charged what it actually cost, at most its quoted ceiling,
2757
+ * from a deposit-backed payment channel instead of a per-call transfer.
2758
+ * Needs the optional peers `@x402/core`, `@x402/svm` and `@solana/kit`.
2759
+ * Ignored in API-key mode. See {@link SolanaBatchOptions}.
2760
+ */
2761
+ batch?: SolanaBatchOptions;
2676
2762
  }
2677
2763
  declare class SolanaLLMClient {
2678
2764
  static readonly SOLANA_API_URL = "https://sol.blockrun.ai/api";
@@ -2689,7 +2775,16 @@ declare class SolanaLLMClient {
2689
2775
  private addressCache;
2690
2776
  private modelPricingCache;
2691
2777
  private modelPricingPromise;
2778
+ private batchPayer?;
2692
2779
  constructor(options?: SolanaLLMClientOptions);
2780
+ /**
2781
+ * Close this wallet's batch-settlement channel and return its unused escrow.
2782
+ *
2783
+ * The gateway closes it cooperatively when it can; otherwise this starts a
2784
+ * payer-forced close and the escrow comes back after the channel's grace
2785
+ * period. Only meaningful with the `batch` option.
2786
+ */
2787
+ closeBatchChannel(): Promise<unknown>;
2693
2788
  /** Get Solana wallet address (public key in base58). */
2694
2789
  getWalletAddress(): Promise<string>;
2695
2790
  /** Simple 1-line chat. */
@@ -2919,7 +3014,7 @@ declare class SolanaLLMClient {
2919
3014
  * @throws PaymentError when the 402 carries no usable Solana requirements.
2920
3015
  */
2921
3016
  /**
2922
- * Follow a 202 `{ id, poll_url }` to completion, on Solana.
3017
+ * Follow a 202 `{ id, poll_url }` to completion, on Solana **image** routes.
2923
3018
  *
2924
3019
  * Two things differ from Base and both come from the same constraint — a
2925
3020
  * Solana payment is a transaction pinned to a recent blockhash, valid for
@@ -2930,6 +3025,9 @@ declare class SolanaLLMClient {
2930
3025
  * settles optimistically at submit, and this loop only fetches the result.
2931
3026
  * The cost is recorded by the caller at POST, never here — recording it on
2932
3027
  * completion would lose the charge whenever a paid job then fails.
3028
+ * Solana VIDEO is the exception: it settles on the completed poll and a
3029
+ * failed job is not charged. Do not route video through this loop as-is —
3030
+ * it would book spend for jobs that were never charged.
2933
3031
  * 2. **Every poll re-signs.** One authorization cannot be replayed across a
2934
3032
  * long render. The gateway binds the job to the payer address rather than
2935
3033
  * to the signature, so a fresh signature from the same wallet is accepted
@@ -2937,6 +3035,10 @@ declare class SolanaLLMClient {
2937
3035
  */
2938
3036
  private followSolanaJob;
2939
3037
  private signPaymentFrom402;
3038
+ /** Read a `402`'s payment requirements from its header, or its JSON body. */
3039
+ private readPaymentRequired;
3040
+ /** Sign the `exact` accept of a 402 as an SPL TransferChecked payment. */
3041
+ private signExactPayment;
2940
3042
  private handlePaymentAndRetry;
2941
3043
  private requestWithPaymentRaw;
2942
3044
  private handlePaymentAndRetryRaw;
@@ -3319,4 +3421,4 @@ declare function validateTemperature(temperature?: number): void;
3319
3421
  */
3320
3422
  declare function validateTopP(topP?: number): void;
3321
3423
 
3322
- export { APIError, API_KEY_URL, ARC_CHAIN_ID, AnthropicClient, type ApiKeyOptions, type AudioModel, type AudioTrack, BASE_CHAIN_ID, type BarResolution, type BlockRunAnthropicOptions, BlockrunClient, type BlockrunClientOptions, BlockrunError, type CallInitiatedResponse, type CallModel, type CallOptions, type CallStatusResponse, type ChatChoice, type ChatCompletionOptions, type ChatMessage, type ChatOptions, type ChatResponse, type ChatResponseWithCost, type ChatUsage, type CostEntry, type CostEstimate, type CreatePaymentOptions, 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 ResponseFormat, RetiredEndpointError, 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 SmartChatCompletionOptions, type SmartChatCompletionResponse, type SmartChatOptions, type SmartChatResponse, SolanaLLMClient, type SolanaLLMClientOptions, type SolanaWalletInfo, type SoundEffectOptions, type SpeechAudio, SpeechClient, type SpeechClientOptions, type SpeechGenerateOptions, type SpeechModel, type SpeechResponse, type SpeechVoice, type Spending, type SpendingReport, type StockMarket, SurfClient, type SurfClientOptions, type SymbolListResponse, type Tool, type ToolCall, type ToolChoice, USDC_ARC, USDC_BASE, USDC_BASE_CONTRACT, USDC_SOLANA, VideoClient, type VideoClientOptions, type VideoClip, type VideoGenerateOptions, type VideoModel, type VideoResponse, VoiceClient, type VoiceClientOptions, type VoiceInfo, type VoicePreset, WALLET_DIR_PATH, WALLET_FILE_PATH, type WalletInfo, type WebSearchSource, type XSearchSource, 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, saveSolanaWallet, saveToCache, saveWallet, scanSolanaWallets, scanWallets, setCache, setupAgentClient, setupAgentSolanaWallet, setupAgentWallet, solanaClient, solanaKeyToBytes, solanaPublicKey, status, validateMaxTokens, validateModel, validateTemperature, validateTopP };
3424
+ export { APIError, API_KEY_URL, ARC_CHAIN_ID, AnthropicClient, type ApiKeyOptions, type AudioModel, type AudioTrack, BASE_CHAIN_ID, type BarResolution, type BlockRunAnthropicOptions, BlockrunClient, type BlockrunClientOptions, BlockrunError, type CallInitiatedResponse, type CallModel, type CallOptions, type CallStatusResponse, type ChatChoice, type ChatCompletionOptions, type ChatMessage, type ChatOptions, type ChatResponse, type ChatResponseWithCost, type ChatUsage, type CostEntry, type CostEstimate, type CreatePaymentOptions, 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 ResponseFormat, RetiredEndpointError, 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 SmartChatCompletionOptions, type SmartChatCompletionResponse, type SmartChatOptions, type SmartChatResponse, type SolanaBatchOptions, 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, 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 XSearchSource, 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, saveSolanaWallet, saveToCache, saveWallet, scanSolanaWallets, scanWallets, setCache, setupAgentClient, setupAgentSolanaWallet, setupAgentWallet, solanaClient, solanaKeyToBytes, solanaPublicKey, status, validateMaxTokens, validateModel, validateTemperature, validateTopP };
package/dist/index.d.ts CHANGED
@@ -770,6 +770,10 @@ interface VideoClip {
770
770
  request_id?: string;
771
771
  /** True when the gateway mirrored the video to its GCS bucket */
772
772
  backed_up?: boolean;
773
+ /** Final frame image when returnLastFrame is requested and the provider returns it. */
774
+ last_frame_url?: string;
775
+ /** Whether the final frame was mirrored to BlockRun storage. */
776
+ last_frame_backed_up?: boolean;
773
777
  }
774
778
  interface VideoResponse {
775
779
  created: number;
@@ -813,18 +817,55 @@ interface VideoGenerateOptions {
813
817
  * First-and-last-frame interpolation: a second image that seeds the FINAL
814
818
  * frame so the model tweens from `imageUrl` → `lastFrameUrl`. Requires
815
819
  * `imageUrl` (the first frame) and a Seedance model
816
- * (bytedance/seedance-1.5-pro, seedance-2.0, or seedance-2.0-fast).
820
+ * (1.5-pro, 2.0 / Fast / Mini, or 2.5).
817
821
  * Priced identically to image-to-video. Mutually exclusive with
818
822
  * `realFaceAssetId`.
819
823
  */
820
824
  lastFrameUrl?: string;
821
825
  /**
822
- * Omni / multi-reference: up to 9 reference image URLs for character/style
823
- * consistency (**Seedance 2.0 only**). Cite them as "image 1", "image 2"
824
- * in the prompt. Mutually exclusive with `imageUrl` / `lastFrameUrl` /
825
- * `realFaceAssetId`.
826
+ * Omni / multi-reference: up to 9 (Seedance 2.0 / Fast / Mini) or 30
827
+ * (Seedance 2.5) reference image URLs for character/style consistency. Cite
828
+ * them as "image 1", "image 2" in the prompt. Mutually exclusive with
829
+ * `imageUrl` / `lastFrameUrl` / `realFaceAssetId`.
830
+ *
831
+ * **Account API key only.** Reference media is served by `api.blockrun.ai`;
832
+ * the wallet gateways (blockrun.ai, sol.blockrun.ai) refuse it with a 400
833
+ * before any payment.
826
834
  */
827
835
  referenceImageUrls?: string[];
836
+ /**
837
+ * Reference-to-video: 1–3 http(s) motion/style video clips (Seedance 2.0 /
838
+ * Fast / Mini). May be combined with `referenceImageUrls`; mutually exclusive
839
+ * with frame seeds. `role` is optional and, when set, must be `"reference"`.
840
+ * Adds a per-clip surcharge. **Account API key only** (see `referenceImageUrls`).
841
+ */
842
+ referenceVideos?: Array<{
843
+ url: string;
844
+ role?: "reference";
845
+ }>;
846
+ /**
847
+ * Reference audio: 1–3 http(s) clips, each ≤15.2s (Seedance 2.0 / Fast /
848
+ * Mini). Requires `referenceImageUrls` or `referenceVideos` alongside it.
849
+ * Adds a per-clip surcharge. **Account API key only** (see `referenceImageUrls`).
850
+ */
851
+ referenceAudios?: Array<{
852
+ url: string;
853
+ role?: "reference";
854
+ }>;
855
+ /** Output bitrate mode. Seedance 2.0 / Fast / Mini / 2.5 only — other models get a 400. */
856
+ bitrateMode?: "standard" | "high";
857
+ /** Output container. Seedance 2.5 only — other models get a 400. */
858
+ outputFormat?: "mp4" | "mov";
859
+ /** Lock the camera. Seedance 1.5-pro only — other models get a 400. */
860
+ cameraFixed?: boolean;
861
+ /** End-user identifier forwarded for upstream abuse monitoring. Seedance only. */
862
+ safetyIdentifier?: string;
863
+ /**
864
+ * Declare the intended mode. The gateway infers it from the media fields
865
+ * anyway; when this is set and disagrees, it answers 400 (with the inferred
866
+ * mode) before payment instead of rendering the wrong thing.
867
+ */
868
+ inputType?: "text" | "image" | "first_last_frame" | "reference";
828
869
  /** Duration to bill for (defaults to model's default duration) */
829
870
  durationSeconds?: number;
830
871
  /** Output aspect ratio. Token360 / Seedance only — silently ignored by xAI Grok. */
@@ -844,7 +885,10 @@ interface VideoGenerateOptions {
844
885
  seed?: number;
845
886
  /** Embed the upstream watermark on the output. Defaults to false at the gateway. */
846
887
  watermark?: boolean;
847
- /** Return the last frame as an image alongside the clip — useful for chaining. */
888
+ /**
889
+ * Return the last frame as an image alongside the clip — useful for chaining.
890
+ * Read it from `data[0].last_frame_url` (absent if the upstream omits it).
891
+ */
848
892
  returnLastFrame?: boolean;
849
893
  }
850
894
  interface SearchOptions {
@@ -1869,8 +1913,11 @@ declare class VideoClient {
1869
1913
  * Generate a video from a standard Seedance `content[]` body.
1870
1914
  *
1871
1915
  * Targets the gateway's `POST /v1/videos` endpoint, which accepts the
1872
- * mainstream multimodal `content` array (text + a single reference image)
1873
- * used by other Seedance APIs — so callers already holding a
1916
+ * mainstream multimodal `content` array used by other Seedance APIs. Items
1917
+ * may carry a `role` — `first_frame`, `last_frame`, `reference_image`,
1918
+ * `reference_video`, `reference_audio` — which the gateway maps to the same
1919
+ * validated fields as {@link generate}; a role-less single image keeps its
1920
+ * first-frame meaning — so callers already holding a
1874
1921
  * `content[]`-shaped request can submit it unchanged. The gateway validates
1875
1922
  * unsupported inputs *before* charging, then delegates to the same x402
1876
1923
  * submit+poll pipeline as {@link generate}.
@@ -1884,7 +1931,8 @@ declare class VideoClient {
1884
1931
  * `{ type: "image_url", image_url: { url: "https://..." } }`.
1885
1932
  * @param options - `model`, `budgetMs`, plus the same camelCase render options
1886
1933
  * as {@link generate} (`durationSeconds`, `aspectRatio`, `resolution`,
1887
- * `generateAudio`, `seed`, `watermark`, `returnLastFrame`). These are mapped
1934
+ * `generateAudio`, `seed`, `watermark`, `returnLastFrame`, `bitrateMode`,
1935
+ * `outputFormat`, `cameraFixed`, `safetyIdentifier`, `inputType`). These are mapped
1888
1936
  * to the gateway's snake_case fields for you. Any other keys you pass are
1889
1937
  * forwarded verbatim (use snake_case for those, since the gateway reads
1890
1938
  * snake_case only).
@@ -1899,6 +1947,11 @@ declare class VideoClient {
1899
1947
  seed?: number;
1900
1948
  watermark?: boolean;
1901
1949
  returnLastFrame?: boolean;
1950
+ bitrateMode?: "standard" | "high";
1951
+ outputFormat?: "mp4" | "mov";
1952
+ cameraFixed?: boolean;
1953
+ safetyIdentifier?: string;
1954
+ inputType?: "text" | "image" | "first_last_frame" | "reference";
1902
1955
  } & Record<string, unknown>): Promise<VideoResponse>;
1903
1956
  private submitAndPoll;
1904
1957
  /**
@@ -2651,6 +2704,31 @@ declare function formatFundingMessageCompact(address: string): string;
2651
2704
  declare const WALLET_FILE_PATH: string;
2652
2705
  declare const WALLET_DIR_PATH: string;
2653
2706
 
2707
+ /** Opt-in configuration for Solana batch-settlement. */
2708
+ interface SolanaBatchOptions {
2709
+ /**
2710
+ * Base58 operator public keys you trust to sign vouchers against your
2711
+ * channel. A batch accept naming any other operator is ignored, and the
2712
+ * call pays with `exact`. Required: there is no built-in default key.
2713
+ */
2714
+ operators: string[];
2715
+ /**
2716
+ * Total escrow, in USD, this client will lock in one channel (the first
2717
+ * deposit plus every top-up). This is the most an operator could take
2718
+ * without another signature from you. Accepts `"$5"`, `"5"` or `5`.
2719
+ * Default `"$1"` (the `@x402/svm` default).
2720
+ */
2721
+ maxDeposit?: string | number;
2722
+ /**
2723
+ * Where open-channel state is persisted between processes.
2724
+ * - default: `~/.blockrun/solana-batch/<wallet address>.json` (mode 0600)
2725
+ * - a path: that file
2726
+ * - `false`: in memory only. On restart the client finds its channel again
2727
+ * by scanning the chain for it.
2728
+ */
2729
+ channelStore?: string | false;
2730
+ }
2731
+
2654
2732
  interface SolanaLLMClientOptions extends ApiKeyOptions {
2655
2733
  /** bs58-encoded Solana secret key (64 bytes). Optional if SOLANA_WALLET_KEY env var is set. */
2656
2734
  privateKey?: string;
@@ -2673,6 +2751,14 @@ interface SolanaLLMClientOptions extends ApiKeyOptions {
2673
2751
  rpcHeaders?: Record<string, string>;
2674
2752
  /** Request timeout in milliseconds (default: 60000) */
2675
2753
  timeout?: number;
2754
+ /**
2755
+ * Opt in to x402 batch-settlement (metered billing) for chat completions.
2756
+ * Each call is charged what it actually cost, at most its quoted ceiling,
2757
+ * from a deposit-backed payment channel instead of a per-call transfer.
2758
+ * Needs the optional peers `@x402/core`, `@x402/svm` and `@solana/kit`.
2759
+ * Ignored in API-key mode. See {@link SolanaBatchOptions}.
2760
+ */
2761
+ batch?: SolanaBatchOptions;
2676
2762
  }
2677
2763
  declare class SolanaLLMClient {
2678
2764
  static readonly SOLANA_API_URL = "https://sol.blockrun.ai/api";
@@ -2689,7 +2775,16 @@ declare class SolanaLLMClient {
2689
2775
  private addressCache;
2690
2776
  private modelPricingCache;
2691
2777
  private modelPricingPromise;
2778
+ private batchPayer?;
2692
2779
  constructor(options?: SolanaLLMClientOptions);
2780
+ /**
2781
+ * Close this wallet's batch-settlement channel and return its unused escrow.
2782
+ *
2783
+ * The gateway closes it cooperatively when it can; otherwise this starts a
2784
+ * payer-forced close and the escrow comes back after the channel's grace
2785
+ * period. Only meaningful with the `batch` option.
2786
+ */
2787
+ closeBatchChannel(): Promise<unknown>;
2693
2788
  /** Get Solana wallet address (public key in base58). */
2694
2789
  getWalletAddress(): Promise<string>;
2695
2790
  /** Simple 1-line chat. */
@@ -2919,7 +3014,7 @@ declare class SolanaLLMClient {
2919
3014
  * @throws PaymentError when the 402 carries no usable Solana requirements.
2920
3015
  */
2921
3016
  /**
2922
- * Follow a 202 `{ id, poll_url }` to completion, on Solana.
3017
+ * Follow a 202 `{ id, poll_url }` to completion, on Solana **image** routes.
2923
3018
  *
2924
3019
  * Two things differ from Base and both come from the same constraint — a
2925
3020
  * Solana payment is a transaction pinned to a recent blockhash, valid for
@@ -2930,6 +3025,9 @@ declare class SolanaLLMClient {
2930
3025
  * settles optimistically at submit, and this loop only fetches the result.
2931
3026
  * The cost is recorded by the caller at POST, never here — recording it on
2932
3027
  * completion would lose the charge whenever a paid job then fails.
3028
+ * Solana VIDEO is the exception: it settles on the completed poll and a
3029
+ * failed job is not charged. Do not route video through this loop as-is —
3030
+ * it would book spend for jobs that were never charged.
2933
3031
  * 2. **Every poll re-signs.** One authorization cannot be replayed across a
2934
3032
  * long render. The gateway binds the job to the payer address rather than
2935
3033
  * to the signature, so a fresh signature from the same wallet is accepted
@@ -2937,6 +3035,10 @@ declare class SolanaLLMClient {
2937
3035
  */
2938
3036
  private followSolanaJob;
2939
3037
  private signPaymentFrom402;
3038
+ /** Read a `402`'s payment requirements from its header, or its JSON body. */
3039
+ private readPaymentRequired;
3040
+ /** Sign the `exact` accept of a 402 as an SPL TransferChecked payment. */
3041
+ private signExactPayment;
2940
3042
  private handlePaymentAndRetry;
2941
3043
  private requestWithPaymentRaw;
2942
3044
  private handlePaymentAndRetryRaw;
@@ -3319,4 +3421,4 @@ declare function validateTemperature(temperature?: number): void;
3319
3421
  */
3320
3422
  declare function validateTopP(topP?: number): void;
3321
3423
 
3322
- export { APIError, API_KEY_URL, ARC_CHAIN_ID, AnthropicClient, type ApiKeyOptions, type AudioModel, type AudioTrack, BASE_CHAIN_ID, type BarResolution, type BlockRunAnthropicOptions, BlockrunClient, type BlockrunClientOptions, BlockrunError, type CallInitiatedResponse, type CallModel, type CallOptions, type CallStatusResponse, type ChatChoice, type ChatCompletionOptions, type ChatMessage, type ChatOptions, type ChatResponse, type ChatResponseWithCost, type ChatUsage, type CostEntry, type CostEstimate, type CreatePaymentOptions, 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 ResponseFormat, RetiredEndpointError, 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 SmartChatCompletionOptions, type SmartChatCompletionResponse, type SmartChatOptions, type SmartChatResponse, SolanaLLMClient, type SolanaLLMClientOptions, type SolanaWalletInfo, type SoundEffectOptions, type SpeechAudio, SpeechClient, type SpeechClientOptions, type SpeechGenerateOptions, type SpeechModel, type SpeechResponse, type SpeechVoice, type Spending, type SpendingReport, type StockMarket, SurfClient, type SurfClientOptions, type SymbolListResponse, type Tool, type ToolCall, type ToolChoice, USDC_ARC, USDC_BASE, USDC_BASE_CONTRACT, USDC_SOLANA, VideoClient, type VideoClientOptions, type VideoClip, type VideoGenerateOptions, type VideoModel, type VideoResponse, VoiceClient, type VoiceClientOptions, type VoiceInfo, type VoicePreset, WALLET_DIR_PATH, WALLET_FILE_PATH, type WalletInfo, type WebSearchSource, type XSearchSource, 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, saveSolanaWallet, saveToCache, saveWallet, scanSolanaWallets, scanWallets, setCache, setupAgentClient, setupAgentSolanaWallet, setupAgentWallet, solanaClient, solanaKeyToBytes, solanaPublicKey, status, validateMaxTokens, validateModel, validateTemperature, validateTopP };
3424
+ export { APIError, API_KEY_URL, ARC_CHAIN_ID, AnthropicClient, type ApiKeyOptions, type AudioModel, type AudioTrack, BASE_CHAIN_ID, type BarResolution, type BlockRunAnthropicOptions, BlockrunClient, type BlockrunClientOptions, BlockrunError, type CallInitiatedResponse, type CallModel, type CallOptions, type CallStatusResponse, type ChatChoice, type ChatCompletionOptions, type ChatMessage, type ChatOptions, type ChatResponse, type ChatResponseWithCost, type ChatUsage, type CostEntry, type CostEstimate, type CreatePaymentOptions, 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 ResponseFormat, RetiredEndpointError, 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 SmartChatCompletionOptions, type SmartChatCompletionResponse, type SmartChatOptions, type SmartChatResponse, type SolanaBatchOptions, 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, 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 XSearchSource, 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, saveSolanaWallet, saveToCache, saveWallet, scanSolanaWallets, scanWallets, setCache, setupAgentClient, setupAgentSolanaWallet, setupAgentWallet, solanaClient, solanaKeyToBytes, solanaPublicKey, status, validateMaxTokens, validateModel, validateTemperature, validateTopP };