@blockrun/llm 2.1.0 → 2.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 +29 -0
- package/dist/index.cjs +427 -29
- package/dist/index.d.cts +214 -6
- package/dist/index.d.ts +214 -6
- package/dist/index.js +424 -28
- package/package.json +13 -13
package/dist/index.d.cts
CHANGED
|
@@ -291,7 +291,7 @@ interface ChatCompletionOptions {
|
|
|
291
291
|
*/
|
|
292
292
|
fallbackModels?: string[];
|
|
293
293
|
}
|
|
294
|
-
type RoutingProfile = "
|
|
294
|
+
type RoutingProfile = "eco" | "auto" | "premium";
|
|
295
295
|
type RoutingTier = "SIMPLE" | "MEDIUM" | "COMPLEX" | "REASONING";
|
|
296
296
|
interface RoutingDecision {
|
|
297
297
|
model: string;
|
|
@@ -302,6 +302,10 @@ interface RoutingDecision {
|
|
|
302
302
|
costEstimate: number;
|
|
303
303
|
baselineCost: number;
|
|
304
304
|
savings: number;
|
|
305
|
+
/** Routing profile applied by clawrouter (may include "agentic" on gateway responses). */
|
|
306
|
+
profile?: RoutingProfile | "agentic";
|
|
307
|
+
/** Score used when agentic routing is active. */
|
|
308
|
+
agenticScore?: number;
|
|
305
309
|
/**
|
|
306
310
|
* Remaining tier models with known pricing, in fallback order. `chat()`
|
|
307
311
|
* walks this list when the primary model hits a transient error
|
|
@@ -310,7 +314,7 @@ interface RoutingDecision {
|
|
|
310
314
|
fallbacks?: string[];
|
|
311
315
|
}
|
|
312
316
|
interface SmartChatOptions extends ChatOptions {
|
|
313
|
-
/** Routing profile:
|
|
317
|
+
/** Routing profile: eco (budget), auto (balanced), premium (best quality) */
|
|
314
318
|
routingProfile?: RoutingProfile;
|
|
315
319
|
/** Maximum output tokens (used for cost estimation) */
|
|
316
320
|
maxOutputTokens?: number;
|
|
@@ -379,6 +383,74 @@ interface MusicGenerateOptions {
|
|
|
379
383
|
/** Custom lyrics — cannot be used with instrumental: true */
|
|
380
384
|
lyrics?: string;
|
|
381
385
|
}
|
|
386
|
+
/** Built-in Bland.ai voice presets. Any string is accepted (custom voice IDs work too). */
|
|
387
|
+
type VoicePreset = "nat" | "josh" | "maya" | "june" | "paige" | "derek" | "florian";
|
|
388
|
+
/** Bland.ai conversation model tier. */
|
|
389
|
+
type CallModel = "base" | "enhanced" | "turbo";
|
|
390
|
+
interface VoiceClientOptions {
|
|
391
|
+
/** EVM wallet private key (hex string starting with 0x) */
|
|
392
|
+
privateKey?: `0x${string}` | string;
|
|
393
|
+
/** API endpoint URL (default: https://blockrun.ai/api) */
|
|
394
|
+
apiUrl?: string;
|
|
395
|
+
/** Request timeout in milliseconds (default: 60000 — initiation only) */
|
|
396
|
+
timeout?: number;
|
|
397
|
+
}
|
|
398
|
+
interface CallOptions {
|
|
399
|
+
/** Destination phone number in E.164 format (e.g. "+14155552671"). US + Canada. */
|
|
400
|
+
to: string;
|
|
401
|
+
/** What the AI agent should do on the call. 10–4000 chars. */
|
|
402
|
+
task: string;
|
|
403
|
+
/** Your provisioned BlockRun caller-ID number (E.164). Must be wallet-owned. */
|
|
404
|
+
from?: string;
|
|
405
|
+
/** Voice preset or any Bland.ai voice ID. */
|
|
406
|
+
voice?: VoicePreset | string;
|
|
407
|
+
/** Maximum call length in minutes (1–30, default 5). */
|
|
408
|
+
max_duration?: number;
|
|
409
|
+
/** BCP-47 language code for STT/TTS (default "en-US"). */
|
|
410
|
+
language?: string;
|
|
411
|
+
/** Optional opening line spoken by the agent. */
|
|
412
|
+
first_sentence?: string;
|
|
413
|
+
/** If true, wait for the recipient to speak first. */
|
|
414
|
+
wait_for_greeting?: boolean;
|
|
415
|
+
/** Sensitivity for detecting recipient interruption (50–500 ms). */
|
|
416
|
+
interruption_threshold?: number;
|
|
417
|
+
/** Conversation model. */
|
|
418
|
+
model?: CallModel;
|
|
419
|
+
}
|
|
420
|
+
interface CallInitiatedResponse {
|
|
421
|
+
call_id: string;
|
|
422
|
+
status: string;
|
|
423
|
+
poll_url: string;
|
|
424
|
+
message?: string;
|
|
425
|
+
/** On-chain payment receipt (Base tx hash). */
|
|
426
|
+
txHash?: string;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Bland.ai call status payload. Returned from getStatus.
|
|
430
|
+
* Most fields are populated only after the call ends.
|
|
431
|
+
*/
|
|
432
|
+
interface CallStatusResponse {
|
|
433
|
+
call_id?: string;
|
|
434
|
+
status?: string;
|
|
435
|
+
to?: string;
|
|
436
|
+
from?: string;
|
|
437
|
+
/** ISO timestamp call started, or null while queued. */
|
|
438
|
+
started_at?: string | null;
|
|
439
|
+
/** ISO timestamp call ended, or null while in progress. */
|
|
440
|
+
ended_at?: string | null;
|
|
441
|
+
/** Total call length in seconds, once completed. */
|
|
442
|
+
call_length?: number;
|
|
443
|
+
/** URL to the call recording (mp3/wav). */
|
|
444
|
+
recording_url?: string | null;
|
|
445
|
+
/** Full text transcript of the call. */
|
|
446
|
+
concatenated_transcript?: string | null;
|
|
447
|
+
/** Per-turn transcript array. Shape comes from Bland.ai. */
|
|
448
|
+
transcripts?: Array<Record<string, unknown>>;
|
|
449
|
+
/** Why the call ended ("user_hangup", "agent_hangup", "timeout", …). */
|
|
450
|
+
ended_reason?: string | null;
|
|
451
|
+
/** Pass-through for anything Bland.ai adds. */
|
|
452
|
+
[key: string]: unknown;
|
|
453
|
+
}
|
|
382
454
|
interface VideoClip {
|
|
383
455
|
/** Permanent blockrun-hosted URL (falls back to upstream if backup fails) */
|
|
384
456
|
url: string;
|
|
@@ -781,9 +853,6 @@ declare class LLMClient {
|
|
|
781
853
|
*
|
|
782
854
|
* @example With routing profile
|
|
783
855
|
* ```ts
|
|
784
|
-
* // Free tier only (zero cost)
|
|
785
|
-
* const result = await client.smartChat('Hello!', { routingProfile: 'free' });
|
|
786
|
-
*
|
|
787
856
|
* // Eco mode (budget optimized)
|
|
788
857
|
* const result = await client.smartChat('Explain quantum computing', { routingProfile: 'eco' });
|
|
789
858
|
*
|
|
@@ -1353,6 +1422,145 @@ declare class MusicClient {
|
|
|
1353
1422
|
getSpending(): Spending;
|
|
1354
1423
|
}
|
|
1355
1424
|
|
|
1425
|
+
/**
|
|
1426
|
+
* BlockRun Video Client - Generate short AI videos via x402 micropayments.
|
|
1427
|
+
*
|
|
1428
|
+
* SECURITY NOTE - Private Key Handling:
|
|
1429
|
+
* Your private key NEVER leaves your machine. Here's what happens:
|
|
1430
|
+
* 1. Key stays local - only used to sign an EIP-712 typed data message
|
|
1431
|
+
* 2. Only the SIGNATURE is sent in the PAYMENT-SIGNATURE header
|
|
1432
|
+
* 3. BlockRun verifies the signature on-chain via Coinbase CDP facilitator
|
|
1433
|
+
*
|
|
1434
|
+
* Async flow (client-polled):
|
|
1435
|
+
* POST /v1/videos/generations -> 402 -> sign -> 202 { id, poll_url }
|
|
1436
|
+
* GET /v1/videos/generations/{id} -> loop until status=completed
|
|
1437
|
+
*
|
|
1438
|
+
* The client signs ONCE and replays the same PAYMENT-SIGNATURE on every poll.
|
|
1439
|
+
* Settlement happens only on the first completed poll, so upstream failure or
|
|
1440
|
+
* the caller giving up = zero charge.
|
|
1441
|
+
*
|
|
1442
|
+
* Usage:
|
|
1443
|
+
* import { VideoClient } from '@blockrun/llm';
|
|
1444
|
+
*
|
|
1445
|
+
* const client = new VideoClient({ privateKey: '0x...' });
|
|
1446
|
+
* const result = await client.generate('a red apple slowly spinning on a wooden table');
|
|
1447
|
+
* console.log(result.data[0].url); // permanent MP4 URL
|
|
1448
|
+
* console.log(result.data[0].duration_seconds);
|
|
1449
|
+
*/
|
|
1450
|
+
|
|
1451
|
+
/**
|
|
1452
|
+
* BlockRun Video Generation Client.
|
|
1453
|
+
*
|
|
1454
|
+
* Supports xAI Grok Imagine Video and ByteDance Seedance (1.5 Pro /
|
|
1455
|
+
* 2.0 Fast / 2.0 Pro) with automatic x402 micropayments on Base.
|
|
1456
|
+
*/
|
|
1457
|
+
declare class VideoClient {
|
|
1458
|
+
private account;
|
|
1459
|
+
private privateKey;
|
|
1460
|
+
private apiUrl;
|
|
1461
|
+
private timeout;
|
|
1462
|
+
private sessionTotalUsd;
|
|
1463
|
+
private sessionCalls;
|
|
1464
|
+
constructor(options?: VideoClientOptions);
|
|
1465
|
+
/**
|
|
1466
|
+
* Generate a short video clip from a text prompt (or text + image).
|
|
1467
|
+
*
|
|
1468
|
+
* Submits an async job, then polls until the video is ready. Typical total
|
|
1469
|
+
* wall-time is 60-180s. If upstream runs past the budget (default 5min),
|
|
1470
|
+
* throws without charging.
|
|
1471
|
+
*
|
|
1472
|
+
* @param prompt - Text description of the video
|
|
1473
|
+
* @param options - Optional generation parameters
|
|
1474
|
+
*/
|
|
1475
|
+
generate(prompt: string, options?: VideoGenerateOptions & {
|
|
1476
|
+
budgetMs?: number;
|
|
1477
|
+
}): Promise<VideoResponse>;
|
|
1478
|
+
private submitAndPoll;
|
|
1479
|
+
private absolute;
|
|
1480
|
+
private extractPaymentRequired;
|
|
1481
|
+
private throwApiError;
|
|
1482
|
+
private fetchWithTimeout;
|
|
1483
|
+
getWalletAddress(): string;
|
|
1484
|
+
getSpending(): Spending;
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
/**
|
|
1488
|
+
* BlockRun Voice Call Client - AI-powered outbound phone calls via x402 micropayments.
|
|
1489
|
+
*
|
|
1490
|
+
* The AI agent calls a phone number (E.164) and conducts a real-time conversation
|
|
1491
|
+
* based on your 'task' instructions. STT, LLM, and TTS are handled upstream by
|
|
1492
|
+
* Bland.ai; BlockRun handles billing through x402.
|
|
1493
|
+
*
|
|
1494
|
+
* SECURITY NOTE - Private Key Handling:
|
|
1495
|
+
* Your private key NEVER leaves your machine. Here's what happens:
|
|
1496
|
+
* 1. Key stays local - only used to sign an EIP-712 typed data message
|
|
1497
|
+
* 2. Only the SIGNATURE is sent in the PAYMENT-SIGNATURE header
|
|
1498
|
+
* 3. BlockRun verifies the signature on-chain via Coinbase CDP facilitator
|
|
1499
|
+
*
|
|
1500
|
+
* Usage:
|
|
1501
|
+
* import { VoiceClient } from '@blockrun/llm';
|
|
1502
|
+
*
|
|
1503
|
+
* const client = new VoiceClient({ privateKey: '0x...' });
|
|
1504
|
+
*
|
|
1505
|
+
* // Initiate a call (paid, $0.54)
|
|
1506
|
+
* const result = await client.call({
|
|
1507
|
+
* to: '+14155552671',
|
|
1508
|
+
* task: 'You are a friendly assistant calling to confirm a 3pm dentist appointment.',
|
|
1509
|
+
* max_duration: 5,
|
|
1510
|
+
* });
|
|
1511
|
+
* console.log(result.call_id);
|
|
1512
|
+
*
|
|
1513
|
+
* // Poll status, transcript, recording (free)
|
|
1514
|
+
* const status = await client.getStatus(result.call_id);
|
|
1515
|
+
* console.log(status);
|
|
1516
|
+
*/
|
|
1517
|
+
|
|
1518
|
+
/**
|
|
1519
|
+
* BlockRun Voice Call Client.
|
|
1520
|
+
*
|
|
1521
|
+
* Initiates AI-powered outbound phone calls with automatic x402 micropayments
|
|
1522
|
+
* on Base chain.
|
|
1523
|
+
*
|
|
1524
|
+
* Pricing: $0.54 per call (regardless of duration up to max_duration).
|
|
1525
|
+
* Status polling is free.
|
|
1526
|
+
*/
|
|
1527
|
+
declare class VoiceClient {
|
|
1528
|
+
private account;
|
|
1529
|
+
private privateKey;
|
|
1530
|
+
private apiUrl;
|
|
1531
|
+
private timeout;
|
|
1532
|
+
private sessionTotalUsd;
|
|
1533
|
+
private sessionCalls;
|
|
1534
|
+
constructor(options?: VoiceClientOptions);
|
|
1535
|
+
/**
|
|
1536
|
+
* Initiate an AI-powered outbound phone call.
|
|
1537
|
+
*
|
|
1538
|
+
* Pricing: $0.54 per call. Returns immediately once the call is queued —
|
|
1539
|
+
* poll getStatus() for transcript and recording.
|
|
1540
|
+
*
|
|
1541
|
+
* @example
|
|
1542
|
+
* const r = await client.call({
|
|
1543
|
+
* to: '+14155552671',
|
|
1544
|
+
* task: 'Confirm the user wants to reschedule to Tuesday 2pm.',
|
|
1545
|
+
* voice: 'maya',
|
|
1546
|
+
* max_duration: 3,
|
|
1547
|
+
* });
|
|
1548
|
+
*/
|
|
1549
|
+
call(options: CallOptions): Promise<CallInitiatedResponse>;
|
|
1550
|
+
/**
|
|
1551
|
+
* Poll the status of an in-progress or completed call. Free — no payment.
|
|
1552
|
+
*
|
|
1553
|
+
* Returns Bland.ai's full call record: status, transcript, recording URL, etc.
|
|
1554
|
+
* Most fields populate only once the call ends.
|
|
1555
|
+
*/
|
|
1556
|
+
getStatus(callId: string): Promise<CallStatusResponse>;
|
|
1557
|
+
private requestWithPayment;
|
|
1558
|
+
private handlePaymentAndRetry;
|
|
1559
|
+
private fetchWithTimeout;
|
|
1560
|
+
getWalletAddress(): string;
|
|
1561
|
+
getSpending(): Spending;
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1356
1564
|
/**
|
|
1357
1565
|
* BlockRun Search Client - Standalone Grok Live Search via x402 micropayments.
|
|
1358
1566
|
*
|
|
@@ -2130,4 +2338,4 @@ declare function validateTemperature(temperature?: number): void;
|
|
|
2130
2338
|
*/
|
|
2131
2339
|
declare function validateTopP(topP?: number): void;
|
|
2132
2340
|
|
|
2133
|
-
export { APIError, AnthropicClient, type AudioModel, type AudioTrack, BASE_CHAIN_ID, type BarResolution, type BlockRunAnthropicOptions, BlockrunError, 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, PaymentError, type PaymentLinks, 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, type SymbolListResponse, type Tool, type ToolCall, type ToolChoice, USDC_BASE, USDC_BASE_CONTRACT, USDC_SOLANA, type VideoClientOptions, type VideoClip, type VideoGenerateOptions, type VideoModel, type VideoResponse, 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 };
|
|
2341
|
+
export { APIError, AnthropicClient, type AudioModel, type AudioTrack, BASE_CHAIN_ID, type BarResolution, type BlockRunAnthropicOptions, 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, PaymentError, type PaymentLinks, 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, 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
|
@@ -291,7 +291,7 @@ interface ChatCompletionOptions {
|
|
|
291
291
|
*/
|
|
292
292
|
fallbackModels?: string[];
|
|
293
293
|
}
|
|
294
|
-
type RoutingProfile = "
|
|
294
|
+
type RoutingProfile = "eco" | "auto" | "premium";
|
|
295
295
|
type RoutingTier = "SIMPLE" | "MEDIUM" | "COMPLEX" | "REASONING";
|
|
296
296
|
interface RoutingDecision {
|
|
297
297
|
model: string;
|
|
@@ -302,6 +302,10 @@ interface RoutingDecision {
|
|
|
302
302
|
costEstimate: number;
|
|
303
303
|
baselineCost: number;
|
|
304
304
|
savings: number;
|
|
305
|
+
/** Routing profile applied by clawrouter (may include "agentic" on gateway responses). */
|
|
306
|
+
profile?: RoutingProfile | "agentic";
|
|
307
|
+
/** Score used when agentic routing is active. */
|
|
308
|
+
agenticScore?: number;
|
|
305
309
|
/**
|
|
306
310
|
* Remaining tier models with known pricing, in fallback order. `chat()`
|
|
307
311
|
* walks this list when the primary model hits a transient error
|
|
@@ -310,7 +314,7 @@ interface RoutingDecision {
|
|
|
310
314
|
fallbacks?: string[];
|
|
311
315
|
}
|
|
312
316
|
interface SmartChatOptions extends ChatOptions {
|
|
313
|
-
/** Routing profile:
|
|
317
|
+
/** Routing profile: eco (budget), auto (balanced), premium (best quality) */
|
|
314
318
|
routingProfile?: RoutingProfile;
|
|
315
319
|
/** Maximum output tokens (used for cost estimation) */
|
|
316
320
|
maxOutputTokens?: number;
|
|
@@ -379,6 +383,74 @@ interface MusicGenerateOptions {
|
|
|
379
383
|
/** Custom lyrics — cannot be used with instrumental: true */
|
|
380
384
|
lyrics?: string;
|
|
381
385
|
}
|
|
386
|
+
/** Built-in Bland.ai voice presets. Any string is accepted (custom voice IDs work too). */
|
|
387
|
+
type VoicePreset = "nat" | "josh" | "maya" | "june" | "paige" | "derek" | "florian";
|
|
388
|
+
/** Bland.ai conversation model tier. */
|
|
389
|
+
type CallModel = "base" | "enhanced" | "turbo";
|
|
390
|
+
interface VoiceClientOptions {
|
|
391
|
+
/** EVM wallet private key (hex string starting with 0x) */
|
|
392
|
+
privateKey?: `0x${string}` | string;
|
|
393
|
+
/** API endpoint URL (default: https://blockrun.ai/api) */
|
|
394
|
+
apiUrl?: string;
|
|
395
|
+
/** Request timeout in milliseconds (default: 60000 — initiation only) */
|
|
396
|
+
timeout?: number;
|
|
397
|
+
}
|
|
398
|
+
interface CallOptions {
|
|
399
|
+
/** Destination phone number in E.164 format (e.g. "+14155552671"). US + Canada. */
|
|
400
|
+
to: string;
|
|
401
|
+
/** What the AI agent should do on the call. 10–4000 chars. */
|
|
402
|
+
task: string;
|
|
403
|
+
/** Your provisioned BlockRun caller-ID number (E.164). Must be wallet-owned. */
|
|
404
|
+
from?: string;
|
|
405
|
+
/** Voice preset or any Bland.ai voice ID. */
|
|
406
|
+
voice?: VoicePreset | string;
|
|
407
|
+
/** Maximum call length in minutes (1–30, default 5). */
|
|
408
|
+
max_duration?: number;
|
|
409
|
+
/** BCP-47 language code for STT/TTS (default "en-US"). */
|
|
410
|
+
language?: string;
|
|
411
|
+
/** Optional opening line spoken by the agent. */
|
|
412
|
+
first_sentence?: string;
|
|
413
|
+
/** If true, wait for the recipient to speak first. */
|
|
414
|
+
wait_for_greeting?: boolean;
|
|
415
|
+
/** Sensitivity for detecting recipient interruption (50–500 ms). */
|
|
416
|
+
interruption_threshold?: number;
|
|
417
|
+
/** Conversation model. */
|
|
418
|
+
model?: CallModel;
|
|
419
|
+
}
|
|
420
|
+
interface CallInitiatedResponse {
|
|
421
|
+
call_id: string;
|
|
422
|
+
status: string;
|
|
423
|
+
poll_url: string;
|
|
424
|
+
message?: string;
|
|
425
|
+
/** On-chain payment receipt (Base tx hash). */
|
|
426
|
+
txHash?: string;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Bland.ai call status payload. Returned from getStatus.
|
|
430
|
+
* Most fields are populated only after the call ends.
|
|
431
|
+
*/
|
|
432
|
+
interface CallStatusResponse {
|
|
433
|
+
call_id?: string;
|
|
434
|
+
status?: string;
|
|
435
|
+
to?: string;
|
|
436
|
+
from?: string;
|
|
437
|
+
/** ISO timestamp call started, or null while queued. */
|
|
438
|
+
started_at?: string | null;
|
|
439
|
+
/** ISO timestamp call ended, or null while in progress. */
|
|
440
|
+
ended_at?: string | null;
|
|
441
|
+
/** Total call length in seconds, once completed. */
|
|
442
|
+
call_length?: number;
|
|
443
|
+
/** URL to the call recording (mp3/wav). */
|
|
444
|
+
recording_url?: string | null;
|
|
445
|
+
/** Full text transcript of the call. */
|
|
446
|
+
concatenated_transcript?: string | null;
|
|
447
|
+
/** Per-turn transcript array. Shape comes from Bland.ai. */
|
|
448
|
+
transcripts?: Array<Record<string, unknown>>;
|
|
449
|
+
/** Why the call ended ("user_hangup", "agent_hangup", "timeout", …). */
|
|
450
|
+
ended_reason?: string | null;
|
|
451
|
+
/** Pass-through for anything Bland.ai adds. */
|
|
452
|
+
[key: string]: unknown;
|
|
453
|
+
}
|
|
382
454
|
interface VideoClip {
|
|
383
455
|
/** Permanent blockrun-hosted URL (falls back to upstream if backup fails) */
|
|
384
456
|
url: string;
|
|
@@ -781,9 +853,6 @@ declare class LLMClient {
|
|
|
781
853
|
*
|
|
782
854
|
* @example With routing profile
|
|
783
855
|
* ```ts
|
|
784
|
-
* // Free tier only (zero cost)
|
|
785
|
-
* const result = await client.smartChat('Hello!', { routingProfile: 'free' });
|
|
786
|
-
*
|
|
787
856
|
* // Eco mode (budget optimized)
|
|
788
857
|
* const result = await client.smartChat('Explain quantum computing', { routingProfile: 'eco' });
|
|
789
858
|
*
|
|
@@ -1353,6 +1422,145 @@ declare class MusicClient {
|
|
|
1353
1422
|
getSpending(): Spending;
|
|
1354
1423
|
}
|
|
1355
1424
|
|
|
1425
|
+
/**
|
|
1426
|
+
* BlockRun Video Client - Generate short AI videos via x402 micropayments.
|
|
1427
|
+
*
|
|
1428
|
+
* SECURITY NOTE - Private Key Handling:
|
|
1429
|
+
* Your private key NEVER leaves your machine. Here's what happens:
|
|
1430
|
+
* 1. Key stays local - only used to sign an EIP-712 typed data message
|
|
1431
|
+
* 2. Only the SIGNATURE is sent in the PAYMENT-SIGNATURE header
|
|
1432
|
+
* 3. BlockRun verifies the signature on-chain via Coinbase CDP facilitator
|
|
1433
|
+
*
|
|
1434
|
+
* Async flow (client-polled):
|
|
1435
|
+
* POST /v1/videos/generations -> 402 -> sign -> 202 { id, poll_url }
|
|
1436
|
+
* GET /v1/videos/generations/{id} -> loop until status=completed
|
|
1437
|
+
*
|
|
1438
|
+
* The client signs ONCE and replays the same PAYMENT-SIGNATURE on every poll.
|
|
1439
|
+
* Settlement happens only on the first completed poll, so upstream failure or
|
|
1440
|
+
* the caller giving up = zero charge.
|
|
1441
|
+
*
|
|
1442
|
+
* Usage:
|
|
1443
|
+
* import { VideoClient } from '@blockrun/llm';
|
|
1444
|
+
*
|
|
1445
|
+
* const client = new VideoClient({ privateKey: '0x...' });
|
|
1446
|
+
* const result = await client.generate('a red apple slowly spinning on a wooden table');
|
|
1447
|
+
* console.log(result.data[0].url); // permanent MP4 URL
|
|
1448
|
+
* console.log(result.data[0].duration_seconds);
|
|
1449
|
+
*/
|
|
1450
|
+
|
|
1451
|
+
/**
|
|
1452
|
+
* BlockRun Video Generation Client.
|
|
1453
|
+
*
|
|
1454
|
+
* Supports xAI Grok Imagine Video and ByteDance Seedance (1.5 Pro /
|
|
1455
|
+
* 2.0 Fast / 2.0 Pro) with automatic x402 micropayments on Base.
|
|
1456
|
+
*/
|
|
1457
|
+
declare class VideoClient {
|
|
1458
|
+
private account;
|
|
1459
|
+
private privateKey;
|
|
1460
|
+
private apiUrl;
|
|
1461
|
+
private timeout;
|
|
1462
|
+
private sessionTotalUsd;
|
|
1463
|
+
private sessionCalls;
|
|
1464
|
+
constructor(options?: VideoClientOptions);
|
|
1465
|
+
/**
|
|
1466
|
+
* Generate a short video clip from a text prompt (or text + image).
|
|
1467
|
+
*
|
|
1468
|
+
* Submits an async job, then polls until the video is ready. Typical total
|
|
1469
|
+
* wall-time is 60-180s. If upstream runs past the budget (default 5min),
|
|
1470
|
+
* throws without charging.
|
|
1471
|
+
*
|
|
1472
|
+
* @param prompt - Text description of the video
|
|
1473
|
+
* @param options - Optional generation parameters
|
|
1474
|
+
*/
|
|
1475
|
+
generate(prompt: string, options?: VideoGenerateOptions & {
|
|
1476
|
+
budgetMs?: number;
|
|
1477
|
+
}): Promise<VideoResponse>;
|
|
1478
|
+
private submitAndPoll;
|
|
1479
|
+
private absolute;
|
|
1480
|
+
private extractPaymentRequired;
|
|
1481
|
+
private throwApiError;
|
|
1482
|
+
private fetchWithTimeout;
|
|
1483
|
+
getWalletAddress(): string;
|
|
1484
|
+
getSpending(): Spending;
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
/**
|
|
1488
|
+
* BlockRun Voice Call Client - AI-powered outbound phone calls via x402 micropayments.
|
|
1489
|
+
*
|
|
1490
|
+
* The AI agent calls a phone number (E.164) and conducts a real-time conversation
|
|
1491
|
+
* based on your 'task' instructions. STT, LLM, and TTS are handled upstream by
|
|
1492
|
+
* Bland.ai; BlockRun handles billing through x402.
|
|
1493
|
+
*
|
|
1494
|
+
* SECURITY NOTE - Private Key Handling:
|
|
1495
|
+
* Your private key NEVER leaves your machine. Here's what happens:
|
|
1496
|
+
* 1. Key stays local - only used to sign an EIP-712 typed data message
|
|
1497
|
+
* 2. Only the SIGNATURE is sent in the PAYMENT-SIGNATURE header
|
|
1498
|
+
* 3. BlockRun verifies the signature on-chain via Coinbase CDP facilitator
|
|
1499
|
+
*
|
|
1500
|
+
* Usage:
|
|
1501
|
+
* import { VoiceClient } from '@blockrun/llm';
|
|
1502
|
+
*
|
|
1503
|
+
* const client = new VoiceClient({ privateKey: '0x...' });
|
|
1504
|
+
*
|
|
1505
|
+
* // Initiate a call (paid, $0.54)
|
|
1506
|
+
* const result = await client.call({
|
|
1507
|
+
* to: '+14155552671',
|
|
1508
|
+
* task: 'You are a friendly assistant calling to confirm a 3pm dentist appointment.',
|
|
1509
|
+
* max_duration: 5,
|
|
1510
|
+
* });
|
|
1511
|
+
* console.log(result.call_id);
|
|
1512
|
+
*
|
|
1513
|
+
* // Poll status, transcript, recording (free)
|
|
1514
|
+
* const status = await client.getStatus(result.call_id);
|
|
1515
|
+
* console.log(status);
|
|
1516
|
+
*/
|
|
1517
|
+
|
|
1518
|
+
/**
|
|
1519
|
+
* BlockRun Voice Call Client.
|
|
1520
|
+
*
|
|
1521
|
+
* Initiates AI-powered outbound phone calls with automatic x402 micropayments
|
|
1522
|
+
* on Base chain.
|
|
1523
|
+
*
|
|
1524
|
+
* Pricing: $0.54 per call (regardless of duration up to max_duration).
|
|
1525
|
+
* Status polling is free.
|
|
1526
|
+
*/
|
|
1527
|
+
declare class VoiceClient {
|
|
1528
|
+
private account;
|
|
1529
|
+
private privateKey;
|
|
1530
|
+
private apiUrl;
|
|
1531
|
+
private timeout;
|
|
1532
|
+
private sessionTotalUsd;
|
|
1533
|
+
private sessionCalls;
|
|
1534
|
+
constructor(options?: VoiceClientOptions);
|
|
1535
|
+
/**
|
|
1536
|
+
* Initiate an AI-powered outbound phone call.
|
|
1537
|
+
*
|
|
1538
|
+
* Pricing: $0.54 per call. Returns immediately once the call is queued —
|
|
1539
|
+
* poll getStatus() for transcript and recording.
|
|
1540
|
+
*
|
|
1541
|
+
* @example
|
|
1542
|
+
* const r = await client.call({
|
|
1543
|
+
* to: '+14155552671',
|
|
1544
|
+
* task: 'Confirm the user wants to reschedule to Tuesday 2pm.',
|
|
1545
|
+
* voice: 'maya',
|
|
1546
|
+
* max_duration: 3,
|
|
1547
|
+
* });
|
|
1548
|
+
*/
|
|
1549
|
+
call(options: CallOptions): Promise<CallInitiatedResponse>;
|
|
1550
|
+
/**
|
|
1551
|
+
* Poll the status of an in-progress or completed call. Free — no payment.
|
|
1552
|
+
*
|
|
1553
|
+
* Returns Bland.ai's full call record: status, transcript, recording URL, etc.
|
|
1554
|
+
* Most fields populate only once the call ends.
|
|
1555
|
+
*/
|
|
1556
|
+
getStatus(callId: string): Promise<CallStatusResponse>;
|
|
1557
|
+
private requestWithPayment;
|
|
1558
|
+
private handlePaymentAndRetry;
|
|
1559
|
+
private fetchWithTimeout;
|
|
1560
|
+
getWalletAddress(): string;
|
|
1561
|
+
getSpending(): Spending;
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1356
1564
|
/**
|
|
1357
1565
|
* BlockRun Search Client - Standalone Grok Live Search via x402 micropayments.
|
|
1358
1566
|
*
|
|
@@ -2130,4 +2338,4 @@ declare function validateTemperature(temperature?: number): void;
|
|
|
2130
2338
|
*/
|
|
2131
2339
|
declare function validateTopP(topP?: number): void;
|
|
2132
2340
|
|
|
2133
|
-
export { APIError, AnthropicClient, type AudioModel, type AudioTrack, BASE_CHAIN_ID, type BarResolution, type BlockRunAnthropicOptions, BlockrunError, 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, PaymentError, type PaymentLinks, 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, type SymbolListResponse, type Tool, type ToolCall, type ToolChoice, USDC_BASE, USDC_BASE_CONTRACT, USDC_SOLANA, type VideoClientOptions, type VideoClip, type VideoGenerateOptions, type VideoModel, type VideoResponse, 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 };
|
|
2341
|
+
export { APIError, AnthropicClient, type AudioModel, type AudioTrack, BASE_CHAIN_ID, type BarResolution, type BlockRunAnthropicOptions, 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, PaymentError, type PaymentLinks, 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, 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 };
|