@blockrun/llm 3.13.5 → 3.14.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 +99 -37
- package/dist/index.cjs +725 -348
- package/dist/index.d.cts +133 -469
- package/dist/index.d.ts +133 -469
- package/dist/index.js +722 -348
- package/package.json +12 -9
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import * as _anthropic_ai_sdk from '@anthropic-ai/sdk';
|
|
2
2
|
|
|
3
|
+
/** Account billing is independent of the wallet payment chain. */
|
|
4
|
+
interface ApiKeyOptions {
|
|
5
|
+
/** BlockRun account key. Defaults to BLOCKRUN_API_KEY unless a privateKey is explicit. */
|
|
6
|
+
apiKey?: string;
|
|
7
|
+
}
|
|
8
|
+
declare const API_KEY_URL = "https://api.blockrun.ai";
|
|
9
|
+
declare const PORTAL_URL = "https://user.blockrun.ai";
|
|
10
|
+
|
|
3
11
|
/**
|
|
4
12
|
* Smart Router Types
|
|
5
13
|
*
|
|
@@ -174,10 +182,6 @@ type RoutingConfig = {
|
|
|
174
182
|
overrides: OverridesConfig;
|
|
175
183
|
};
|
|
176
184
|
|
|
177
|
-
/**
|
|
178
|
-
* Type definitions for BlockRun LLM SDK
|
|
179
|
-
*/
|
|
180
|
-
|
|
181
185
|
interface FunctionDefinition {
|
|
182
186
|
name: string;
|
|
183
187
|
description?: string;
|
|
@@ -300,7 +304,7 @@ interface ImageModel {
|
|
|
300
304
|
available: boolean;
|
|
301
305
|
type?: "llm" | "image";
|
|
302
306
|
}
|
|
303
|
-
interface ImageClientOptions {
|
|
307
|
+
interface ImageClientOptions extends ApiKeyOptions {
|
|
304
308
|
/** EVM wallet private key (hex string starting with 0x) */
|
|
305
309
|
privateKey?: `0x${string}` | string;
|
|
306
310
|
/** API endpoint URL (default: https://blockrun.ai/api) */
|
|
@@ -417,7 +421,7 @@ interface PaymentRequired {
|
|
|
417
421
|
accepts: PaymentRequirement[];
|
|
418
422
|
resource?: ResourceInfo;
|
|
419
423
|
}
|
|
420
|
-
interface LLMClientOptions {
|
|
424
|
+
interface LLMClientOptions extends ApiKeyOptions {
|
|
421
425
|
/** EVM wallet private key (hex string starting with 0x). Optional if BASE_CHAIN_WALLET_KEY env var is set. */
|
|
422
426
|
privateKey?: `0x${string}` | string;
|
|
423
427
|
/** API endpoint URL (default: https://blockrun.ai/api) */
|
|
@@ -576,7 +580,7 @@ interface AudioModel {
|
|
|
576
580
|
available: boolean;
|
|
577
581
|
type: "audio";
|
|
578
582
|
}
|
|
579
|
-
interface MusicClientOptions {
|
|
583
|
+
interface MusicClientOptions extends ApiKeyOptions {
|
|
580
584
|
/** EVM wallet private key (hex string starting with 0x) */
|
|
581
585
|
privateKey?: `0x${string}` | string;
|
|
582
586
|
/** API endpoint URL (default: https://blockrun.ai/api) */
|
|
@@ -606,7 +610,7 @@ interface SpeechResponse {
|
|
|
606
610
|
data: SpeechAudio[];
|
|
607
611
|
txHash?: string;
|
|
608
612
|
}
|
|
609
|
-
interface SpeechClientOptions {
|
|
613
|
+
interface SpeechClientOptions extends ApiKeyOptions {
|
|
610
614
|
/** EVM wallet private key (hex string starting with 0x) */
|
|
611
615
|
privateKey?: `0x${string}` | string;
|
|
612
616
|
/** API endpoint URL (default: https://blockrun.ai/api) */
|
|
@@ -648,7 +652,7 @@ interface VoiceInfo {
|
|
|
648
652
|
preview_url?: string;
|
|
649
653
|
[key: string]: unknown;
|
|
650
654
|
}
|
|
651
|
-
interface RpcClientOptions {
|
|
655
|
+
interface RpcClientOptions extends ApiKeyOptions {
|
|
652
656
|
/** EVM wallet private key (hex string starting with 0x) */
|
|
653
657
|
privateKey?: `0x${string}` | string;
|
|
654
658
|
/** API endpoint URL (default: https://blockrun.ai/api) */
|
|
@@ -691,7 +695,7 @@ interface RpcBatchRequest {
|
|
|
691
695
|
type VoicePreset = "nat" | "josh" | "maya" | "june" | "paige" | "derek" | "florian";
|
|
692
696
|
/** Bland.ai conversation model tier. */
|
|
693
697
|
type CallModel = "base" | "enhanced" | "turbo";
|
|
694
|
-
interface VoiceClientOptions {
|
|
698
|
+
interface VoiceClientOptions extends ApiKeyOptions {
|
|
695
699
|
/** EVM wallet private key (hex string starting with 0x) */
|
|
696
700
|
privateKey?: `0x${string}` | string;
|
|
697
701
|
/** API endpoint URL (default: https://blockrun.ai/api) */
|
|
@@ -785,7 +789,7 @@ interface VideoModel {
|
|
|
785
789
|
available: boolean;
|
|
786
790
|
type: "video";
|
|
787
791
|
}
|
|
788
|
-
interface VideoClientOptions {
|
|
792
|
+
interface VideoClientOptions extends ApiKeyOptions {
|
|
789
793
|
/** EVM wallet private key (hex string starting with 0x) */
|
|
790
794
|
privateKey?: `0x${string}` | string;
|
|
791
795
|
/** API endpoint URL (default: https://blockrun.ai/api) */
|
|
@@ -976,24 +980,24 @@ interface ListOptions extends PriceOptions {
|
|
|
976
980
|
/** Page size, capped at 2000. Defaults to 100. */
|
|
977
981
|
limit?: number;
|
|
978
982
|
}
|
|
979
|
-
interface SearchClientOptions {
|
|
983
|
+
interface SearchClientOptions extends ApiKeyOptions {
|
|
980
984
|
privateKey?: `0x${string}` | string;
|
|
981
985
|
apiUrl?: string;
|
|
982
986
|
timeout?: number;
|
|
983
987
|
}
|
|
984
|
-
interface PriceClientOptions {
|
|
988
|
+
interface PriceClientOptions extends ApiKeyOptions {
|
|
985
989
|
privateKey?: `0x${string}` | string;
|
|
986
990
|
apiUrl?: string;
|
|
987
991
|
timeout?: number;
|
|
988
992
|
/** If false, construction succeeds without a wallet (free endpoints only). */
|
|
989
993
|
requireWallet?: boolean;
|
|
990
994
|
}
|
|
991
|
-
interface SurfClientOptions {
|
|
995
|
+
interface SurfClientOptions extends ApiKeyOptions {
|
|
992
996
|
privateKey?: `0x${string}` | string;
|
|
993
997
|
apiUrl?: string;
|
|
994
998
|
timeout?: number;
|
|
995
999
|
}
|
|
996
|
-
interface PhoneClientOptions {
|
|
1000
|
+
interface PhoneClientOptions extends ApiKeyOptions {
|
|
997
1001
|
/** EVM wallet private key (hex string starting with 0x) */
|
|
998
1002
|
privateKey?: `0x${string}` | string;
|
|
999
1003
|
/** API endpoint URL (default: https://blockrun.ai/api) */
|
|
@@ -1062,7 +1066,7 @@ interface PhoneReleaseResponse {
|
|
|
1062
1066
|
phone_number: string;
|
|
1063
1067
|
txHash?: string;
|
|
1064
1068
|
}
|
|
1065
|
-
interface PortraitClientOptions {
|
|
1069
|
+
interface PortraitClientOptions extends ApiKeyOptions {
|
|
1066
1070
|
/** EVM wallet private key (hex string starting with 0x) */
|
|
1067
1071
|
privateKey?: `0x${string}` | string;
|
|
1068
1072
|
/** API endpoint URL (default: https://blockrun.ai/api) */
|
|
@@ -1119,7 +1123,7 @@ interface PortraitEnrollResponse {
|
|
|
1119
1123
|
/** On-chain payment receipt (tx hash), surfaced from the response header. */
|
|
1120
1124
|
txHash?: string;
|
|
1121
1125
|
}
|
|
1122
|
-
interface BlockrunClientOptions {
|
|
1126
|
+
interface BlockrunClientOptions extends ApiKeyOptions {
|
|
1123
1127
|
privateKey?: `0x${string}` | string;
|
|
1124
1128
|
apiUrl?: string;
|
|
1125
1129
|
/** Per-HTTP-call timeout in ms (default 60000). For long-running poll() jobs,
|
|
@@ -1150,26 +1154,12 @@ declare class PaymentError extends BlockrunError {
|
|
|
1150
1154
|
}
|
|
1151
1155
|
declare class APIError extends BlockrunError {
|
|
1152
1156
|
statusCode: number;
|
|
1157
|
+
/** Retry-After header returned by the account API. */
|
|
1158
|
+
retryAfter?: string;
|
|
1153
1159
|
response?: unknown;
|
|
1154
1160
|
constructor(message: string, statusCode: number, response?: unknown);
|
|
1155
1161
|
}
|
|
1156
1162
|
|
|
1157
|
-
/**
|
|
1158
|
-
* BlockRun LLM Client - Main SDK entry point.
|
|
1159
|
-
*
|
|
1160
|
-
* Usage:
|
|
1161
|
-
* import { LLMClient } from '@blockrun/llm';
|
|
1162
|
-
*
|
|
1163
|
-
* // Option 1: Use BASE_CHAIN_WALLET_KEY env var
|
|
1164
|
-
* const client = new LLMClient();
|
|
1165
|
-
*
|
|
1166
|
-
* // Option 2: Pass private key directly
|
|
1167
|
-
* const client = new LLMClient({ privateKey: '0x...' });
|
|
1168
|
-
*
|
|
1169
|
-
* const response = await client.chat('openai/gpt-5.2', 'Hello!');
|
|
1170
|
-
* console.log(response);
|
|
1171
|
-
*/
|
|
1172
|
-
|
|
1173
1163
|
/**
|
|
1174
1164
|
* BlockRun LLM Gateway Client.
|
|
1175
1165
|
*
|
|
@@ -1179,8 +1169,13 @@ declare class APIError extends BlockrunError {
|
|
|
1179
1169
|
*/
|
|
1180
1170
|
declare class LLMClient {
|
|
1181
1171
|
static readonly DEFAULT_API_URL = "https://blockrun.ai/api";
|
|
1182
|
-
private
|
|
1183
|
-
private
|
|
1172
|
+
private _account?;
|
|
1173
|
+
private get account();
|
|
1174
|
+
private apiAuth?;
|
|
1175
|
+
/** Active billing mode. */
|
|
1176
|
+
get authMode(): "api-key" | "wallet";
|
|
1177
|
+
private _privateKey?;
|
|
1178
|
+
private get privateKey();
|
|
1184
1179
|
private apiUrl;
|
|
1185
1180
|
private timeout;
|
|
1186
1181
|
private sessionTotalUsd;
|
|
@@ -1610,23 +1605,6 @@ declare class LLMClient {
|
|
|
1610
1605
|
getWalletAddress(): string;
|
|
1611
1606
|
}
|
|
1612
1607
|
|
|
1613
|
-
/**
|
|
1614
|
-
* BlockRun Image Client - Generate images via x402 micropayments.
|
|
1615
|
-
*
|
|
1616
|
-
* SECURITY NOTE - Private Key Handling:
|
|
1617
|
-
* Your private key NEVER leaves your machine. Here's what happens:
|
|
1618
|
-
* 1. Key stays local - only used to sign an EIP-712 typed data message
|
|
1619
|
-
* 2. Only the SIGNATURE is sent in the PAYMENT-SIGNATURE header
|
|
1620
|
-
* 3. BlockRun verifies the signature on-chain via Coinbase CDP facilitator
|
|
1621
|
-
*
|
|
1622
|
-
* Usage:
|
|
1623
|
-
* import { ImageClient } from '@blockrun/llm';
|
|
1624
|
-
*
|
|
1625
|
-
* const client = new ImageClient({ privateKey: '0x...' });
|
|
1626
|
-
* const result = await client.generate('A cute cat in space');
|
|
1627
|
-
* console.log(result.data[0].url);
|
|
1628
|
-
*/
|
|
1629
|
-
|
|
1630
1608
|
/**
|
|
1631
1609
|
* BlockRun Image Generation Client.
|
|
1632
1610
|
*
|
|
@@ -1634,8 +1612,13 @@ declare class LLMClient {
|
|
|
1634
1612
|
* or CogView-4 (Zhipu AI) with automatic x402 micropayments on Base chain.
|
|
1635
1613
|
*/
|
|
1636
1614
|
declare class ImageClient {
|
|
1637
|
-
private
|
|
1638
|
-
private
|
|
1615
|
+
private _account?;
|
|
1616
|
+
private get account();
|
|
1617
|
+
private apiAuth?;
|
|
1618
|
+
/** Active billing mode. */
|
|
1619
|
+
get authMode(): "api-key" | "wallet";
|
|
1620
|
+
private _privateKey?;
|
|
1621
|
+
private get privateKey();
|
|
1639
1622
|
private apiUrl;
|
|
1640
1623
|
private timeout;
|
|
1641
1624
|
private sessionTotalUsd;
|
|
@@ -1729,23 +1712,6 @@ declare class ImageClient {
|
|
|
1729
1712
|
getSpending(): Spending;
|
|
1730
1713
|
}
|
|
1731
1714
|
|
|
1732
|
-
/**
|
|
1733
|
-
* BlockRun Music Client - Generate music tracks via x402 micropayments.
|
|
1734
|
-
*
|
|
1735
|
-
* SECURITY NOTE - Private Key Handling:
|
|
1736
|
-
* Your private key NEVER leaves your machine. Here's what happens:
|
|
1737
|
-
* 1. Key stays local - only used to sign an EIP-712 typed data message
|
|
1738
|
-
* 2. Only the SIGNATURE is sent in the PAYMENT-SIGNATURE header
|
|
1739
|
-
* 3. BlockRun verifies the signature on-chain via Coinbase CDP facilitator
|
|
1740
|
-
*
|
|
1741
|
-
* Usage:
|
|
1742
|
-
* import { MusicClient } from '@blockrun/llm';
|
|
1743
|
-
*
|
|
1744
|
-
* const client = new MusicClient({ privateKey: '0x...' });
|
|
1745
|
-
* const result = await client.generate('upbeat synthwave with neon pads');
|
|
1746
|
-
* console.log(result.data[0].url); // CDN URL — download within 24h
|
|
1747
|
-
*/
|
|
1748
|
-
|
|
1749
1715
|
/**
|
|
1750
1716
|
* BlockRun Music Generation Client.
|
|
1751
1717
|
*
|
|
@@ -1756,8 +1722,13 @@ declare class ImageClient {
|
|
|
1756
1722
|
* Note: Generated URLs expire in ~24h — download immediately if needed.
|
|
1757
1723
|
*/
|
|
1758
1724
|
declare class MusicClient {
|
|
1759
|
-
private
|
|
1760
|
-
private
|
|
1725
|
+
private _account?;
|
|
1726
|
+
private get account();
|
|
1727
|
+
private apiAuth?;
|
|
1728
|
+
/** Active billing mode. */
|
|
1729
|
+
get authMode(): "api-key" | "wallet";
|
|
1730
|
+
private _privateKey?;
|
|
1731
|
+
private get privateKey();
|
|
1761
1732
|
private apiUrl;
|
|
1762
1733
|
private timeout;
|
|
1763
1734
|
private sessionTotalUsd;
|
|
@@ -1790,40 +1761,6 @@ declare class MusicClient {
|
|
|
1790
1761
|
getSpending(): Spending;
|
|
1791
1762
|
}
|
|
1792
1763
|
|
|
1793
|
-
/**
|
|
1794
|
-
* BlockRun Speech Client - Text-to-speech and sound effects (ElevenLabs) via x402 micropayments.
|
|
1795
|
-
*
|
|
1796
|
-
* SECURITY NOTE - Private Key Handling:
|
|
1797
|
-
* Your private key NEVER leaves your machine. Here's what happens:
|
|
1798
|
-
* 1. Key stays local - only used to sign an EIP-712 typed data message
|
|
1799
|
-
* 2. Only the SIGNATURE is sent in the PAYMENT-SIGNATURE header
|
|
1800
|
-
* 3. BlockRun verifies the signature on-chain via Coinbase CDP facilitator
|
|
1801
|
-
*
|
|
1802
|
-
* Usage:
|
|
1803
|
-
* import { SpeechClient } from '@blockrun/llm';
|
|
1804
|
-
*
|
|
1805
|
-
* const client = new SpeechClient({ privateKey: '0x...' });
|
|
1806
|
-
*
|
|
1807
|
-
* // Text-to-speech (price scales with character count)
|
|
1808
|
-
* const result = await client.generate('Hello from BlockRun!', { voice: 'sarah' });
|
|
1809
|
-
* console.log(result.data[0].url);
|
|
1810
|
-
*
|
|
1811
|
-
* // Sound effects (flat $0.05/generation)
|
|
1812
|
-
* const fx = await client.soundEffect('rain on a tin roof, distant thunder');
|
|
1813
|
-
*
|
|
1814
|
-
* // List voices (free, rate-limited)
|
|
1815
|
-
* const voices = await client.listVoices();
|
|
1816
|
-
*
|
|
1817
|
-
* Models & pricing:
|
|
1818
|
-
* elevenlabs/flash-v2.5 $0.05/1k chars ~75ms latency, 32 languages (default)
|
|
1819
|
-
* elevenlabs/turbo-v2.5 $0.05/1k chars ~250ms latency, 32 languages
|
|
1820
|
-
* elevenlabs/multilingual-v2 $0.10/1k chars long-form narration, 29 languages
|
|
1821
|
-
* elevenlabs/v3 $0.10/1k chars max expressiveness, 70+ languages
|
|
1822
|
-
* elevenlabs/sound-effects $0.05/generation (up to 22s)
|
|
1823
|
-
*
|
|
1824
|
-
* Price = (characters / 1000) x model rate, minimum $0.001/request.
|
|
1825
|
-
*/
|
|
1826
|
-
|
|
1827
1764
|
/**
|
|
1828
1765
|
* BlockRun Speech Client (BlockRun Voice).
|
|
1829
1766
|
*
|
|
@@ -1834,8 +1771,13 @@ declare class MusicClient {
|
|
|
1834
1771
|
* $0.05/generation.
|
|
1835
1772
|
*/
|
|
1836
1773
|
declare class SpeechClient {
|
|
1837
|
-
private
|
|
1838
|
-
private
|
|
1774
|
+
private _account?;
|
|
1775
|
+
private get account();
|
|
1776
|
+
private apiAuth?;
|
|
1777
|
+
/** Active billing mode. */
|
|
1778
|
+
get authMode(): "api-key" | "wallet";
|
|
1779
|
+
private _privateKey?;
|
|
1780
|
+
private get privateKey();
|
|
1839
1781
|
private apiUrl;
|
|
1840
1782
|
private timeout;
|
|
1841
1783
|
private sessionTotalUsd;
|
|
@@ -1888,33 +1830,6 @@ declare class SpeechClient {
|
|
|
1888
1830
|
getSpending(): Spending;
|
|
1889
1831
|
}
|
|
1890
1832
|
|
|
1891
|
-
/**
|
|
1892
|
-
* BlockRun Video Client - Generate short AI videos via x402 micropayments.
|
|
1893
|
-
*
|
|
1894
|
-
* SECURITY NOTE - Private Key Handling:
|
|
1895
|
-
* Your private key NEVER leaves your machine. Here's what happens:
|
|
1896
|
-
* 1. Key stays local - only used to sign an EIP-712 typed data message
|
|
1897
|
-
* 2. Only the SIGNATURE is sent in the PAYMENT-SIGNATURE header
|
|
1898
|
-
* 3. BlockRun verifies the signature on-chain via Coinbase CDP facilitator
|
|
1899
|
-
*
|
|
1900
|
-
* Async flow (client-polled):
|
|
1901
|
-
* POST /v1/videos/generations -> 402 -> sign -> 202 { id, poll_url }
|
|
1902
|
-
* GET /v1/videos/generations/{id} -> loop until status=completed
|
|
1903
|
-
*
|
|
1904
|
-
* The client signs once and replays the same PAYMENT-SIGNATURE on every poll,
|
|
1905
|
-
* re-signing automatically if the 600s authorization window lapses mid-poll.
|
|
1906
|
-
* Settlement happens only on the first completed poll, so upstream failure or
|
|
1907
|
-
* the caller giving up = zero charge.
|
|
1908
|
-
*
|
|
1909
|
-
* Usage:
|
|
1910
|
-
* import { VideoClient } from '@blockrun/llm';
|
|
1911
|
-
*
|
|
1912
|
-
* const client = new VideoClient({ privateKey: '0x...' });
|
|
1913
|
-
* const result = await client.generate('a red apple slowly spinning on a wooden table');
|
|
1914
|
-
* console.log(result.data[0].url); // permanent MP4 URL
|
|
1915
|
-
* console.log(result.data[0].duration_seconds);
|
|
1916
|
-
*/
|
|
1917
|
-
|
|
1918
1833
|
/**
|
|
1919
1834
|
* BlockRun Video Generation Client.
|
|
1920
1835
|
*
|
|
@@ -1922,8 +1837,13 @@ declare class SpeechClient {
|
|
|
1922
1837
|
* 2.0 Fast / 2.0 Pro) with automatic x402 micropayments on Base.
|
|
1923
1838
|
*/
|
|
1924
1839
|
declare class VideoClient {
|
|
1925
|
-
private
|
|
1926
|
-
private
|
|
1840
|
+
private _account?;
|
|
1841
|
+
private get account();
|
|
1842
|
+
private apiAuth?;
|
|
1843
|
+
/** Active billing mode. */
|
|
1844
|
+
get authMode(): "api-key" | "wallet";
|
|
1845
|
+
private _privateKey?;
|
|
1846
|
+
private get privateKey();
|
|
1927
1847
|
private apiUrl;
|
|
1928
1848
|
private timeout;
|
|
1929
1849
|
private sessionTotalUsd;
|
|
@@ -1993,37 +1913,6 @@ declare class VideoClient {
|
|
|
1993
1913
|
getSpending(): Spending;
|
|
1994
1914
|
}
|
|
1995
1915
|
|
|
1996
|
-
/**
|
|
1997
|
-
* BlockRun Voice Call Client - AI-powered outbound phone calls via x402 micropayments.
|
|
1998
|
-
*
|
|
1999
|
-
* The AI agent calls a phone number (E.164) and conducts a real-time conversation
|
|
2000
|
-
* based on your 'task' instructions. STT, LLM, and TTS are handled upstream by
|
|
2001
|
-
* Bland.ai; BlockRun handles billing through x402.
|
|
2002
|
-
*
|
|
2003
|
-
* SECURITY NOTE - Private Key Handling:
|
|
2004
|
-
* Your private key NEVER leaves your machine. Here's what happens:
|
|
2005
|
-
* 1. Key stays local - only used to sign an EIP-712 typed data message
|
|
2006
|
-
* 2. Only the SIGNATURE is sent in the PAYMENT-SIGNATURE header
|
|
2007
|
-
* 3. BlockRun verifies the signature on-chain via Coinbase CDP facilitator
|
|
2008
|
-
*
|
|
2009
|
-
* Usage:
|
|
2010
|
-
* import { VoiceClient } from '@blockrun/llm';
|
|
2011
|
-
*
|
|
2012
|
-
* const client = new VoiceClient({ privateKey: '0x...' });
|
|
2013
|
-
*
|
|
2014
|
-
* // Initiate a call (paid, $0.54)
|
|
2015
|
-
* const result = await client.call({
|
|
2016
|
-
* to: '+14155552671',
|
|
2017
|
-
* task: 'You are a friendly assistant calling to confirm a 3pm dentist appointment.',
|
|
2018
|
-
* max_duration: 5,
|
|
2019
|
-
* });
|
|
2020
|
-
* console.log(result.call_id);
|
|
2021
|
-
*
|
|
2022
|
-
* // Poll status, transcript, recording (free)
|
|
2023
|
-
* const status = await client.getStatus(result.call_id);
|
|
2024
|
-
* console.log(status);
|
|
2025
|
-
*/
|
|
2026
|
-
|
|
2027
1916
|
/**
|
|
2028
1917
|
* BlockRun Voice Call Client.
|
|
2029
1918
|
*
|
|
@@ -2034,8 +1923,13 @@ declare class VideoClient {
|
|
|
2034
1923
|
* Status polling is free.
|
|
2035
1924
|
*/
|
|
2036
1925
|
declare class VoiceClient {
|
|
2037
|
-
private
|
|
2038
|
-
private
|
|
1926
|
+
private _account?;
|
|
1927
|
+
private get account();
|
|
1928
|
+
private apiAuth?;
|
|
1929
|
+
/** Active billing mode. */
|
|
1930
|
+
get authMode(): "api-key" | "wallet";
|
|
1931
|
+
private _privateKey?;
|
|
1932
|
+
private get privateKey();
|
|
2039
1933
|
private apiUrl;
|
|
2040
1934
|
private timeout;
|
|
2041
1935
|
private sessionTotalUsd;
|
|
@@ -2070,43 +1964,6 @@ declare class VoiceClient {
|
|
|
2070
1964
|
getSpending(): Spending;
|
|
2071
1965
|
}
|
|
2072
1966
|
|
|
2073
|
-
/**
|
|
2074
|
-
* BlockRun Phone Client — Twilio-backed phone lookup + number provisioning via x402.
|
|
2075
|
-
*
|
|
2076
|
-
* Endpoints (all under /v1/phone/...):
|
|
2077
|
-
* POST /lookup $0.01 Carrier + line-type lookup
|
|
2078
|
-
* POST /lookup/fraud $0.05 Carrier + SIM-swap / call-forwarding signals
|
|
2079
|
-
* POST /numbers/buy $5.00 Provision a US/CA number (30-day lease, bound to wallet)
|
|
2080
|
-
* POST /numbers/renew $5.00 Extend an existing number by 30 days
|
|
2081
|
-
* POST /numbers/list $0.001 List the wallet's active numbers
|
|
2082
|
-
* POST /numbers/release free Release a provisioned number (still flows through x402
|
|
2083
|
-
* so the backend can verify wallet identity)
|
|
2084
|
-
*
|
|
2085
|
-
* After buying a number you can use it as the `from` caller ID in VoiceClient.call().
|
|
2086
|
-
*
|
|
2087
|
-
* SECURITY NOTE — your private key never leaves your machine. Only EIP-712
|
|
2088
|
-
* signatures are sent in the PAYMENT-SIGNATURE header.
|
|
2089
|
-
*
|
|
2090
|
-
* @example
|
|
2091
|
-
* import { PhoneClient } from '@blockrun/llm';
|
|
2092
|
-
*
|
|
2093
|
-
* const client = new PhoneClient({ privateKey: '0x...' });
|
|
2094
|
-
*
|
|
2095
|
-
* // Lookup a number
|
|
2096
|
-
* const info = await client.lookup('+14155552671');
|
|
2097
|
-
*
|
|
2098
|
-
* // Buy a number (US, optional area code)
|
|
2099
|
-
* const bought = await client.buyNumber({ country: 'US', areaCode: '415' });
|
|
2100
|
-
* console.log(bought.phone_number, bought.expires_at);
|
|
2101
|
-
*
|
|
2102
|
-
* // List your active numbers
|
|
2103
|
-
* console.log(await client.listNumbers());
|
|
2104
|
-
*
|
|
2105
|
-
* // Renew / release
|
|
2106
|
-
* await client.renewNumber(bought.phone_number);
|
|
2107
|
-
* await client.releaseNumber(bought.phone_number);
|
|
2108
|
-
*/
|
|
2109
|
-
|
|
2110
1967
|
/** Per-endpoint price in USD — mirrors the backend's `PHONE_PRICES`. */
|
|
2111
1968
|
declare const PHONE_PRICES: Readonly<Record<string, number>>;
|
|
2112
1969
|
/**
|
|
@@ -2116,8 +1973,13 @@ declare const PHONE_PRICES: Readonly<Record<string, number>>;
|
|
|
2116
1973
|
* and provisioning of the caller-ID numbers required by VoiceClient.call().
|
|
2117
1974
|
*/
|
|
2118
1975
|
declare class PhoneClient {
|
|
2119
|
-
private
|
|
2120
|
-
private
|
|
1976
|
+
private _account?;
|
|
1977
|
+
private get account();
|
|
1978
|
+
private apiAuth?;
|
|
1979
|
+
/** Active billing mode. */
|
|
1980
|
+
get authMode(): "api-key" | "wallet";
|
|
1981
|
+
private _privateKey?;
|
|
1982
|
+
private get privateKey();
|
|
2121
1983
|
private apiUrl;
|
|
2122
1984
|
private timeout;
|
|
2123
1985
|
private sessionTotalUsd;
|
|
@@ -2170,33 +2032,6 @@ declare class PhoneClient {
|
|
|
2170
2032
|
private fetchWithTimeout;
|
|
2171
2033
|
}
|
|
2172
2034
|
|
|
2173
|
-
/**
|
|
2174
|
-
* BlockRun Portrait Client — enroll a Virtual Portrait via x402.
|
|
2175
|
-
*
|
|
2176
|
-
* Wraps `POST /v1/portrait/enroll` ($0.01 USDC promo, no KYC). You upload a face image
|
|
2177
|
-
* by URL and get back a Token360 asset id (`ta_xxxxxx`). Pass that id as
|
|
2178
|
-
* `realFaceAssetId` on a Seedance 2.0 video generation (VideoClient.generate)
|
|
2179
|
-
* to keep the same AI character across clips.
|
|
2180
|
-
*
|
|
2181
|
-
* SECURITY NOTE — your private key never leaves your machine. Only EIP-712
|
|
2182
|
-
* signatures are sent in the PAYMENT-SIGNATURE header.
|
|
2183
|
-
*
|
|
2184
|
-
* @example
|
|
2185
|
-
* import { PortraitClient, VideoClient } from '@blockrun/llm';
|
|
2186
|
-
*
|
|
2187
|
-
* const portraits = new PortraitClient({ privateKey: '0x...' });
|
|
2188
|
-
* const { asset_id } = await portraits.enroll({
|
|
2189
|
-
* name: 'Spokesperson',
|
|
2190
|
-
* imageUrl: 'https://example.com/face.jpg',
|
|
2191
|
-
* });
|
|
2192
|
-
*
|
|
2193
|
-
* const video = new VideoClient({ privateKey: '0x...' });
|
|
2194
|
-
* const clip = await video.generate('she waves and smiles', {
|
|
2195
|
-
* model: 'bytedance/seedance-2.0-fast',
|
|
2196
|
-
* realFaceAssetId: asset_id,
|
|
2197
|
-
* });
|
|
2198
|
-
*/
|
|
2199
|
-
|
|
2200
2035
|
/**
|
|
2201
2036
|
* Flat enrollment price in USD — mirrors the backend's `ENROLLMENT_PRICE_USD`.
|
|
2202
2037
|
* Currently $0.01 (promotional, parity with RealFace). The authoritative price
|
|
@@ -2211,8 +2046,13 @@ declare const PORTRAIT_ENROLLMENT_PRICE_USD = 0.01;
|
|
|
2211
2046
|
* not supported on BlockRun — enrolled portraits are AI characters.
|
|
2212
2047
|
*/
|
|
2213
2048
|
declare class PortraitClient {
|
|
2214
|
-
private
|
|
2215
|
-
private
|
|
2049
|
+
private _account?;
|
|
2050
|
+
private get account();
|
|
2051
|
+
private apiAuth?;
|
|
2052
|
+
/** Active billing mode. */
|
|
2053
|
+
get authMode(): "api-key" | "wallet";
|
|
2054
|
+
private _privateKey?;
|
|
2055
|
+
private get privateKey();
|
|
2216
2056
|
private apiUrl;
|
|
2217
2057
|
private timeout;
|
|
2218
2058
|
private sessionTotalUsd;
|
|
@@ -2239,25 +2079,14 @@ declare class PortraitClient {
|
|
|
2239
2079
|
private fetchWithTimeout;
|
|
2240
2080
|
}
|
|
2241
2081
|
|
|
2242
|
-
/**
|
|
2243
|
-
* BlockRun Search Client - Standalone Grok Live Search via x402 micropayments.
|
|
2244
|
-
*
|
|
2245
|
-
* Backend endpoint: POST /api/v1/search
|
|
2246
|
-
* Pricing: $0.025/source + margin (default 10 sources ≈ $0.26).
|
|
2247
|
-
*
|
|
2248
|
-
* Usage:
|
|
2249
|
-
* import { SearchClient } from "@blockrun/llm";
|
|
2250
|
-
*
|
|
2251
|
-
* const client = new SearchClient({ privateKey: "0x..." });
|
|
2252
|
-
* const result = await client.search("Latest news on x402 adoption", {
|
|
2253
|
-
* sources: ["x", "web"],
|
|
2254
|
-
* });
|
|
2255
|
-
* console.log(result.summary);
|
|
2256
|
-
*/
|
|
2257
|
-
|
|
2258
2082
|
declare class SearchClient {
|
|
2259
|
-
private
|
|
2260
|
-
private
|
|
2083
|
+
private _account?;
|
|
2084
|
+
private get account();
|
|
2085
|
+
private apiAuth?;
|
|
2086
|
+
/** Active billing mode. */
|
|
2087
|
+
get authMode(): "api-key" | "wallet";
|
|
2088
|
+
private _privateKey?;
|
|
2089
|
+
private get privateKey();
|
|
2261
2090
|
private apiUrl;
|
|
2262
2091
|
private timeout;
|
|
2263
2092
|
constructor(options?: SearchClientOptions);
|
|
@@ -2268,25 +2097,9 @@ declare class SearchClient {
|
|
|
2268
2097
|
getWalletAddress(): string;
|
|
2269
2098
|
}
|
|
2270
2099
|
|
|
2271
|
-
/**
|
|
2272
|
-
* BlockRun Price Client - Pyth-backed market data via x402.
|
|
2273
|
-
*
|
|
2274
|
-
* Payment gating mirrors CategoryConfig.paid in the backend:
|
|
2275
|
-
* crypto, fx, commodity → FREE across price + history + list
|
|
2276
|
-
* usstock, stocks/{market} → PAID for price + history; list always free
|
|
2277
|
-
*
|
|
2278
|
-
* Usage:
|
|
2279
|
-
* import { PriceClient } from "@blockrun/llm";
|
|
2280
|
-
*
|
|
2281
|
-
* const p = new PriceClient({ privateKey: "0x..." });
|
|
2282
|
-
* const btc = await p.price("crypto", "BTC-USD");
|
|
2283
|
-
* const aapl = await p.price("stocks", "AAPL", { market: "us" });
|
|
2284
|
-
* const bars = await p.history("stocks", "AAPL", { market: "us",
|
|
2285
|
-
* from: 1700000000, to: 1710000000 });
|
|
2286
|
-
* const symbols = await p.listSymbols("crypto", { query: "sol" });
|
|
2287
|
-
*/
|
|
2288
|
-
|
|
2289
2100
|
declare class PriceClient {
|
|
2101
|
+
private apiAuth?;
|
|
2102
|
+
get authMode(): "api-key" | "wallet";
|
|
2290
2103
|
private account;
|
|
2291
2104
|
private privateKey;
|
|
2292
2105
|
private apiUrl;
|
|
@@ -2301,53 +2114,16 @@ declare class PriceClient {
|
|
|
2301
2114
|
private fetchWithTimeout;
|
|
2302
2115
|
}
|
|
2303
2116
|
|
|
2304
|
-
/**
|
|
2305
|
-
* BlockRun Surf Client — pay-per-call crypto data via x402 micropayments.
|
|
2306
|
-
*
|
|
2307
|
-
* Surf aggregates 84+ endpoints across CEX/DEX market data, on-chain SQL,
|
|
2308
|
-
* wallet intelligence, prediction markets, social analytics, and news under
|
|
2309
|
-
* a single OpenAPI surface mounted at `/api/v1/surf/*`.
|
|
2310
|
-
*
|
|
2311
|
-
* Pricing tiers (flat per-call, USDC on Base):
|
|
2312
|
-
* Tier 1 — $0.001/call (prices, rankings, lists, news, simple reads)
|
|
2313
|
-
* Tier 2 — $0.005/call (order books, candles, search, wallet details)
|
|
2314
|
-
* Tier 3 — $0.020/call (on-chain SQL, schema introspection, chat)
|
|
2315
|
-
*
|
|
2316
|
-
* Because the catalog is large and evolving, this client deliberately
|
|
2317
|
-
* exposes a thin `get` / `post` pair instead of 84 typed wrappers. Pass the
|
|
2318
|
-
* path (with or without the `/v1/surf` prefix) and either query params or a
|
|
2319
|
-
* JSON body. The full endpoint inventory lives at
|
|
2320
|
-
* https://blockrun.ai/marketplace/surf.
|
|
2321
|
-
*
|
|
2322
|
-
* Usage:
|
|
2323
|
-
* import { SurfClient } from "@blockrun/llm";
|
|
2324
|
-
*
|
|
2325
|
-
* const surf = new SurfClient({ privateKey: "0x..." });
|
|
2326
|
-
*
|
|
2327
|
-
* // Tier 1 — token price ($0.001)
|
|
2328
|
-
* const btc = await surf.get("/market/price", { symbol: "BTC" });
|
|
2329
|
-
*
|
|
2330
|
-
* // Tier 2 — order book ($0.005)
|
|
2331
|
-
* const book = await surf.get("/exchange/depth", {
|
|
2332
|
-
* exchange: "binance",
|
|
2333
|
-
* symbol: "BTC-USDT",
|
|
2334
|
-
* });
|
|
2335
|
-
*
|
|
2336
|
-
* // Tier 3 — raw on-chain SQL ($0.020)
|
|
2337
|
-
* const rows = await surf.post("/onchain/sql", {
|
|
2338
|
-
* query: "SELECT block_number FROM ethereum.blocks ORDER BY block_number DESC LIMIT 5",
|
|
2339
|
-
* });
|
|
2340
|
-
*
|
|
2341
|
-
* // Typed responses via generic
|
|
2342
|
-
* type Price = { symbol: string; price: number; timestamp: string };
|
|
2343
|
-
* const typed = await surf.get<Price>("/market/price", { symbol: "ETH" });
|
|
2344
|
-
*/
|
|
2345
|
-
|
|
2346
2117
|
type QueryValue$1 = string | number | boolean | null | undefined;
|
|
2347
2118
|
type QueryParams$1 = Record<string, QueryValue$1 | QueryValue$1[]>;
|
|
2348
2119
|
declare class SurfClient {
|
|
2349
|
-
private
|
|
2350
|
-
private
|
|
2120
|
+
private _account?;
|
|
2121
|
+
private get account();
|
|
2122
|
+
private apiAuth?;
|
|
2123
|
+
/** Active billing mode. */
|
|
2124
|
+
get authMode(): "api-key" | "wallet";
|
|
2125
|
+
private _privateKey?;
|
|
2126
|
+
private get privateKey();
|
|
2351
2127
|
private apiUrl;
|
|
2352
2128
|
private timeout;
|
|
2353
2129
|
constructor(options?: SurfClientOptions);
|
|
@@ -2369,52 +2145,6 @@ declare class SurfClient {
|
|
|
2369
2145
|
getWalletAddress(): string;
|
|
2370
2146
|
}
|
|
2371
2147
|
|
|
2372
|
-
/**
|
|
2373
|
-
* BlockRun RPC Client - Multi-chain JSON-RPC (Tatum gateway) via x402 micropayments.
|
|
2374
|
-
*
|
|
2375
|
-
* One endpoint, 40+ chains: Ethereum, Base, Solana, Polygon, BSC, Arbitrum,
|
|
2376
|
-
* Optimism, Avalanche, Bitcoin, Sui, and more. Standard JSON-RPC 2.0
|
|
2377
|
-
* passthrough — no API key, pay-per-call in USDC.
|
|
2378
|
-
*
|
|
2379
|
-
* SECURITY NOTE - Private Key Handling:
|
|
2380
|
-
* Your private key NEVER leaves your machine. Here's what happens:
|
|
2381
|
-
* 1. Key stays local - only used to sign an EIP-712 typed data message
|
|
2382
|
-
* 2. Only the SIGNATURE is sent in the PAYMENT-SIGNATURE header
|
|
2383
|
-
* 3. BlockRun verifies the signature on-chain via Coinbase CDP facilitator
|
|
2384
|
-
*
|
|
2385
|
-
* Usage:
|
|
2386
|
-
* import { RpcClient } from '@blockrun/llm';
|
|
2387
|
-
*
|
|
2388
|
-
* const client = new RpcClient({ privateKey: '0x...' });
|
|
2389
|
-
*
|
|
2390
|
-
* // EVM chains speak eth_* JSON-RPC
|
|
2391
|
-
* const block = await client.call('ethereum', 'eth_blockNumber');
|
|
2392
|
-
* console.log(block.result); // e.g. "0x1499f7c"
|
|
2393
|
-
*
|
|
2394
|
-
* const balance = await client.call('base', 'eth_getBalance', [
|
|
2395
|
-
* '0x4200000000000000000000000000000000000006',
|
|
2396
|
-
* 'latest',
|
|
2397
|
-
* ]);
|
|
2398
|
-
*
|
|
2399
|
-
* // Non-EVM chains speak their native JSON-RPC
|
|
2400
|
-
* const slot = await client.call('solana', 'getSlot');
|
|
2401
|
-
*
|
|
2402
|
-
* // Batch: one payment, per-element pricing ($0.002 x N)
|
|
2403
|
-
* const out = await client.batch('polygon', [
|
|
2404
|
-
* { method: 'eth_blockNumber' },
|
|
2405
|
-
* { method: 'eth_gasPrice' },
|
|
2406
|
-
* ]);
|
|
2407
|
-
*
|
|
2408
|
-
* Pricing:
|
|
2409
|
-
* Flat $0.002 per JSON-RPC call; a batch charges per element.
|
|
2410
|
-
*
|
|
2411
|
-
* Networks:
|
|
2412
|
-
* 40 curated chains (see SUPPORTED_NETWORKS) plus common aliases
|
|
2413
|
-
* (eth, arb, op, matic, bnb, avax, sol, btc, xrp, dot, ...). Unknown but
|
|
2414
|
-
* well-formed slugs fall through to a generic `{slug}-mainnet` gateway
|
|
2415
|
-
* attempt, so new Tatum chains work without an SDK update.
|
|
2416
|
-
*/
|
|
2417
|
-
|
|
2418
2148
|
/**
|
|
2419
2149
|
* Flat price per JSON-RPC call (batch = N x this). Informational only —
|
|
2420
2150
|
* the actual quote always comes from the 402 challenge.
|
|
@@ -2439,8 +2169,13 @@ declare const NETWORK_ALIASES: Record<string, string>;
|
|
|
2439
2169
|
* Flat $0.002 per call; a JSON-RPC batch charges per element.
|
|
2440
2170
|
*/
|
|
2441
2171
|
declare class RpcClient {
|
|
2442
|
-
private
|
|
2443
|
-
private
|
|
2172
|
+
private _account?;
|
|
2173
|
+
private get account();
|
|
2174
|
+
private apiAuth?;
|
|
2175
|
+
/** Active billing mode. */
|
|
2176
|
+
get authMode(): "api-key" | "wallet";
|
|
2177
|
+
private _privateKey?;
|
|
2178
|
+
private get privateKey();
|
|
2444
2179
|
private apiUrl;
|
|
2445
2180
|
private timeout;
|
|
2446
2181
|
private sessionTotalUsd;
|
|
@@ -2488,55 +2223,6 @@ declare class RpcClient {
|
|
|
2488
2223
|
getSpending(): Spending;
|
|
2489
2224
|
}
|
|
2490
2225
|
|
|
2491
|
-
/**
|
|
2492
|
-
* BlockrunClient — the x402-paying HTTP primitive for the BlockRun gateway.
|
|
2493
|
-
*
|
|
2494
|
-
* This is the **primitive** that every BlockRun API surface composes on top of:
|
|
2495
|
-
* a wallet, an x402 401-sign-replay handler, and four call shapes (get, post,
|
|
2496
|
-
* poll, stream). Per-API classes (LLMClient, ImageClient, SurfClient, …) are
|
|
2497
|
-
* being collapsed into Claude Code skills that drive this client directly.
|
|
2498
|
-
*
|
|
2499
|
-
* Why one primitive instead of one client per API surface:
|
|
2500
|
-
* - Every BlockRun endpoint pays the same way (USDC via x402 on Base/Solana)
|
|
2501
|
-
* - ~30-40 % of each existing client class is identical boilerplate
|
|
2502
|
-
* - New API surfaces should ship as a skill (markdown) + path, not as a
|
|
2503
|
-
* new TypeScript class + npm release
|
|
2504
|
-
*
|
|
2505
|
-
* Four call shapes:
|
|
2506
|
-
* client.get<T>(path, params?) — sync GET, e.g. /v1/surf/market/price
|
|
2507
|
-
* client.post<T>(path, body?) — sync POST, e.g. /v1/surf/onchain/sql
|
|
2508
|
-
* client.poll<T>(path, body?, { budgetMs }) — submit + poll, e.g. /v1/videos/generations
|
|
2509
|
-
* client.stream<T>(path, body?) — SSE iterator, e.g. /v1/chat/completions
|
|
2510
|
-
*
|
|
2511
|
-
* Usage:
|
|
2512
|
-
* import { BlockrunClient } from "@blockrun/llm";
|
|
2513
|
-
*
|
|
2514
|
-
* const br = new BlockrunClient({ privateKey: "0x..." });
|
|
2515
|
-
*
|
|
2516
|
-
* // Surf endpoint (Tier 1, $0.001)
|
|
2517
|
-
* const btc = await br.get("/v1/surf/market/price", { symbol: "BTC" });
|
|
2518
|
-
*
|
|
2519
|
-
* // Raw on-chain SQL (Tier 3, $0.020)
|
|
2520
|
-
* const rows = await br.post("/v1/surf/onchain/sql", {
|
|
2521
|
-
* query: "SELECT block_number FROM ethereum.blocks ORDER BY block_number DESC LIMIT 1",
|
|
2522
|
-
* });
|
|
2523
|
-
*
|
|
2524
|
-
* // Long-running video generation (submit + poll, paid on success)
|
|
2525
|
-
* const video = await br.poll("/v1/videos/generations", {
|
|
2526
|
-
* model: "xai/grok-imagine-video",
|
|
2527
|
-
* prompt: "a red apple spinning",
|
|
2528
|
-
* });
|
|
2529
|
-
*
|
|
2530
|
-
* // Streaming chat
|
|
2531
|
-
* for await (const chunk of br.stream("/v1/chat/completions", {
|
|
2532
|
-
* model: "anthropic/claude-sonnet-4-6",
|
|
2533
|
-
* messages: [{ role: "user", content: "Hi" }],
|
|
2534
|
-
* stream: true,
|
|
2535
|
-
* })) {
|
|
2536
|
-
* process.stdout.write(chunk.choices?.[0]?.delta?.content ?? "");
|
|
2537
|
-
* }
|
|
2538
|
-
*/
|
|
2539
|
-
|
|
2540
2226
|
type QueryValue = string | number | boolean | null | undefined;
|
|
2541
2227
|
type QueryParams = Record<string, QueryValue | QueryValue[]>;
|
|
2542
2228
|
/**
|
|
@@ -2546,8 +2232,13 @@ type QueryParams = Record<string, QueryValue | QueryValue[]>;
|
|
|
2546
2232
|
* poll, stream) cover every endpoint type the gateway exposes.
|
|
2547
2233
|
*/
|
|
2548
2234
|
declare class BlockrunClient {
|
|
2549
|
-
private
|
|
2550
|
-
private
|
|
2235
|
+
private _account?;
|
|
2236
|
+
private get account();
|
|
2237
|
+
private apiAuth?;
|
|
2238
|
+
/** Active billing mode. */
|
|
2239
|
+
get authMode(): "api-key" | "wallet";
|
|
2240
|
+
private _privateKey?;
|
|
2241
|
+
private get privateKey();
|
|
2551
2242
|
private apiUrl;
|
|
2552
2243
|
private timeout;
|
|
2553
2244
|
private sessionTotalUsd;
|
|
@@ -2914,22 +2605,7 @@ declare function formatFundingMessageCompact(address: string): string;
|
|
|
2914
2605
|
declare const WALLET_FILE_PATH: string;
|
|
2915
2606
|
declare const WALLET_DIR_PATH: string;
|
|
2916
2607
|
|
|
2917
|
-
|
|
2918
|
-
* BlockRun Solana LLM Client.
|
|
2919
|
-
*
|
|
2920
|
-
* Usage:
|
|
2921
|
-
* import { SolanaLLMClient } from '@blockrun/llm';
|
|
2922
|
-
*
|
|
2923
|
-
* // SOLANA_WALLET_KEY env var (bs58-encoded Solana secret key)
|
|
2924
|
-
* const client = new SolanaLLMClient();
|
|
2925
|
-
*
|
|
2926
|
-
* // Or pass key directly
|
|
2927
|
-
* const client = new SolanaLLMClient({ privateKey: 'your-bs58-key' });
|
|
2928
|
-
*
|
|
2929
|
-
* const response = await client.chat('openai/gpt-5.2', 'gm Solana');
|
|
2930
|
-
*/
|
|
2931
|
-
|
|
2932
|
-
interface SolanaLLMClientOptions {
|
|
2608
|
+
interface SolanaLLMClientOptions extends ApiKeyOptions {
|
|
2933
2609
|
/** bs58-encoded Solana secret key (64 bytes). Optional if SOLANA_WALLET_KEY env var is set. */
|
|
2934
2610
|
privateKey?: string;
|
|
2935
2611
|
/** API endpoint URL (default: https://sol.blockrun.ai/api) */
|
|
@@ -2954,7 +2630,10 @@ interface SolanaLLMClientOptions {
|
|
|
2954
2630
|
}
|
|
2955
2631
|
declare class SolanaLLMClient {
|
|
2956
2632
|
static readonly SOLANA_API_URL = "https://sol.blockrun.ai/api";
|
|
2957
|
-
private
|
|
2633
|
+
private apiAuth?;
|
|
2634
|
+
get authMode(): "api-key" | "wallet";
|
|
2635
|
+
private _privateKey?;
|
|
2636
|
+
private get privateKey();
|
|
2958
2637
|
private apiUrl;
|
|
2959
2638
|
private rpcUrl;
|
|
2960
2639
|
private rpcHeaders?;
|
|
@@ -3204,13 +2883,6 @@ declare function getCostLogSummary(): {
|
|
|
3204
2883
|
byEndpoint: Record<string, number>;
|
|
3205
2884
|
};
|
|
3206
2885
|
|
|
3207
|
-
/**
|
|
3208
|
-
* Agent wallet setup utilities.
|
|
3209
|
-
*
|
|
3210
|
-
* Convenience functions for agent runtimes (Claude Code skills, etc.)
|
|
3211
|
-
* that auto-create wallets and return configured clients.
|
|
3212
|
-
*/
|
|
3213
|
-
|
|
3214
2886
|
declare function setupAgentWallet(options?: {
|
|
3215
2887
|
silent?: boolean;
|
|
3216
2888
|
}): LLMClient;
|
|
@@ -3221,6 +2893,14 @@ declare function status(): Promise<{
|
|
|
3221
2893
|
address: string;
|
|
3222
2894
|
balance: number;
|
|
3223
2895
|
}>;
|
|
2896
|
+
/** Account API when configured; otherwise Solana for new wallets.
|
|
2897
|
+
* Existing chain preferences and Base-only wallets remain on their chosen chain.
|
|
2898
|
+
* The named setupAgentWallet/setupAgentSolanaWallet helpers retain their behavior.
|
|
2899
|
+
*/
|
|
2900
|
+
declare function setupAgentClient(options?: ApiKeyOptions & {
|
|
2901
|
+
chain?: 'solana' | 'base';
|
|
2902
|
+
silent?: boolean;
|
|
2903
|
+
}): Promise<LLMClient | SolanaLLMClient>;
|
|
3224
2904
|
|
|
3225
2905
|
/** Canonical on-wire schema for cost_log.jsonl entries. */
|
|
3226
2906
|
interface CostEntry {
|
|
@@ -3247,29 +2927,8 @@ declare function getCostSummary(): {
|
|
|
3247
2927
|
byEndpoint: Record<string, number>;
|
|
3248
2928
|
};
|
|
3249
2929
|
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
*
|
|
3253
|
-
* Drop-in replacement for OpenAI SDK - just change the import and use walletKey instead of apiKey.
|
|
3254
|
-
*
|
|
3255
|
-
* @example
|
|
3256
|
-
* // Before (OpenAI)
|
|
3257
|
-
* import OpenAI from 'openai';
|
|
3258
|
-
* const client = new OpenAI({ apiKey: 'sk-...' });
|
|
3259
|
-
*
|
|
3260
|
-
* // After (BlockRun)
|
|
3261
|
-
* import { OpenAI } from '@blockrun/llm';
|
|
3262
|
-
* const client = new OpenAI({ walletKey: '0x...' });
|
|
3263
|
-
*
|
|
3264
|
-
* // Rest of your code stays exactly the same!
|
|
3265
|
-
* const response = await client.chat.completions.create({
|
|
3266
|
-
* model: 'gpt-5.2',
|
|
3267
|
-
* messages: [{ role: 'user', content: 'Hello!' }]
|
|
3268
|
-
* });
|
|
3269
|
-
*/
|
|
3270
|
-
|
|
3271
|
-
interface OpenAIClientOptions {
|
|
3272
|
-
/** EVM wallet private key (replaces apiKey) */
|
|
2930
|
+
interface OpenAIClientOptions extends ApiKeyOptions {
|
|
2931
|
+
/** EVM wallet private key for explicit wallet mode. */
|
|
3273
2932
|
walletKey?: `0x${string}` | string;
|
|
3274
2933
|
/** Alternative: use privateKey like LLMClient */
|
|
3275
2934
|
privateKey?: `0x${string}` | string;
|
|
@@ -3381,6 +3040,7 @@ declare class Chat {
|
|
|
3381
3040
|
*/
|
|
3382
3041
|
declare class OpenAI {
|
|
3383
3042
|
chat: Chat;
|
|
3043
|
+
get authMode(): "api-key" | "wallet";
|
|
3384
3044
|
private client;
|
|
3385
3045
|
constructor(options?: OpenAIClientOptions);
|
|
3386
3046
|
/**
|
|
@@ -3389,7 +3049,7 @@ declare class OpenAI {
|
|
|
3389
3049
|
getWalletAddress(): string;
|
|
3390
3050
|
}
|
|
3391
3051
|
|
|
3392
|
-
interface BlockRunAnthropicOptions {
|
|
3052
|
+
interface BlockRunAnthropicOptions extends ApiKeyOptions {
|
|
3393
3053
|
privateKey?: `0x${string}` | string;
|
|
3394
3054
|
apiUrl?: string;
|
|
3395
3055
|
timeout?: number;
|
|
@@ -3397,8 +3057,12 @@ interface BlockRunAnthropicOptions {
|
|
|
3397
3057
|
declare class AnthropicClient {
|
|
3398
3058
|
private _client;
|
|
3399
3059
|
private _clientPromise;
|
|
3400
|
-
private
|
|
3401
|
-
|
|
3060
|
+
private apiAuth?;
|
|
3061
|
+
get authMode(): "api-key" | "wallet";
|
|
3062
|
+
private walletKey?;
|
|
3063
|
+
private get _privateKey();
|
|
3064
|
+
private walletAccount?;
|
|
3065
|
+
private get _account();
|
|
3402
3066
|
private _apiUrl;
|
|
3403
3067
|
private _timeout;
|
|
3404
3068
|
constructor(options?: BlockRunAnthropicOptions);
|
|
@@ -3479,4 +3143,4 @@ declare function validateTemperature(temperature?: number): void;
|
|
|
3479
3143
|
*/
|
|
3480
3144
|
declare function validateTopP(topP?: number): void;
|
|
3481
3145
|
|
|
3482
|
-
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, NETWORK_ALIASES, 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, 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_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, 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, setupAgentSolanaWallet, setupAgentWallet, solanaClient, solanaKeyToBytes, solanaPublicKey, status, validateMaxTokens, validateModel, validateTemperature, validateTopP };
|
|
3146
|
+
export { APIError, API_KEY_URL, 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, 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_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, 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 };
|