@blockrun/llm 2.7.0 → 2.9.1
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 +42 -3
- package/dist/index.cjs +223 -46
- package/dist/index.d.cts +157 -12
- package/dist/index.d.ts +157 -12
- package/dist/index.js +220 -45
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -335,7 +335,7 @@ interface SearchResult {
|
|
|
335
335
|
model?: string;
|
|
336
336
|
}
|
|
337
337
|
interface ImageEditOptions {
|
|
338
|
-
/** Model ID (default: "openai/gpt-image-
|
|
338
|
+
/** Model ID (default: "openai/gpt-image-2") */
|
|
339
339
|
model?: string;
|
|
340
340
|
/** Optional base64-encoded mask image */
|
|
341
341
|
mask?: string;
|
|
@@ -497,7 +497,7 @@ interface VideoGenerateOptions {
|
|
|
497
497
|
/**
|
|
498
498
|
* Virtual Portrait asset ID (`ta_xxxxxx`) — keeps the same AI character
|
|
499
499
|
* across multiple Seedance videos. Enroll via `POST /v1/portrait/enroll`
|
|
500
|
-
* ($0.
|
|
500
|
+
* ($0.01 USDC promo, no KYC). **Seedance 2.0 fast/pro only.** Mutually exclusive
|
|
501
501
|
* with `imageUrl`. Real-person likeness is not supported on BlockRun.
|
|
502
502
|
*/
|
|
503
503
|
realFaceAssetId?: string;
|
|
@@ -867,6 +867,63 @@ interface PhoneReleaseResponse {
|
|
|
867
867
|
phone_number: string;
|
|
868
868
|
txHash?: string;
|
|
869
869
|
}
|
|
870
|
+
interface PortraitClientOptions {
|
|
871
|
+
/** EVM wallet private key (hex string starting with 0x) */
|
|
872
|
+
privateKey?: `0x${string}` | string;
|
|
873
|
+
/** API endpoint URL (default: https://blockrun.ai/api) */
|
|
874
|
+
apiUrl?: string;
|
|
875
|
+
/** Request timeout in milliseconds (default: 60000) */
|
|
876
|
+
timeout?: number;
|
|
877
|
+
}
|
|
878
|
+
interface PortraitEnrollOptions {
|
|
879
|
+
/** Display name for the portrait (1–64 chars). */
|
|
880
|
+
name: string;
|
|
881
|
+
/**
|
|
882
|
+
* Public HTTPS URL to a JPG/PNG/WEBP face image (≤10 MB). The gateway fetches
|
|
883
|
+
* it server-side and forwards it to Token360 as multipart — only the URL is sent.
|
|
884
|
+
*/
|
|
885
|
+
imageUrl: string;
|
|
886
|
+
}
|
|
887
|
+
/**
|
|
888
|
+
* Response from `POST /v1/portrait/enroll`. The `asset_id` (`ta_xxxxxx`) is what
|
|
889
|
+
* you pass as `realFaceAssetId` on a Seedance 2.0 video generation to keep the
|
|
890
|
+
* same AI character across clips.
|
|
891
|
+
*/
|
|
892
|
+
interface PortraitEnrollResponse {
|
|
893
|
+
object: "virtual_portrait";
|
|
894
|
+
/** Token360 asset id (`ta_xxxxxx`) — pass as `realFaceAssetId` in VideoGenerateOptions. */
|
|
895
|
+
asset_id: string;
|
|
896
|
+
/** Token360 asset-group id (internal/debugging). */
|
|
897
|
+
group_id: string;
|
|
898
|
+
name: string;
|
|
899
|
+
/**
|
|
900
|
+
* Persisted thumbnail URL. The gateway mirrors your source image to its own
|
|
901
|
+
* storage when possible (so the listing thumbnail survives a dead source
|
|
902
|
+
* host); falls back to the original URL if mirroring fails. See `mirrored`.
|
|
903
|
+
*/
|
|
904
|
+
image_url: string;
|
|
905
|
+
/** The original URL you supplied (before any mirroring). */
|
|
906
|
+
source_image_url?: string;
|
|
907
|
+
/** Whether `image_url` is the gateway-mirrored copy (true) or your original (false). */
|
|
908
|
+
mirrored?: boolean;
|
|
909
|
+
/** ISO-8601 creation timestamp. */
|
|
910
|
+
created_at: string;
|
|
911
|
+
usage: {
|
|
912
|
+
compatible_models: string[];
|
|
913
|
+
how_to_use: string;
|
|
914
|
+
};
|
|
915
|
+
price: {
|
|
916
|
+
amount: string;
|
|
917
|
+
currency: string;
|
|
918
|
+
};
|
|
919
|
+
settlement: {
|
|
920
|
+
success: boolean;
|
|
921
|
+
tx_hash: string | null;
|
|
922
|
+
network: string;
|
|
923
|
+
};
|
|
924
|
+
/** On-chain payment receipt (tx hash), surfaced from the response header. */
|
|
925
|
+
txHash?: string;
|
|
926
|
+
}
|
|
870
927
|
interface BlockrunClientOptions {
|
|
871
928
|
privateKey?: `0x${string}` | string;
|
|
872
929
|
apiUrl?: string;
|
|
@@ -1101,14 +1158,16 @@ declare class LLMClient {
|
|
|
1101
1158
|
*/
|
|
1102
1159
|
private fetchRawModels;
|
|
1103
1160
|
/**
|
|
1104
|
-
* Edit an image using img2img.
|
|
1161
|
+
* Edit an image using img2img, optionally fusing multiple source images.
|
|
1105
1162
|
*
|
|
1106
1163
|
* @param prompt - Text description of the desired edit
|
|
1107
|
-
* @param image -
|
|
1164
|
+
* @param image - A base64 `data:image/...` URI, or an array of 2–4 such URIs
|
|
1165
|
+
* to fuse (image fusion). Caps: `openai/*` up to 4, `google/*` up to 3.
|
|
1166
|
+
* A `mask` cannot be combined with multiple source images.
|
|
1108
1167
|
* @param options - Optional edit parameters
|
|
1109
1168
|
* @returns ImageResponse with edited image URLs
|
|
1110
1169
|
*/
|
|
1111
|
-
imageEdit(prompt: string, image: string, options?: ImageEditOptions): Promise<ImageResponse>;
|
|
1170
|
+
imageEdit(prompt: string, image: string | string[], options?: ImageEditOptions): Promise<ImageResponse>;
|
|
1112
1171
|
/**
|
|
1113
1172
|
* Standalone search (web, X/Twitter, news).
|
|
1114
1173
|
*
|
|
@@ -1421,18 +1480,35 @@ declare class ImageClient {
|
|
|
1421
1480
|
*/
|
|
1422
1481
|
generate(prompt: string, options?: ImageGenerateOptions): Promise<ImageResponse>;
|
|
1423
1482
|
/**
|
|
1424
|
-
* Edit an image using img2img.
|
|
1483
|
+
* Edit an image using img2img, optionally fusing multiple source images.
|
|
1484
|
+
*
|
|
1485
|
+
* Pass a single `data:image/...` base64 data URI to edit one image, or an
|
|
1486
|
+
* array of 2–4 data URIs to fuse them (image fusion) — e.g. a reference photo
|
|
1487
|
+
* plus a brand logo. The server caps fusion per provider: `openai/*` accepts
|
|
1488
|
+
* up to 4 source images, `google/*` (Nano Banana) up to 3. A `mask` cannot be
|
|
1489
|
+
* combined with multiple source images.
|
|
1490
|
+
*
|
|
1491
|
+
* Edit-capable models: `openai/gpt-image-1`, `openai/gpt-image-2`,
|
|
1492
|
+
* `google/nano-banana`, `google/nano-banana-pro`.
|
|
1425
1493
|
*
|
|
1426
1494
|
* @param prompt - Text description of the desired edit
|
|
1427
|
-
* @param image -
|
|
1495
|
+
* @param image - A base64 `data:image/...` URI, or an array of 2–4 such URIs to fuse
|
|
1428
1496
|
* @param options - Optional edit parameters
|
|
1429
1497
|
* @returns ImageResponse with edited image URLs
|
|
1430
1498
|
*
|
|
1431
1499
|
* @example
|
|
1432
|
-
*
|
|
1433
|
-
*
|
|
1500
|
+
* // Single-image edit
|
|
1501
|
+
* const result = await client.edit('Make it a painting', imageDataUri);
|
|
1502
|
+
*
|
|
1503
|
+
* @example
|
|
1504
|
+
* // Multi-image fusion (Nano Banana): blend a subject with a brand logo
|
|
1505
|
+
* const fused = await client.edit(
|
|
1506
|
+
* 'Place the logo on the t-shirt',
|
|
1507
|
+
* [subjectDataUri, logoDataUri],
|
|
1508
|
+
* { model: 'google/nano-banana' }
|
|
1509
|
+
* );
|
|
1434
1510
|
*/
|
|
1435
|
-
edit(prompt: string, image: string, options?: ImageEditOptions): Promise<ImageResponse>;
|
|
1511
|
+
edit(prompt: string, image: string | string[], options?: ImageEditOptions): Promise<ImageResponse>;
|
|
1436
1512
|
/**
|
|
1437
1513
|
* List available image generation models with pricing.
|
|
1438
1514
|
*
|
|
@@ -1774,6 +1850,75 @@ declare class PhoneClient {
|
|
|
1774
1850
|
private fetchWithTimeout;
|
|
1775
1851
|
}
|
|
1776
1852
|
|
|
1853
|
+
/**
|
|
1854
|
+
* BlockRun Portrait Client — enroll a Virtual Portrait via x402.
|
|
1855
|
+
*
|
|
1856
|
+
* Wraps `POST /v1/portrait/enroll` ($0.01 USDC promo, no KYC). You upload a face image
|
|
1857
|
+
* by URL and get back a Token360 asset id (`ta_xxxxxx`). Pass that id as
|
|
1858
|
+
* `realFaceAssetId` on a Seedance 2.0 video generation (VideoClient.generate)
|
|
1859
|
+
* to keep the same AI character across clips.
|
|
1860
|
+
*
|
|
1861
|
+
* SECURITY NOTE — your private key never leaves your machine. Only EIP-712
|
|
1862
|
+
* signatures are sent in the PAYMENT-SIGNATURE header.
|
|
1863
|
+
*
|
|
1864
|
+
* @example
|
|
1865
|
+
* import { PortraitClient, VideoClient } from '@blockrun/llm';
|
|
1866
|
+
*
|
|
1867
|
+
* const portraits = new PortraitClient({ privateKey: '0x...' });
|
|
1868
|
+
* const { asset_id } = await portraits.enroll({
|
|
1869
|
+
* name: 'Spokesperson',
|
|
1870
|
+
* imageUrl: 'https://example.com/face.jpg',
|
|
1871
|
+
* });
|
|
1872
|
+
*
|
|
1873
|
+
* const video = new VideoClient({ privateKey: '0x...' });
|
|
1874
|
+
* const clip = await video.generate('she waves and smiles', {
|
|
1875
|
+
* model: 'bytedance/seedance-2.0-fast',
|
|
1876
|
+
* realFaceAssetId: asset_id,
|
|
1877
|
+
* });
|
|
1878
|
+
*/
|
|
1879
|
+
|
|
1880
|
+
/**
|
|
1881
|
+
* Flat enrollment price in USD — mirrors the backend's `ENROLLMENT_PRICE_USD`.
|
|
1882
|
+
* Currently $0.01 (promotional, parity with RealFace). The authoritative price
|
|
1883
|
+
* is whatever the gateway quotes in the 402; this constant is informational.
|
|
1884
|
+
*/
|
|
1885
|
+
declare const PORTRAIT_ENROLLMENT_PRICE_USD = 0.01;
|
|
1886
|
+
/**
|
|
1887
|
+
* BlockRun Portrait Client.
|
|
1888
|
+
*
|
|
1889
|
+
* Enrolls a Virtual Portrait from a face image URL and returns the `ta_xxxxxx`
|
|
1890
|
+
* asset id consumed by Seedance 2.0 video generation. Real-person likeness is
|
|
1891
|
+
* not supported on BlockRun — enrolled portraits are AI characters.
|
|
1892
|
+
*/
|
|
1893
|
+
declare class PortraitClient {
|
|
1894
|
+
private account;
|
|
1895
|
+
private privateKey;
|
|
1896
|
+
private apiUrl;
|
|
1897
|
+
private timeout;
|
|
1898
|
+
private sessionTotalUsd;
|
|
1899
|
+
private sessionCalls;
|
|
1900
|
+
constructor(options?: PortraitClientOptions);
|
|
1901
|
+
/** EVM wallet address used for payments. */
|
|
1902
|
+
getWalletAddress(): string;
|
|
1903
|
+
/** Session-cumulative USD spend + call count across this client instance. */
|
|
1904
|
+
getSpending(): Spending;
|
|
1905
|
+
/**
|
|
1906
|
+
* Enroll a Virtual Portrait from a face image URL. $0.01 (promo).
|
|
1907
|
+
*
|
|
1908
|
+
* Payment is settled only after Token360 confirms the enrollment, so failed
|
|
1909
|
+
* enrollments never charge your wallet.
|
|
1910
|
+
*
|
|
1911
|
+
* @param options.name Display name (1–64 chars).
|
|
1912
|
+
* @param options.imageUrl Public HTTPS URL to a JPG/PNG/WEBP image (≤10 MB).
|
|
1913
|
+
* @returns The enrollment record, including `asset_id` (`ta_xxxxxx`).
|
|
1914
|
+
*/
|
|
1915
|
+
enroll(options: PortraitEnrollOptions): Promise<PortraitEnrollResponse>;
|
|
1916
|
+
private request;
|
|
1917
|
+
private handlePaymentAndRetry;
|
|
1918
|
+
private unwrap;
|
|
1919
|
+
private fetchWithTimeout;
|
|
1920
|
+
}
|
|
1921
|
+
|
|
1777
1922
|
/**
|
|
1778
1923
|
* BlockRun Search Client - Standalone Grok Live Search via x402 micropayments.
|
|
1779
1924
|
*
|
|
@@ -2378,7 +2523,7 @@ declare class SolanaLLMClient {
|
|
|
2378
2523
|
*/
|
|
2379
2524
|
getBalance(): Promise<number>;
|
|
2380
2525
|
/** Edit an image using img2img (Solana payment). */
|
|
2381
|
-
imageEdit(prompt: string, image: string, options?: ImageEditOptions): Promise<ImageResponse>;
|
|
2526
|
+
imageEdit(prompt: string, image: string | string[], options?: ImageEditOptions): Promise<ImageResponse>;
|
|
2382
2527
|
/** Standalone search (Solana payment). */
|
|
2383
2528
|
search(query: string, options?: SearchOptions): Promise<SearchResult>;
|
|
2384
2529
|
xUserLookup(usernames: string | string[]): Promise<XUserLookupResponse>;
|
|
@@ -2762,4 +2907,4 @@ declare function validateTemperature(temperature?: number): void;
|
|
|
2762
2907
|
*/
|
|
2763
2908
|
declare function validateTopP(topP?: number): void;
|
|
2764
2909
|
|
|
2765
|
-
export { APIError, AnthropicClient, type AudioModel, type AudioTrack, BASE_CHAIN_ID, type BarResolution, type BlockRunAnthropicOptions, BlockrunClient, type BlockrunClientOptions, BlockrunError, type CallInitiatedResponse, type CallModel, type CallOptions, type CallStatusResponse, type ChatChoice, type ChatCompletionOptions, type ChatMessage, type ChatOptions, type ChatResponse, type ChatResponseWithCost, type ChatUsage, type CostEntry, type CostEstimate, type CreatePaymentOptions, type FunctionCall, type FunctionDefinition, type HistoryOptions, ImageClient, type ImageClientOptions, type ImageData, type ImageEditOptions, type ImageGenerateOptions, type ImageModel, type ImageResponse, KNOWN_PROVIDERS, LLMClient, type LLMClientOptions, type ListOptions, type MarketSession, type Model, MusicClient, type MusicClientOptions, type MusicGenerateOptions, type MusicResponse, type NewsSearchSource, OpenAI, type OpenAIChatCompletionChoice, type OpenAIChatCompletionChunk, type OpenAIChatCompletionParams, type OpenAIChatCompletionResponse, type OpenAIClientOptions, PHONE_PRICES, PaymentError, type PaymentLinks, type PhoneBuyOptions, type PhoneBuyResponse, PhoneClient, type PhoneClientOptions, type PhoneListResponse, type PhoneLookupResponse, type PhoneNumberRecord, type PhoneReleaseResponse, type PhoneRenewResponse, type PollOptions, type PriceBar, type PriceCategory, PriceClient, type PriceClientOptions, type PriceHistoryResponse, type PriceOptions, type PricePoint, type RoutingDecision, type RoutingProfile, type RoutingTier, type RssSearchSource, SOLANA_NETWORK, SOLANA_WALLET_FILE as SOLANA_WALLET_FILE_PATH, SearchClient, type SearchClientOptions, type SearchOptions, type SearchParameters, type SearchResult, type SearchSource, type SearchUsage, type SmartChatOptions, type SmartChatResponse, SolanaLLMClient, type SolanaLLMClientOptions, type SolanaWalletInfo, type Spending, type SpendingReport, type StockMarket, SurfClient, type SurfClientOptions, type SymbolListResponse, type Tool, type ToolCall, type ToolChoice, USDC_BASE, USDC_BASE_CONTRACT, USDC_SOLANA, VideoClient, type VideoClientOptions, type VideoClip, type VideoGenerateOptions, type VideoModel, type VideoResponse, VoiceClient, type VoiceClientOptions, type VoicePreset, WALLET_DIR_PATH, WALLET_FILE_PATH, type WalletInfo, type WebSearchSource, type XArticlesRisingResponse, type XAuthorAnalyticsResponse, XClient, type XClientOptions, type XCompareAuthorsResponse, type XFollower, type XFollowersResponse, type XFollowingsResponse, type XMentionsOptions, type XMentionsResponse, type XSearchOptions, type XSearchResponse, type XSearchSource, type XTrendingResponse, type XTweet, type XTweetLookupResponse, type XTweetRepliesOptions, type XTweetRepliesResponse, type XTweetThreadResponse, type XTweetsResponse, type XUser, type XUserInfoResponse, type XUserLookupResponse, type XUserTweetsOptions, type XVerifiedFollowersResponse, clearCache, createPaymentPayload, createSolanaPaymentPayload, createSolanaWallet, createWallet, LLMClient as default, extractPaymentDetails, formatFundingMessageCompact, formatNeedsFundingMessage, formatWalletCreatedMessage, getCached, getCachedByRequest, getCostLogSummary, getCostSummary, getEip681Uri, getOrCreateSolanaWallet, getOrCreateWallet, getPaymentLinks, getWalletAddress, loadSolanaWallet, loadWallet, logCost, parsePaymentRequired, saveSolanaWallet, saveToCache, saveWallet, scanSolanaWallets, scanWallets, setCache, setupAgentSolanaWallet, setupAgentWallet, solanaClient, solanaKeyToBytes, solanaPublicKey, status, validateMaxTokens, validateModel, validateTemperature, validateTopP };
|
|
2910
|
+
export { APIError, AnthropicClient, type AudioModel, type AudioTrack, BASE_CHAIN_ID, type BarResolution, type BlockRunAnthropicOptions, BlockrunClient, type BlockrunClientOptions, BlockrunError, type CallInitiatedResponse, type CallModel, type CallOptions, type CallStatusResponse, type ChatChoice, type ChatCompletionOptions, type ChatMessage, type ChatOptions, type ChatResponse, type ChatResponseWithCost, type ChatUsage, type CostEntry, type CostEstimate, type CreatePaymentOptions, type FunctionCall, type FunctionDefinition, type HistoryOptions, ImageClient, type ImageClientOptions, type ImageData, type ImageEditOptions, type ImageGenerateOptions, type ImageModel, type ImageResponse, KNOWN_PROVIDERS, LLMClient, type LLMClientOptions, type ListOptions, type MarketSession, type Model, MusicClient, type MusicClientOptions, type MusicGenerateOptions, type MusicResponse, type NewsSearchSource, OpenAI, type OpenAIChatCompletionChoice, type OpenAIChatCompletionChunk, type OpenAIChatCompletionParams, type OpenAIChatCompletionResponse, type OpenAIClientOptions, PHONE_PRICES, PORTRAIT_ENROLLMENT_PRICE_USD, PaymentError, type PaymentLinks, type PhoneBuyOptions, type PhoneBuyResponse, PhoneClient, type PhoneClientOptions, type PhoneListResponse, type PhoneLookupResponse, type PhoneNumberRecord, type PhoneReleaseResponse, type PhoneRenewResponse, type PollOptions, PortraitClient, type PortraitClientOptions, type PortraitEnrollOptions, type PortraitEnrollResponse, type PriceBar, type PriceCategory, PriceClient, type PriceClientOptions, type PriceHistoryResponse, type PriceOptions, type PricePoint, type RoutingDecision, type RoutingProfile, type RoutingTier, type RssSearchSource, SOLANA_NETWORK, SOLANA_WALLET_FILE as SOLANA_WALLET_FILE_PATH, SearchClient, type SearchClientOptions, type SearchOptions, type SearchParameters, type SearchResult, type SearchSource, type SearchUsage, type SmartChatOptions, type SmartChatResponse, SolanaLLMClient, type SolanaLLMClientOptions, type SolanaWalletInfo, type Spending, type SpendingReport, type StockMarket, SurfClient, type SurfClientOptions, type SymbolListResponse, type Tool, type ToolCall, type ToolChoice, USDC_BASE, USDC_BASE_CONTRACT, USDC_SOLANA, VideoClient, type VideoClientOptions, type VideoClip, type VideoGenerateOptions, type VideoModel, type VideoResponse, VoiceClient, type VoiceClientOptions, type VoicePreset, WALLET_DIR_PATH, WALLET_FILE_PATH, type WalletInfo, type WebSearchSource, type XArticlesRisingResponse, type XAuthorAnalyticsResponse, XClient, type XClientOptions, type XCompareAuthorsResponse, type XFollower, type XFollowersResponse, type XFollowingsResponse, type XMentionsOptions, type XMentionsResponse, type XSearchOptions, type XSearchResponse, type XSearchSource, type XTrendingResponse, type XTweet, type XTweetLookupResponse, type XTweetRepliesOptions, type XTweetRepliesResponse, type XTweetThreadResponse, type XTweetsResponse, type XUser, type XUserInfoResponse, type XUserLookupResponse, type XUserTweetsOptions, type XVerifiedFollowersResponse, clearCache, createPaymentPayload, createSolanaPaymentPayload, createSolanaWallet, createWallet, LLMClient as default, extractPaymentDetails, formatFundingMessageCompact, formatNeedsFundingMessage, formatWalletCreatedMessage, getCached, getCachedByRequest, getCostLogSummary, getCostSummary, getEip681Uri, getOrCreateSolanaWallet, getOrCreateWallet, getPaymentLinks, getWalletAddress, loadSolanaWallet, loadWallet, logCost, parsePaymentRequired, saveSolanaWallet, saveToCache, saveWallet, scanSolanaWallets, scanWallets, setCache, setupAgentSolanaWallet, setupAgentWallet, solanaClient, solanaKeyToBytes, solanaPublicKey, status, validateMaxTokens, validateModel, validateTemperature, validateTopP };
|
package/dist/index.d.ts
CHANGED
|
@@ -335,7 +335,7 @@ interface SearchResult {
|
|
|
335
335
|
model?: string;
|
|
336
336
|
}
|
|
337
337
|
interface ImageEditOptions {
|
|
338
|
-
/** Model ID (default: "openai/gpt-image-
|
|
338
|
+
/** Model ID (default: "openai/gpt-image-2") */
|
|
339
339
|
model?: string;
|
|
340
340
|
/** Optional base64-encoded mask image */
|
|
341
341
|
mask?: string;
|
|
@@ -497,7 +497,7 @@ interface VideoGenerateOptions {
|
|
|
497
497
|
/**
|
|
498
498
|
* Virtual Portrait asset ID (`ta_xxxxxx`) — keeps the same AI character
|
|
499
499
|
* across multiple Seedance videos. Enroll via `POST /v1/portrait/enroll`
|
|
500
|
-
* ($0.
|
|
500
|
+
* ($0.01 USDC promo, no KYC). **Seedance 2.0 fast/pro only.** Mutually exclusive
|
|
501
501
|
* with `imageUrl`. Real-person likeness is not supported on BlockRun.
|
|
502
502
|
*/
|
|
503
503
|
realFaceAssetId?: string;
|
|
@@ -867,6 +867,63 @@ interface PhoneReleaseResponse {
|
|
|
867
867
|
phone_number: string;
|
|
868
868
|
txHash?: string;
|
|
869
869
|
}
|
|
870
|
+
interface PortraitClientOptions {
|
|
871
|
+
/** EVM wallet private key (hex string starting with 0x) */
|
|
872
|
+
privateKey?: `0x${string}` | string;
|
|
873
|
+
/** API endpoint URL (default: https://blockrun.ai/api) */
|
|
874
|
+
apiUrl?: string;
|
|
875
|
+
/** Request timeout in milliseconds (default: 60000) */
|
|
876
|
+
timeout?: number;
|
|
877
|
+
}
|
|
878
|
+
interface PortraitEnrollOptions {
|
|
879
|
+
/** Display name for the portrait (1–64 chars). */
|
|
880
|
+
name: string;
|
|
881
|
+
/**
|
|
882
|
+
* Public HTTPS URL to a JPG/PNG/WEBP face image (≤10 MB). The gateway fetches
|
|
883
|
+
* it server-side and forwards it to Token360 as multipart — only the URL is sent.
|
|
884
|
+
*/
|
|
885
|
+
imageUrl: string;
|
|
886
|
+
}
|
|
887
|
+
/**
|
|
888
|
+
* Response from `POST /v1/portrait/enroll`. The `asset_id` (`ta_xxxxxx`) is what
|
|
889
|
+
* you pass as `realFaceAssetId` on a Seedance 2.0 video generation to keep the
|
|
890
|
+
* same AI character across clips.
|
|
891
|
+
*/
|
|
892
|
+
interface PortraitEnrollResponse {
|
|
893
|
+
object: "virtual_portrait";
|
|
894
|
+
/** Token360 asset id (`ta_xxxxxx`) — pass as `realFaceAssetId` in VideoGenerateOptions. */
|
|
895
|
+
asset_id: string;
|
|
896
|
+
/** Token360 asset-group id (internal/debugging). */
|
|
897
|
+
group_id: string;
|
|
898
|
+
name: string;
|
|
899
|
+
/**
|
|
900
|
+
* Persisted thumbnail URL. The gateway mirrors your source image to its own
|
|
901
|
+
* storage when possible (so the listing thumbnail survives a dead source
|
|
902
|
+
* host); falls back to the original URL if mirroring fails. See `mirrored`.
|
|
903
|
+
*/
|
|
904
|
+
image_url: string;
|
|
905
|
+
/** The original URL you supplied (before any mirroring). */
|
|
906
|
+
source_image_url?: string;
|
|
907
|
+
/** Whether `image_url` is the gateway-mirrored copy (true) or your original (false). */
|
|
908
|
+
mirrored?: boolean;
|
|
909
|
+
/** ISO-8601 creation timestamp. */
|
|
910
|
+
created_at: string;
|
|
911
|
+
usage: {
|
|
912
|
+
compatible_models: string[];
|
|
913
|
+
how_to_use: string;
|
|
914
|
+
};
|
|
915
|
+
price: {
|
|
916
|
+
amount: string;
|
|
917
|
+
currency: string;
|
|
918
|
+
};
|
|
919
|
+
settlement: {
|
|
920
|
+
success: boolean;
|
|
921
|
+
tx_hash: string | null;
|
|
922
|
+
network: string;
|
|
923
|
+
};
|
|
924
|
+
/** On-chain payment receipt (tx hash), surfaced from the response header. */
|
|
925
|
+
txHash?: string;
|
|
926
|
+
}
|
|
870
927
|
interface BlockrunClientOptions {
|
|
871
928
|
privateKey?: `0x${string}` | string;
|
|
872
929
|
apiUrl?: string;
|
|
@@ -1101,14 +1158,16 @@ declare class LLMClient {
|
|
|
1101
1158
|
*/
|
|
1102
1159
|
private fetchRawModels;
|
|
1103
1160
|
/**
|
|
1104
|
-
* Edit an image using img2img.
|
|
1161
|
+
* Edit an image using img2img, optionally fusing multiple source images.
|
|
1105
1162
|
*
|
|
1106
1163
|
* @param prompt - Text description of the desired edit
|
|
1107
|
-
* @param image -
|
|
1164
|
+
* @param image - A base64 `data:image/...` URI, or an array of 2–4 such URIs
|
|
1165
|
+
* to fuse (image fusion). Caps: `openai/*` up to 4, `google/*` up to 3.
|
|
1166
|
+
* A `mask` cannot be combined with multiple source images.
|
|
1108
1167
|
* @param options - Optional edit parameters
|
|
1109
1168
|
* @returns ImageResponse with edited image URLs
|
|
1110
1169
|
*/
|
|
1111
|
-
imageEdit(prompt: string, image: string, options?: ImageEditOptions): Promise<ImageResponse>;
|
|
1170
|
+
imageEdit(prompt: string, image: string | string[], options?: ImageEditOptions): Promise<ImageResponse>;
|
|
1112
1171
|
/**
|
|
1113
1172
|
* Standalone search (web, X/Twitter, news).
|
|
1114
1173
|
*
|
|
@@ -1421,18 +1480,35 @@ declare class ImageClient {
|
|
|
1421
1480
|
*/
|
|
1422
1481
|
generate(prompt: string, options?: ImageGenerateOptions): Promise<ImageResponse>;
|
|
1423
1482
|
/**
|
|
1424
|
-
* Edit an image using img2img.
|
|
1483
|
+
* Edit an image using img2img, optionally fusing multiple source images.
|
|
1484
|
+
*
|
|
1485
|
+
* Pass a single `data:image/...` base64 data URI to edit one image, or an
|
|
1486
|
+
* array of 2–4 data URIs to fuse them (image fusion) — e.g. a reference photo
|
|
1487
|
+
* plus a brand logo. The server caps fusion per provider: `openai/*` accepts
|
|
1488
|
+
* up to 4 source images, `google/*` (Nano Banana) up to 3. A `mask` cannot be
|
|
1489
|
+
* combined with multiple source images.
|
|
1490
|
+
*
|
|
1491
|
+
* Edit-capable models: `openai/gpt-image-1`, `openai/gpt-image-2`,
|
|
1492
|
+
* `google/nano-banana`, `google/nano-banana-pro`.
|
|
1425
1493
|
*
|
|
1426
1494
|
* @param prompt - Text description of the desired edit
|
|
1427
|
-
* @param image -
|
|
1495
|
+
* @param image - A base64 `data:image/...` URI, or an array of 2–4 such URIs to fuse
|
|
1428
1496
|
* @param options - Optional edit parameters
|
|
1429
1497
|
* @returns ImageResponse with edited image URLs
|
|
1430
1498
|
*
|
|
1431
1499
|
* @example
|
|
1432
|
-
*
|
|
1433
|
-
*
|
|
1500
|
+
* // Single-image edit
|
|
1501
|
+
* const result = await client.edit('Make it a painting', imageDataUri);
|
|
1502
|
+
*
|
|
1503
|
+
* @example
|
|
1504
|
+
* // Multi-image fusion (Nano Banana): blend a subject with a brand logo
|
|
1505
|
+
* const fused = await client.edit(
|
|
1506
|
+
* 'Place the logo on the t-shirt',
|
|
1507
|
+
* [subjectDataUri, logoDataUri],
|
|
1508
|
+
* { model: 'google/nano-banana' }
|
|
1509
|
+
* );
|
|
1434
1510
|
*/
|
|
1435
|
-
edit(prompt: string, image: string, options?: ImageEditOptions): Promise<ImageResponse>;
|
|
1511
|
+
edit(prompt: string, image: string | string[], options?: ImageEditOptions): Promise<ImageResponse>;
|
|
1436
1512
|
/**
|
|
1437
1513
|
* List available image generation models with pricing.
|
|
1438
1514
|
*
|
|
@@ -1774,6 +1850,75 @@ declare class PhoneClient {
|
|
|
1774
1850
|
private fetchWithTimeout;
|
|
1775
1851
|
}
|
|
1776
1852
|
|
|
1853
|
+
/**
|
|
1854
|
+
* BlockRun Portrait Client — enroll a Virtual Portrait via x402.
|
|
1855
|
+
*
|
|
1856
|
+
* Wraps `POST /v1/portrait/enroll` ($0.01 USDC promo, no KYC). You upload a face image
|
|
1857
|
+
* by URL and get back a Token360 asset id (`ta_xxxxxx`). Pass that id as
|
|
1858
|
+
* `realFaceAssetId` on a Seedance 2.0 video generation (VideoClient.generate)
|
|
1859
|
+
* to keep the same AI character across clips.
|
|
1860
|
+
*
|
|
1861
|
+
* SECURITY NOTE — your private key never leaves your machine. Only EIP-712
|
|
1862
|
+
* signatures are sent in the PAYMENT-SIGNATURE header.
|
|
1863
|
+
*
|
|
1864
|
+
* @example
|
|
1865
|
+
* import { PortraitClient, VideoClient } from '@blockrun/llm';
|
|
1866
|
+
*
|
|
1867
|
+
* const portraits = new PortraitClient({ privateKey: '0x...' });
|
|
1868
|
+
* const { asset_id } = await portraits.enroll({
|
|
1869
|
+
* name: 'Spokesperson',
|
|
1870
|
+
* imageUrl: 'https://example.com/face.jpg',
|
|
1871
|
+
* });
|
|
1872
|
+
*
|
|
1873
|
+
* const video = new VideoClient({ privateKey: '0x...' });
|
|
1874
|
+
* const clip = await video.generate('she waves and smiles', {
|
|
1875
|
+
* model: 'bytedance/seedance-2.0-fast',
|
|
1876
|
+
* realFaceAssetId: asset_id,
|
|
1877
|
+
* });
|
|
1878
|
+
*/
|
|
1879
|
+
|
|
1880
|
+
/**
|
|
1881
|
+
* Flat enrollment price in USD — mirrors the backend's `ENROLLMENT_PRICE_USD`.
|
|
1882
|
+
* Currently $0.01 (promotional, parity with RealFace). The authoritative price
|
|
1883
|
+
* is whatever the gateway quotes in the 402; this constant is informational.
|
|
1884
|
+
*/
|
|
1885
|
+
declare const PORTRAIT_ENROLLMENT_PRICE_USD = 0.01;
|
|
1886
|
+
/**
|
|
1887
|
+
* BlockRun Portrait Client.
|
|
1888
|
+
*
|
|
1889
|
+
* Enrolls a Virtual Portrait from a face image URL and returns the `ta_xxxxxx`
|
|
1890
|
+
* asset id consumed by Seedance 2.0 video generation. Real-person likeness is
|
|
1891
|
+
* not supported on BlockRun — enrolled portraits are AI characters.
|
|
1892
|
+
*/
|
|
1893
|
+
declare class PortraitClient {
|
|
1894
|
+
private account;
|
|
1895
|
+
private privateKey;
|
|
1896
|
+
private apiUrl;
|
|
1897
|
+
private timeout;
|
|
1898
|
+
private sessionTotalUsd;
|
|
1899
|
+
private sessionCalls;
|
|
1900
|
+
constructor(options?: PortraitClientOptions);
|
|
1901
|
+
/** EVM wallet address used for payments. */
|
|
1902
|
+
getWalletAddress(): string;
|
|
1903
|
+
/** Session-cumulative USD spend + call count across this client instance. */
|
|
1904
|
+
getSpending(): Spending;
|
|
1905
|
+
/**
|
|
1906
|
+
* Enroll a Virtual Portrait from a face image URL. $0.01 (promo).
|
|
1907
|
+
*
|
|
1908
|
+
* Payment is settled only after Token360 confirms the enrollment, so failed
|
|
1909
|
+
* enrollments never charge your wallet.
|
|
1910
|
+
*
|
|
1911
|
+
* @param options.name Display name (1–64 chars).
|
|
1912
|
+
* @param options.imageUrl Public HTTPS URL to a JPG/PNG/WEBP image (≤10 MB).
|
|
1913
|
+
* @returns The enrollment record, including `asset_id` (`ta_xxxxxx`).
|
|
1914
|
+
*/
|
|
1915
|
+
enroll(options: PortraitEnrollOptions): Promise<PortraitEnrollResponse>;
|
|
1916
|
+
private request;
|
|
1917
|
+
private handlePaymentAndRetry;
|
|
1918
|
+
private unwrap;
|
|
1919
|
+
private fetchWithTimeout;
|
|
1920
|
+
}
|
|
1921
|
+
|
|
1777
1922
|
/**
|
|
1778
1923
|
* BlockRun Search Client - Standalone Grok Live Search via x402 micropayments.
|
|
1779
1924
|
*
|
|
@@ -2378,7 +2523,7 @@ declare class SolanaLLMClient {
|
|
|
2378
2523
|
*/
|
|
2379
2524
|
getBalance(): Promise<number>;
|
|
2380
2525
|
/** Edit an image using img2img (Solana payment). */
|
|
2381
|
-
imageEdit(prompt: string, image: string, options?: ImageEditOptions): Promise<ImageResponse>;
|
|
2526
|
+
imageEdit(prompt: string, image: string | string[], options?: ImageEditOptions): Promise<ImageResponse>;
|
|
2382
2527
|
/** Standalone search (Solana payment). */
|
|
2383
2528
|
search(query: string, options?: SearchOptions): Promise<SearchResult>;
|
|
2384
2529
|
xUserLookup(usernames: string | string[]): Promise<XUserLookupResponse>;
|
|
@@ -2762,4 +2907,4 @@ declare function validateTemperature(temperature?: number): void;
|
|
|
2762
2907
|
*/
|
|
2763
2908
|
declare function validateTopP(topP?: number): void;
|
|
2764
2909
|
|
|
2765
|
-
export { APIError, AnthropicClient, type AudioModel, type AudioTrack, BASE_CHAIN_ID, type BarResolution, type BlockRunAnthropicOptions, BlockrunClient, type BlockrunClientOptions, BlockrunError, type CallInitiatedResponse, type CallModel, type CallOptions, type CallStatusResponse, type ChatChoice, type ChatCompletionOptions, type ChatMessage, type ChatOptions, type ChatResponse, type ChatResponseWithCost, type ChatUsage, type CostEntry, type CostEstimate, type CreatePaymentOptions, type FunctionCall, type FunctionDefinition, type HistoryOptions, ImageClient, type ImageClientOptions, type ImageData, type ImageEditOptions, type ImageGenerateOptions, type ImageModel, type ImageResponse, KNOWN_PROVIDERS, LLMClient, type LLMClientOptions, type ListOptions, type MarketSession, type Model, MusicClient, type MusicClientOptions, type MusicGenerateOptions, type MusicResponse, type NewsSearchSource, OpenAI, type OpenAIChatCompletionChoice, type OpenAIChatCompletionChunk, type OpenAIChatCompletionParams, type OpenAIChatCompletionResponse, type OpenAIClientOptions, PHONE_PRICES, PaymentError, type PaymentLinks, type PhoneBuyOptions, type PhoneBuyResponse, PhoneClient, type PhoneClientOptions, type PhoneListResponse, type PhoneLookupResponse, type PhoneNumberRecord, type PhoneReleaseResponse, type PhoneRenewResponse, type PollOptions, type PriceBar, type PriceCategory, PriceClient, type PriceClientOptions, type PriceHistoryResponse, type PriceOptions, type PricePoint, type RoutingDecision, type RoutingProfile, type RoutingTier, type RssSearchSource, SOLANA_NETWORK, SOLANA_WALLET_FILE as SOLANA_WALLET_FILE_PATH, SearchClient, type SearchClientOptions, type SearchOptions, type SearchParameters, type SearchResult, type SearchSource, type SearchUsage, type SmartChatOptions, type SmartChatResponse, SolanaLLMClient, type SolanaLLMClientOptions, type SolanaWalletInfo, type Spending, type SpendingReport, type StockMarket, SurfClient, type SurfClientOptions, type SymbolListResponse, type Tool, type ToolCall, type ToolChoice, USDC_BASE, USDC_BASE_CONTRACT, USDC_SOLANA, VideoClient, type VideoClientOptions, type VideoClip, type VideoGenerateOptions, type VideoModel, type VideoResponse, VoiceClient, type VoiceClientOptions, type VoicePreset, WALLET_DIR_PATH, WALLET_FILE_PATH, type WalletInfo, type WebSearchSource, type XArticlesRisingResponse, type XAuthorAnalyticsResponse, XClient, type XClientOptions, type XCompareAuthorsResponse, type XFollower, type XFollowersResponse, type XFollowingsResponse, type XMentionsOptions, type XMentionsResponse, type XSearchOptions, type XSearchResponse, type XSearchSource, type XTrendingResponse, type XTweet, type XTweetLookupResponse, type XTweetRepliesOptions, type XTweetRepliesResponse, type XTweetThreadResponse, type XTweetsResponse, type XUser, type XUserInfoResponse, type XUserLookupResponse, type XUserTweetsOptions, type XVerifiedFollowersResponse, clearCache, createPaymentPayload, createSolanaPaymentPayload, createSolanaWallet, createWallet, LLMClient as default, extractPaymentDetails, formatFundingMessageCompact, formatNeedsFundingMessage, formatWalletCreatedMessage, getCached, getCachedByRequest, getCostLogSummary, getCostSummary, getEip681Uri, getOrCreateSolanaWallet, getOrCreateWallet, getPaymentLinks, getWalletAddress, loadSolanaWallet, loadWallet, logCost, parsePaymentRequired, saveSolanaWallet, saveToCache, saveWallet, scanSolanaWallets, scanWallets, setCache, setupAgentSolanaWallet, setupAgentWallet, solanaClient, solanaKeyToBytes, solanaPublicKey, status, validateMaxTokens, validateModel, validateTemperature, validateTopP };
|
|
2910
|
+
export { APIError, AnthropicClient, type AudioModel, type AudioTrack, BASE_CHAIN_ID, type BarResolution, type BlockRunAnthropicOptions, BlockrunClient, type BlockrunClientOptions, BlockrunError, type CallInitiatedResponse, type CallModel, type CallOptions, type CallStatusResponse, type ChatChoice, type ChatCompletionOptions, type ChatMessage, type ChatOptions, type ChatResponse, type ChatResponseWithCost, type ChatUsage, type CostEntry, type CostEstimate, type CreatePaymentOptions, type FunctionCall, type FunctionDefinition, type HistoryOptions, ImageClient, type ImageClientOptions, type ImageData, type ImageEditOptions, type ImageGenerateOptions, type ImageModel, type ImageResponse, KNOWN_PROVIDERS, LLMClient, type LLMClientOptions, type ListOptions, type MarketSession, type Model, MusicClient, type MusicClientOptions, type MusicGenerateOptions, type MusicResponse, type NewsSearchSource, OpenAI, type OpenAIChatCompletionChoice, type OpenAIChatCompletionChunk, type OpenAIChatCompletionParams, type OpenAIChatCompletionResponse, type OpenAIClientOptions, PHONE_PRICES, PORTRAIT_ENROLLMENT_PRICE_USD, PaymentError, type PaymentLinks, type PhoneBuyOptions, type PhoneBuyResponse, PhoneClient, type PhoneClientOptions, type PhoneListResponse, type PhoneLookupResponse, type PhoneNumberRecord, type PhoneReleaseResponse, type PhoneRenewResponse, type PollOptions, PortraitClient, type PortraitClientOptions, type PortraitEnrollOptions, type PortraitEnrollResponse, type PriceBar, type PriceCategory, PriceClient, type PriceClientOptions, type PriceHistoryResponse, type PriceOptions, type PricePoint, type RoutingDecision, type RoutingProfile, type RoutingTier, type RssSearchSource, SOLANA_NETWORK, SOLANA_WALLET_FILE as SOLANA_WALLET_FILE_PATH, SearchClient, type SearchClientOptions, type SearchOptions, type SearchParameters, type SearchResult, type SearchSource, type SearchUsage, type SmartChatOptions, type SmartChatResponse, SolanaLLMClient, type SolanaLLMClientOptions, type SolanaWalletInfo, type Spending, type SpendingReport, type StockMarket, SurfClient, type SurfClientOptions, type SymbolListResponse, type Tool, type ToolCall, type ToolChoice, USDC_BASE, USDC_BASE_CONTRACT, USDC_SOLANA, VideoClient, type VideoClientOptions, type VideoClip, type VideoGenerateOptions, type VideoModel, type VideoResponse, VoiceClient, type VoiceClientOptions, type VoicePreset, WALLET_DIR_PATH, WALLET_FILE_PATH, type WalletInfo, type WebSearchSource, type XArticlesRisingResponse, type XAuthorAnalyticsResponse, XClient, type XClientOptions, type XCompareAuthorsResponse, type XFollower, type XFollowersResponse, type XFollowingsResponse, type XMentionsOptions, type XMentionsResponse, type XSearchOptions, type XSearchResponse, type XSearchSource, type XTrendingResponse, type XTweet, type XTweetLookupResponse, type XTweetRepliesOptions, type XTweetRepliesResponse, type XTweetThreadResponse, type XTweetsResponse, type XUser, type XUserInfoResponse, type XUserLookupResponse, type XUserTweetsOptions, type XVerifiedFollowersResponse, clearCache, createPaymentPayload, createSolanaPaymentPayload, createSolanaWallet, createWallet, LLMClient as default, extractPaymentDetails, formatFundingMessageCompact, formatNeedsFundingMessage, formatWalletCreatedMessage, getCached, getCachedByRequest, getCostLogSummary, getCostSummary, getEip681Uri, getOrCreateSolanaWallet, getOrCreateWallet, getPaymentLinks, getWalletAddress, loadSolanaWallet, loadWallet, logCost, parsePaymentRequired, saveSolanaWallet, saveToCache, saveWallet, scanSolanaWallets, scanWallets, setCache, setupAgentSolanaWallet, setupAgentWallet, solanaClient, solanaKeyToBytes, solanaPublicKey, status, validateMaxTokens, validateModel, validateTemperature, validateTopP };
|