@blockrun/llm 4.3.1 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,5 +1,19 @@
1
1
  import * as _anthropic_ai_sdk from '@anthropic-ai/sdk';
2
2
 
3
+ /**
4
+ * Tier → Model Selection
5
+ *
6
+ * Maps a classification tier to the cheapest capable model.
7
+ * Builds RoutingDecision metadata with cost estimates and savings.
8
+ */
9
+
10
+ type ModelPricing$1 = {
11
+ inputPrice: number;
12
+ outputPrice: number;
13
+ /** Active promo flat price per request (overrides token-based pricing when set) */
14
+ flatPrice?: number;
15
+ };
16
+
3
17
  /**
4
18
  * Smart Router Types
5
19
  *
@@ -347,6 +361,12 @@ interface Model {
347
361
  billingMode?: "paid" | "flat" | "free";
348
362
  /** Flat per-request price when billingMode === "flat". */
349
363
  flatPrice?: number;
364
+ /**
365
+ * Platform fee (percent) an x402 call pays on top of the per-token
366
+ * `inputPrice` / `outputPrice`: cost = token cost x (1 + this / 100).
367
+ * 0 for free, flat and media rows, and when the gateway does not publish it.
368
+ */
369
+ platformFeePercent?: number;
350
370
  /** True for deprecated/superseded models that remain routable. */
351
371
  hidden?: boolean;
352
372
  }
@@ -1200,6 +1220,74 @@ interface PricePoint {
1200
1220
  /** The gateway's note on the data, e.g. "Daily close, not realtime. ..." */
1201
1221
  note?: string;
1202
1222
  }
1223
+ /**
1224
+ * What PriceClient.price returns: the typed fields plus every other field the
1225
+ * gateway sent, kept as-is (the on-chain US stock price carries chain, pools,
1226
+ * multiplier, usMarket, asset this way). The index signature lives here, not on
1227
+ * PricePoint, so PricePoint itself stays strict for everyone else.
1228
+ */
1229
+ type PricePointWithExtras = PricePoint & Record<string, unknown>;
1230
+ /**
1231
+ * On-chain US stock price: GET /v1/stocks/us/price/{symbol}. blockrun.ai prices
1232
+ * Coinbase Tokenized Stocks on Base, sol.blockrun.ai prices xStocks on Solana;
1233
+ * each answers only for its own chain, and a ticker with no on-chain market
1234
+ * there is a 404 before any payment.
1235
+ */
1236
+ interface OnchainStockQuote {
1237
+ symbol: string;
1238
+ market: "us";
1239
+ chain: "base" | "solana";
1240
+ /** USD per share: liquidity-weighted mid of the on-chain pools, multiplier applied. */
1241
+ price: number;
1242
+ kind: "onchain_dex_mid";
1243
+ note: string;
1244
+ token: {
1245
+ symbol: string;
1246
+ issuer: string;
1247
+ address: string;
1248
+ standard: string;
1249
+ decimals: number;
1250
+ };
1251
+ multiplier: {
1252
+ value: number;
1253
+ next: {
1254
+ value: number;
1255
+ effectiveAt: string;
1256
+ } | null;
1257
+ };
1258
+ paused: boolean | null;
1259
+ pools: Array<{
1260
+ address: string;
1261
+ dex: string;
1262
+ quote: "USDC" | "SOL";
1263
+ price: number | null;
1264
+ quoteSideUsd: number;
1265
+ tvlUsd: number;
1266
+ weight: number;
1267
+ included: boolean;
1268
+ excludedReason: string | null;
1269
+ lastTxAt: string | null;
1270
+ ageSeconds: number | null;
1271
+ }>;
1272
+ quoteSideUsd: number;
1273
+ tvlUsd: number;
1274
+ poolSpreadBps: number;
1275
+ staleWarning?: string[];
1276
+ staleWarningText?: string;
1277
+ chainTime: string;
1278
+ readAt: string;
1279
+ usMarket: {
1280
+ session: "pre" | "regular" | "post" | "closed" | "unknown";
1281
+ nextOpen: string | null;
1282
+ };
1283
+ asset: Record<string, unknown>;
1284
+ otherChains: Array<{
1285
+ chain: "base" | "solana";
1286
+ covered: boolean;
1287
+ endpoint: string;
1288
+ }>;
1289
+ [key: string]: unknown;
1290
+ }
1203
1291
  interface PriceBar {
1204
1292
  t?: number;
1205
1293
  o?: number;
@@ -1962,6 +2050,15 @@ declare class LLMClient {
1962
2050
  * @param params - Query parameters passed through to DefiLlama
1963
2051
  */
1964
2052
  defi(path: string, params?: Record<string, string>): Promise<Record<string, unknown>>;
2053
+ /**
2054
+ * On-chain US stock price from tokenized-stock DEX pools, paid per call.
2055
+ * This client's chain decides the market: Base (blockrun.ai, Coinbase
2056
+ * Tokenized Stocks) or Solana (sol.blockrun.ai, xStocks). Returns the full
2057
+ * response: price, every pool, the dividend multiplier, the US session and
2058
+ * SEC company facts. A ticker with no market on this chain throws a 404
2059
+ * APIError before anything is signed.
2060
+ */
2061
+ stockPrice(symbol: string): Promise<OnchainStockQuote>;
1965
2062
  /** All DeFi protocols with TVL. */
1966
2063
  defiProtocols(): Promise<Record<string, unknown>>;
1967
2064
  /** Single protocol details + historical TVL. */
@@ -2552,7 +2649,7 @@ declare class PriceClient {
2552
2649
  private apiUrl;
2553
2650
  private timeout;
2554
2651
  constructor(options?: PriceClientOptions);
2555
- price(category: PriceCategory, symbol: string, options?: PriceOptions): Promise<PricePoint>;
2652
+ price(category: PriceCategory, symbol: string, options?: PriceOptions): Promise<PricePointWithExtras>;
2556
2653
  history(category: PriceCategory, symbol: string, options: HistoryOptions): Promise<PriceHistoryResponse>;
2557
2654
  listSymbols(category: PriceCategory, options?: ListOptions): Promise<SymbolListResponse>;
2558
2655
  getWalletAddress(): string | null;
@@ -2766,6 +2863,49 @@ declare class BlockrunClient {
2766
2863
  getSpending(): Spending;
2767
2864
  }
2768
2865
 
2866
+ /**
2867
+ * A catalog pricing entry: the bundled router's pricing shape plus the
2868
+ * gateway's platform fee. `platformFeePercent` is set only on per-token paid
2869
+ * chat rows (see {@link platformFeePercentOf}); the router ignores it, and
2870
+ * {@link estimateChatCostUsd} applies it.
2871
+ */
2872
+ type ModelPricing = ModelPricing$1 & {
2873
+ platformFeePercent?: number;
2874
+ };
2875
+ /** A `/v1/models` row as either gateway emits it, or as the SDK maps it. */
2876
+ interface PlatformFeeRow {
2877
+ billing_mode?: string;
2878
+ billingMode?: string;
2879
+ platform_fee_percent?: unknown;
2880
+ platformFeePercent?: unknown;
2881
+ pricing?: {
2882
+ platform_fee_percent?: unknown;
2883
+ flat?: unknown;
2884
+ } | null;
2885
+ }
2886
+ /**
2887
+ * The platform fee, in percent, that an x402 call to this `/v1/models` row
2888
+ * pays on top of its per-token `pricing.input` / `pricing.output` (which stay
2889
+ * at the vendor's list price). Spec: BlockRunAI/blockrun
2890
+ * specs/2026-11-16-chat-platform-fee.md PF-8.
2891
+ *
2892
+ * Read from `pricing.platform_fee_percent` (sol.blockrun.ai and blockrun.ai),
2893
+ * then the row's top-level `platform_fee_percent` (blockrun.ai), then the
2894
+ * SDK-mapped `platformFeePercent`. The first finite, non-negative number wins.
2895
+ *
2896
+ * 0 when the field is absent (older gateways and enterprise, PF-9, do not
2897
+ * send it), and always 0 for a row that is not per-token paid chat: free,
2898
+ * flat (a flat price is final) and media rows never pay it.
2899
+ */
2900
+ declare function platformFeePercentOf(row: PlatformFeeRow | null | undefined): number;
2901
+ /**
2902
+ * Estimated USD cost of one chat call against a catalog pricing entry, before
2903
+ * any payment floor: a flat price as-is, otherwise the per-token list cost
2904
+ * times `(1 + platformFeePercent / 100)`. The real charge is always the
2905
+ * gateway's 402 quote; this is metadata for routing and budgeting.
2906
+ */
2907
+ declare function estimateChatCostUsd(pricing: ModelPricing, inputTokens: number, outputTokens: number): number;
2908
+
2769
2909
  /**
2770
2910
  * x402 Payment Protocol v2 Implementation for BlockRun.
2771
2911
  *
@@ -4265,6 +4405,15 @@ declare class SolanaLLMClient {
4265
4405
  * @param params - Query parameters passed through to DefiLlama
4266
4406
  */
4267
4407
  defi(path: string, params?: Record<string, string>): Promise<Record<string, unknown>>;
4408
+ /**
4409
+ * On-chain US stock price from tokenized-stock DEX pools, paid per call.
4410
+ * This client's chain decides the market: Base (blockrun.ai, Coinbase
4411
+ * Tokenized Stocks) or Solana (sol.blockrun.ai, xStocks). Returns the full
4412
+ * response: price, every pool, the dividend multiplier, the US session and
4413
+ * SEC company facts. A ticker with no market on this chain throws a 404
4414
+ * APIError before anything is signed.
4415
+ */
4416
+ stockPrice(symbol: string): Promise<OnchainStockQuote>;
4268
4417
  /** All DeFi protocols with TVL. */
4269
4418
  defiProtocols(): Promise<Record<string, unknown>>;
4270
4419
  /** Single protocol details + historical TVL. */
@@ -4915,4 +5064,4 @@ declare function readSettlement(response: Response, quotedUsd: number, scheme: S
4915
5064
  /** The model OpenAI serves Decisions from; the gateway also accepts our catalog ids. */
4916
5065
  declare const DECISIONS_DEFAULT_MODEL = "gpt-6-luna";
4917
5066
 
4918
- export { APIError, API_KEY_URL, ARC_CHAIN_ID, AnthropicClient, type AnyTool, type ApiKeyOptions, type AudioModel, type AudioTrack, BASE_CHAIN_ID, BLOCKRUN_SOL_OPERATOR, type BarResolution, type BatchAttempt, BatchChannelBusyError, BatchChannelLockedError, BatchCloseDeferredError, type BatchPayloadKind, BatchPaymentUnresolvedError, type BatchUnresolvedReason, type BlockRunAnthropicOptions, BlockrunClient, type BlockrunClientOptions, BlockrunError, type CallInitiatedResponse, type CallModel, type CallOptions, type CallStatusResponse, type ChatChoice, type ChatCompletionOptions, type ChatMessage, type ChatOptions, type ChatResponse, type ChatResponseWithCost, type ChatUsage, type CostEntry, type CostEstimate, type CreatePaymentOptions, DECISIONS_DEFAULT_MODEL, DEFAULT_BATCH_BUSY_WAIT_MS, DEFAULT_BATCH_IN_DOUBT, DEFAULT_BATCH_LOCK_WAIT_MS, DEFAULT_BATCH_RATE_LIMIT, type DecisionAnswer, type DecisionChoice, type DecisionInputMessage, type DecisionLevel, type DecisionQuestion, type DecisionsRequest, type DecisionsResponse, EVM_NETWORKS, type EvmNetwork, type FunctionCall, type FunctionDefinition, type HistoryOptions, ImageClient, type ImageClientOptions, type ImageData, type ImageEditOptions, type ImageGenerateOptions, type ImageModel, type ImageResponse, KNOWN_PROVIDERS, LLMClient, type LLMClientOptions, type ListOptions, type MarketSession, type Model, MusicClient, type MusicClientOptions, type MusicGenerateOptions, type MusicResponse, NETWORK_ALIASES, type NewsSearchSource, OpenAI, type OpenAIChatCompletionChoice, type OpenAIChatCompletionChunk, type OpenAIChatCompletionParams, type OpenAIChatCompletionResponse, type OpenAIClientOptions, PAYMENT_REPLAY, PHONE_PRICES, PORTAL_URL, PORTRAIT_ENROLLMENT_PRICE_USD, PaymentError, type PaymentLinks, PaymentReplayError, type PhoneBuyOptions, type PhoneBuyResponse, PhoneClient, type PhoneClientOptions, type PhoneListResponse, type PhoneLookupResponse, type PhoneNumberRecord, type PhoneReleaseResponse, type PhoneRenewResponse, type PollOptions, PortraitClient, type PortraitClientOptions, type PortraitEnrollOptions, type PortraitEnrollResponse, type PriceBar, type PriceCategory, PriceClient, type PriceClientOptions, type PriceHistoryResponse, type PriceOptions, type PricePoint, RPC_PRICE_USD, type ReasoningEffort, type Rechallenge, type ResponseFormat, RetiredEndpointError, type RetryDisposition, type RoutingDecision, type RoutingProfile, type RoutingTaskType, type RoutingTier, type RoutingTierConfig, type RpcBatchRequest, RpcClient, type RpcClientOptions, type RpcError, type RpcNetwork, type RpcResponse, type RssSearchSource, SOLANA_NETWORK, SOLANA_WALLET_FILE as SOLANA_WALLET_FILE_PATH, SUPPORTED_NETWORKS, SearchClient, type SearchClientOptions, type SearchOptions, type SearchParameters, type SearchResult, type SearchSource, type SearchUsage, type Settlement, type SmartChatCompletionOptions, type SmartChatCompletionResponse, type SmartChatOptions, type SmartChatResponse, type SolanaBatchEvent, type SolanaBatchOptions, SolanaBatchPayer, type SolanaBatchPayerInit, type SolanaBatchStats, SolanaLLMClient, type SolanaLLMClientOptions, type SolanaWalletInfo, type SoundEffectOptions, type SpeechAudio, SpeechClient, type SpeechClientOptions, type SpeechGenerateOptions, type SpeechModel, type SpeechResponse, type SpeechVoice, type Spending, type SpendingReport, type StockMarket, SurfClient, type SurfClientOptions, type SymbolListResponse, type Tool, type ToolCall, type ToolChoice, USDC_ARC, USDC_BASE, USDC_BASE_CONTRACT, USDC_SOLANA, type UrlCitation, VideoClient, type VideoClientOptions, type VideoClip, type VideoGenerateOptions, type VideoModel, type VideoResponse, VoiceClient, type VoiceClientOptions, type VoiceInfo, type VoicePreset, WALLET_DIR_PATH, WALLET_FILE_PATH, type WalletAuthChallenge, type WalletInfo, type WebSearchSource, type WebSearchTool, type X402ClientLike, type X402HookContext, type XSearchSource, type XSearchTool, buildPaymentRejectedError, clearCache, createPaymentPayload, createSolanaPaymentPayload, createSolanaWallet, createWallet, LLMClient as default, evmNetwork, extractPaymentDetails, formatFundingMessageCompact, formatNeedsFundingMessage, formatSolanaWalletMigrationNotice, formatWalletCreatedMessage, formatWalletMigrationNotice, getCached, getCachedByRequest, getCostLogSummary, getCostSummary, getEip681Uri, getOrCreateSolanaWallet, getOrCreateWallet, getPaymentLinks, getWalletAddress, importSolanaWallet, importWallet, isPaymentReplay, listDiscoveredSolanaWallets, listDiscoveredWallets, loadSolanaWallet, loadWallet, logCost, parsePaymentRequired, paymentRejectedErrorFromBody, readSettlement, retryDisposition, saveSolanaWallet, saveToCache, saveWallet, scanSolanaWallets, scanWallets, setCache, setupAgentClient, setupAgentSolanaWallet, setupAgentWallet, solanaClient, solanaKeyToBytes, solanaPublicKey, status, toWireSearchParameters, toWireTools, validateMaxTokens, validateModel, validateTemperature, validateTopP };
5067
+ export { APIError, API_KEY_URL, ARC_CHAIN_ID, AnthropicClient, type AnyTool, type ApiKeyOptions, type AudioModel, type AudioTrack, BASE_CHAIN_ID, BLOCKRUN_SOL_OPERATOR, type BarResolution, type BatchAttempt, BatchChannelBusyError, BatchChannelLockedError, BatchCloseDeferredError, type BatchPayloadKind, BatchPaymentUnresolvedError, type BatchUnresolvedReason, type BlockRunAnthropicOptions, BlockrunClient, type BlockrunClientOptions, BlockrunError, type CallInitiatedResponse, type CallModel, type CallOptions, type CallStatusResponse, type ChatChoice, type ChatCompletionOptions, type ChatMessage, type ChatOptions, type ChatResponse, type ChatResponseWithCost, type ChatUsage, type CostEntry, type CostEstimate, type CreatePaymentOptions, DECISIONS_DEFAULT_MODEL, DEFAULT_BATCH_BUSY_WAIT_MS, DEFAULT_BATCH_IN_DOUBT, DEFAULT_BATCH_LOCK_WAIT_MS, DEFAULT_BATCH_RATE_LIMIT, type DecisionAnswer, type DecisionChoice, type DecisionInputMessage, type DecisionLevel, type DecisionQuestion, type DecisionsRequest, type DecisionsResponse, EVM_NETWORKS, type EvmNetwork, type FunctionCall, type FunctionDefinition, type HistoryOptions, ImageClient, type ImageClientOptions, type ImageData, type ImageEditOptions, type ImageGenerateOptions, type ImageModel, type ImageResponse, KNOWN_PROVIDERS, LLMClient, type LLMClientOptions, type ListOptions, type MarketSession, type Model, MusicClient, type MusicClientOptions, type MusicGenerateOptions, type MusicResponse, NETWORK_ALIASES, type NewsSearchSource, type OnchainStockQuote, OpenAI, type OpenAIChatCompletionChoice, type OpenAIChatCompletionChunk, type OpenAIChatCompletionParams, type OpenAIChatCompletionResponse, type OpenAIClientOptions, PAYMENT_REPLAY, PHONE_PRICES, PORTAL_URL, PORTRAIT_ENROLLMENT_PRICE_USD, PaymentError, type PaymentLinks, PaymentReplayError, type PhoneBuyOptions, type PhoneBuyResponse, PhoneClient, type PhoneClientOptions, type PhoneListResponse, type PhoneLookupResponse, type PhoneNumberRecord, type PhoneReleaseResponse, type PhoneRenewResponse, type PlatformFeeRow, type PollOptions, PortraitClient, type PortraitClientOptions, type PortraitEnrollOptions, type PortraitEnrollResponse, type PriceBar, type PriceCategory, PriceClient, type PriceClientOptions, type PriceHistoryResponse, type PriceOptions, type PricePoint, type PricePointWithExtras, RPC_PRICE_USD, type ReasoningEffort, type Rechallenge, type ResponseFormat, RetiredEndpointError, type RetryDisposition, type RoutingDecision, type RoutingProfile, type RoutingTaskType, type RoutingTier, type RoutingTierConfig, type RpcBatchRequest, RpcClient, type RpcClientOptions, type RpcError, type RpcNetwork, type RpcResponse, type RssSearchSource, SOLANA_NETWORK, SOLANA_WALLET_FILE as SOLANA_WALLET_FILE_PATH, SUPPORTED_NETWORKS, SearchClient, type SearchClientOptions, type SearchOptions, type SearchParameters, type SearchResult, type SearchSource, type SearchUsage, type Settlement, type SmartChatCompletionOptions, type SmartChatCompletionResponse, type SmartChatOptions, type SmartChatResponse, type SolanaBatchEvent, type SolanaBatchOptions, SolanaBatchPayer, type SolanaBatchPayerInit, type SolanaBatchStats, SolanaLLMClient, type SolanaLLMClientOptions, type SolanaWalletInfo, type SoundEffectOptions, type SpeechAudio, SpeechClient, type SpeechClientOptions, type SpeechGenerateOptions, type SpeechModel, type SpeechResponse, type SpeechVoice, type Spending, type SpendingReport, type StockMarket, SurfClient, type SurfClientOptions, type SymbolListResponse, type Tool, type ToolCall, type ToolChoice, USDC_ARC, USDC_BASE, USDC_BASE_CONTRACT, USDC_SOLANA, type UrlCitation, VideoClient, type VideoClientOptions, type VideoClip, type VideoGenerateOptions, type VideoModel, type VideoResponse, VoiceClient, type VoiceClientOptions, type VoiceInfo, type VoicePreset, WALLET_DIR_PATH, WALLET_FILE_PATH, type WalletAuthChallenge, type WalletInfo, type WebSearchSource, type WebSearchTool, type X402ClientLike, type X402HookContext, type XSearchSource, type XSearchTool, buildPaymentRejectedError, clearCache, createPaymentPayload, createSolanaPaymentPayload, createSolanaWallet, createWallet, LLMClient as default, estimateChatCostUsd, evmNetwork, extractPaymentDetails, formatFundingMessageCompact, formatNeedsFundingMessage, formatSolanaWalletMigrationNotice, formatWalletCreatedMessage, formatWalletMigrationNotice, getCached, getCachedByRequest, getCostLogSummary, getCostSummary, getEip681Uri, getOrCreateSolanaWallet, getOrCreateWallet, getPaymentLinks, getWalletAddress, importSolanaWallet, importWallet, isPaymentReplay, listDiscoveredSolanaWallets, listDiscoveredWallets, loadSolanaWallet, loadWallet, logCost, parsePaymentRequired, paymentRejectedErrorFromBody, platformFeePercentOf, readSettlement, retryDisposition, saveSolanaWallet, saveToCache, saveWallet, scanSolanaWallets, scanWallets, setCache, setupAgentClient, setupAgentSolanaWallet, setupAgentWallet, solanaClient, solanaKeyToBytes, solanaPublicKey, status, toWireSearchParameters, toWireTools, validateMaxTokens, validateModel, validateTemperature, validateTopP };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,19 @@
1
1
  import * as _anthropic_ai_sdk from '@anthropic-ai/sdk';
2
2
 
3
+ /**
4
+ * Tier → Model Selection
5
+ *
6
+ * Maps a classification tier to the cheapest capable model.
7
+ * Builds RoutingDecision metadata with cost estimates and savings.
8
+ */
9
+
10
+ type ModelPricing$1 = {
11
+ inputPrice: number;
12
+ outputPrice: number;
13
+ /** Active promo flat price per request (overrides token-based pricing when set) */
14
+ flatPrice?: number;
15
+ };
16
+
3
17
  /**
4
18
  * Smart Router Types
5
19
  *
@@ -347,6 +361,12 @@ interface Model {
347
361
  billingMode?: "paid" | "flat" | "free";
348
362
  /** Flat per-request price when billingMode === "flat". */
349
363
  flatPrice?: number;
364
+ /**
365
+ * Platform fee (percent) an x402 call pays on top of the per-token
366
+ * `inputPrice` / `outputPrice`: cost = token cost x (1 + this / 100).
367
+ * 0 for free, flat and media rows, and when the gateway does not publish it.
368
+ */
369
+ platformFeePercent?: number;
350
370
  /** True for deprecated/superseded models that remain routable. */
351
371
  hidden?: boolean;
352
372
  }
@@ -1200,6 +1220,74 @@ interface PricePoint {
1200
1220
  /** The gateway's note on the data, e.g. "Daily close, not realtime. ..." */
1201
1221
  note?: string;
1202
1222
  }
1223
+ /**
1224
+ * What PriceClient.price returns: the typed fields plus every other field the
1225
+ * gateway sent, kept as-is (the on-chain US stock price carries chain, pools,
1226
+ * multiplier, usMarket, asset this way). The index signature lives here, not on
1227
+ * PricePoint, so PricePoint itself stays strict for everyone else.
1228
+ */
1229
+ type PricePointWithExtras = PricePoint & Record<string, unknown>;
1230
+ /**
1231
+ * On-chain US stock price: GET /v1/stocks/us/price/{symbol}. blockrun.ai prices
1232
+ * Coinbase Tokenized Stocks on Base, sol.blockrun.ai prices xStocks on Solana;
1233
+ * each answers only for its own chain, and a ticker with no on-chain market
1234
+ * there is a 404 before any payment.
1235
+ */
1236
+ interface OnchainStockQuote {
1237
+ symbol: string;
1238
+ market: "us";
1239
+ chain: "base" | "solana";
1240
+ /** USD per share: liquidity-weighted mid of the on-chain pools, multiplier applied. */
1241
+ price: number;
1242
+ kind: "onchain_dex_mid";
1243
+ note: string;
1244
+ token: {
1245
+ symbol: string;
1246
+ issuer: string;
1247
+ address: string;
1248
+ standard: string;
1249
+ decimals: number;
1250
+ };
1251
+ multiplier: {
1252
+ value: number;
1253
+ next: {
1254
+ value: number;
1255
+ effectiveAt: string;
1256
+ } | null;
1257
+ };
1258
+ paused: boolean | null;
1259
+ pools: Array<{
1260
+ address: string;
1261
+ dex: string;
1262
+ quote: "USDC" | "SOL";
1263
+ price: number | null;
1264
+ quoteSideUsd: number;
1265
+ tvlUsd: number;
1266
+ weight: number;
1267
+ included: boolean;
1268
+ excludedReason: string | null;
1269
+ lastTxAt: string | null;
1270
+ ageSeconds: number | null;
1271
+ }>;
1272
+ quoteSideUsd: number;
1273
+ tvlUsd: number;
1274
+ poolSpreadBps: number;
1275
+ staleWarning?: string[];
1276
+ staleWarningText?: string;
1277
+ chainTime: string;
1278
+ readAt: string;
1279
+ usMarket: {
1280
+ session: "pre" | "regular" | "post" | "closed" | "unknown";
1281
+ nextOpen: string | null;
1282
+ };
1283
+ asset: Record<string, unknown>;
1284
+ otherChains: Array<{
1285
+ chain: "base" | "solana";
1286
+ covered: boolean;
1287
+ endpoint: string;
1288
+ }>;
1289
+ [key: string]: unknown;
1290
+ }
1203
1291
  interface PriceBar {
1204
1292
  t?: number;
1205
1293
  o?: number;
@@ -1962,6 +2050,15 @@ declare class LLMClient {
1962
2050
  * @param params - Query parameters passed through to DefiLlama
1963
2051
  */
1964
2052
  defi(path: string, params?: Record<string, string>): Promise<Record<string, unknown>>;
2053
+ /**
2054
+ * On-chain US stock price from tokenized-stock DEX pools, paid per call.
2055
+ * This client's chain decides the market: Base (blockrun.ai, Coinbase
2056
+ * Tokenized Stocks) or Solana (sol.blockrun.ai, xStocks). Returns the full
2057
+ * response: price, every pool, the dividend multiplier, the US session and
2058
+ * SEC company facts. A ticker with no market on this chain throws a 404
2059
+ * APIError before anything is signed.
2060
+ */
2061
+ stockPrice(symbol: string): Promise<OnchainStockQuote>;
1965
2062
  /** All DeFi protocols with TVL. */
1966
2063
  defiProtocols(): Promise<Record<string, unknown>>;
1967
2064
  /** Single protocol details + historical TVL. */
@@ -2552,7 +2649,7 @@ declare class PriceClient {
2552
2649
  private apiUrl;
2553
2650
  private timeout;
2554
2651
  constructor(options?: PriceClientOptions);
2555
- price(category: PriceCategory, symbol: string, options?: PriceOptions): Promise<PricePoint>;
2652
+ price(category: PriceCategory, symbol: string, options?: PriceOptions): Promise<PricePointWithExtras>;
2556
2653
  history(category: PriceCategory, symbol: string, options: HistoryOptions): Promise<PriceHistoryResponse>;
2557
2654
  listSymbols(category: PriceCategory, options?: ListOptions): Promise<SymbolListResponse>;
2558
2655
  getWalletAddress(): string | null;
@@ -2766,6 +2863,49 @@ declare class BlockrunClient {
2766
2863
  getSpending(): Spending;
2767
2864
  }
2768
2865
 
2866
+ /**
2867
+ * A catalog pricing entry: the bundled router's pricing shape plus the
2868
+ * gateway's platform fee. `platformFeePercent` is set only on per-token paid
2869
+ * chat rows (see {@link platformFeePercentOf}); the router ignores it, and
2870
+ * {@link estimateChatCostUsd} applies it.
2871
+ */
2872
+ type ModelPricing = ModelPricing$1 & {
2873
+ platformFeePercent?: number;
2874
+ };
2875
+ /** A `/v1/models` row as either gateway emits it, or as the SDK maps it. */
2876
+ interface PlatformFeeRow {
2877
+ billing_mode?: string;
2878
+ billingMode?: string;
2879
+ platform_fee_percent?: unknown;
2880
+ platformFeePercent?: unknown;
2881
+ pricing?: {
2882
+ platform_fee_percent?: unknown;
2883
+ flat?: unknown;
2884
+ } | null;
2885
+ }
2886
+ /**
2887
+ * The platform fee, in percent, that an x402 call to this `/v1/models` row
2888
+ * pays on top of its per-token `pricing.input` / `pricing.output` (which stay
2889
+ * at the vendor's list price). Spec: BlockRunAI/blockrun
2890
+ * specs/2026-11-16-chat-platform-fee.md PF-8.
2891
+ *
2892
+ * Read from `pricing.platform_fee_percent` (sol.blockrun.ai and blockrun.ai),
2893
+ * then the row's top-level `platform_fee_percent` (blockrun.ai), then the
2894
+ * SDK-mapped `platformFeePercent`. The first finite, non-negative number wins.
2895
+ *
2896
+ * 0 when the field is absent (older gateways and enterprise, PF-9, do not
2897
+ * send it), and always 0 for a row that is not per-token paid chat: free,
2898
+ * flat (a flat price is final) and media rows never pay it.
2899
+ */
2900
+ declare function platformFeePercentOf(row: PlatformFeeRow | null | undefined): number;
2901
+ /**
2902
+ * Estimated USD cost of one chat call against a catalog pricing entry, before
2903
+ * any payment floor: a flat price as-is, otherwise the per-token list cost
2904
+ * times `(1 + platformFeePercent / 100)`. The real charge is always the
2905
+ * gateway's 402 quote; this is metadata for routing and budgeting.
2906
+ */
2907
+ declare function estimateChatCostUsd(pricing: ModelPricing, inputTokens: number, outputTokens: number): number;
2908
+
2769
2909
  /**
2770
2910
  * x402 Payment Protocol v2 Implementation for BlockRun.
2771
2911
  *
@@ -4265,6 +4405,15 @@ declare class SolanaLLMClient {
4265
4405
  * @param params - Query parameters passed through to DefiLlama
4266
4406
  */
4267
4407
  defi(path: string, params?: Record<string, string>): Promise<Record<string, unknown>>;
4408
+ /**
4409
+ * On-chain US stock price from tokenized-stock DEX pools, paid per call.
4410
+ * This client's chain decides the market: Base (blockrun.ai, Coinbase
4411
+ * Tokenized Stocks) or Solana (sol.blockrun.ai, xStocks). Returns the full
4412
+ * response: price, every pool, the dividend multiplier, the US session and
4413
+ * SEC company facts. A ticker with no market on this chain throws a 404
4414
+ * APIError before anything is signed.
4415
+ */
4416
+ stockPrice(symbol: string): Promise<OnchainStockQuote>;
4268
4417
  /** All DeFi protocols with TVL. */
4269
4418
  defiProtocols(): Promise<Record<string, unknown>>;
4270
4419
  /** Single protocol details + historical TVL. */
@@ -4915,4 +5064,4 @@ declare function readSettlement(response: Response, quotedUsd: number, scheme: S
4915
5064
  /** The model OpenAI serves Decisions from; the gateway also accepts our catalog ids. */
4916
5065
  declare const DECISIONS_DEFAULT_MODEL = "gpt-6-luna";
4917
5066
 
4918
- export { APIError, API_KEY_URL, ARC_CHAIN_ID, AnthropicClient, type AnyTool, type ApiKeyOptions, type AudioModel, type AudioTrack, BASE_CHAIN_ID, BLOCKRUN_SOL_OPERATOR, type BarResolution, type BatchAttempt, BatchChannelBusyError, BatchChannelLockedError, BatchCloseDeferredError, type BatchPayloadKind, BatchPaymentUnresolvedError, type BatchUnresolvedReason, type BlockRunAnthropicOptions, BlockrunClient, type BlockrunClientOptions, BlockrunError, type CallInitiatedResponse, type CallModel, type CallOptions, type CallStatusResponse, type ChatChoice, type ChatCompletionOptions, type ChatMessage, type ChatOptions, type ChatResponse, type ChatResponseWithCost, type ChatUsage, type CostEntry, type CostEstimate, type CreatePaymentOptions, DECISIONS_DEFAULT_MODEL, DEFAULT_BATCH_BUSY_WAIT_MS, DEFAULT_BATCH_IN_DOUBT, DEFAULT_BATCH_LOCK_WAIT_MS, DEFAULT_BATCH_RATE_LIMIT, type DecisionAnswer, type DecisionChoice, type DecisionInputMessage, type DecisionLevel, type DecisionQuestion, type DecisionsRequest, type DecisionsResponse, EVM_NETWORKS, type EvmNetwork, type FunctionCall, type FunctionDefinition, type HistoryOptions, ImageClient, type ImageClientOptions, type ImageData, type ImageEditOptions, type ImageGenerateOptions, type ImageModel, type ImageResponse, KNOWN_PROVIDERS, LLMClient, type LLMClientOptions, type ListOptions, type MarketSession, type Model, MusicClient, type MusicClientOptions, type MusicGenerateOptions, type MusicResponse, NETWORK_ALIASES, type NewsSearchSource, OpenAI, type OpenAIChatCompletionChoice, type OpenAIChatCompletionChunk, type OpenAIChatCompletionParams, type OpenAIChatCompletionResponse, type OpenAIClientOptions, PAYMENT_REPLAY, PHONE_PRICES, PORTAL_URL, PORTRAIT_ENROLLMENT_PRICE_USD, PaymentError, type PaymentLinks, PaymentReplayError, type PhoneBuyOptions, type PhoneBuyResponse, PhoneClient, type PhoneClientOptions, type PhoneListResponse, type PhoneLookupResponse, type PhoneNumberRecord, type PhoneReleaseResponse, type PhoneRenewResponse, type PollOptions, PortraitClient, type PortraitClientOptions, type PortraitEnrollOptions, type PortraitEnrollResponse, type PriceBar, type PriceCategory, PriceClient, type PriceClientOptions, type PriceHistoryResponse, type PriceOptions, type PricePoint, RPC_PRICE_USD, type ReasoningEffort, type Rechallenge, type ResponseFormat, RetiredEndpointError, type RetryDisposition, type RoutingDecision, type RoutingProfile, type RoutingTaskType, type RoutingTier, type RoutingTierConfig, type RpcBatchRequest, RpcClient, type RpcClientOptions, type RpcError, type RpcNetwork, type RpcResponse, type RssSearchSource, SOLANA_NETWORK, SOLANA_WALLET_FILE as SOLANA_WALLET_FILE_PATH, SUPPORTED_NETWORKS, SearchClient, type SearchClientOptions, type SearchOptions, type SearchParameters, type SearchResult, type SearchSource, type SearchUsage, type Settlement, type SmartChatCompletionOptions, type SmartChatCompletionResponse, type SmartChatOptions, type SmartChatResponse, type SolanaBatchEvent, type SolanaBatchOptions, SolanaBatchPayer, type SolanaBatchPayerInit, type SolanaBatchStats, SolanaLLMClient, type SolanaLLMClientOptions, type SolanaWalletInfo, type SoundEffectOptions, type SpeechAudio, SpeechClient, type SpeechClientOptions, type SpeechGenerateOptions, type SpeechModel, type SpeechResponse, type SpeechVoice, type Spending, type SpendingReport, type StockMarket, SurfClient, type SurfClientOptions, type SymbolListResponse, type Tool, type ToolCall, type ToolChoice, USDC_ARC, USDC_BASE, USDC_BASE_CONTRACT, USDC_SOLANA, type UrlCitation, VideoClient, type VideoClientOptions, type VideoClip, type VideoGenerateOptions, type VideoModel, type VideoResponse, VoiceClient, type VoiceClientOptions, type VoiceInfo, type VoicePreset, WALLET_DIR_PATH, WALLET_FILE_PATH, type WalletAuthChallenge, type WalletInfo, type WebSearchSource, type WebSearchTool, type X402ClientLike, type X402HookContext, type XSearchSource, type XSearchTool, buildPaymentRejectedError, clearCache, createPaymentPayload, createSolanaPaymentPayload, createSolanaWallet, createWallet, LLMClient as default, evmNetwork, extractPaymentDetails, formatFundingMessageCompact, formatNeedsFundingMessage, formatSolanaWalletMigrationNotice, formatWalletCreatedMessage, formatWalletMigrationNotice, getCached, getCachedByRequest, getCostLogSummary, getCostSummary, getEip681Uri, getOrCreateSolanaWallet, getOrCreateWallet, getPaymentLinks, getWalletAddress, importSolanaWallet, importWallet, isPaymentReplay, listDiscoveredSolanaWallets, listDiscoveredWallets, loadSolanaWallet, loadWallet, logCost, parsePaymentRequired, paymentRejectedErrorFromBody, readSettlement, retryDisposition, saveSolanaWallet, saveToCache, saveWallet, scanSolanaWallets, scanWallets, setCache, setupAgentClient, setupAgentSolanaWallet, setupAgentWallet, solanaClient, solanaKeyToBytes, solanaPublicKey, status, toWireSearchParameters, toWireTools, validateMaxTokens, validateModel, validateTemperature, validateTopP };
5067
+ export { APIError, API_KEY_URL, ARC_CHAIN_ID, AnthropicClient, type AnyTool, type ApiKeyOptions, type AudioModel, type AudioTrack, BASE_CHAIN_ID, BLOCKRUN_SOL_OPERATOR, type BarResolution, type BatchAttempt, BatchChannelBusyError, BatchChannelLockedError, BatchCloseDeferredError, type BatchPayloadKind, BatchPaymentUnresolvedError, type BatchUnresolvedReason, type BlockRunAnthropicOptions, BlockrunClient, type BlockrunClientOptions, BlockrunError, type CallInitiatedResponse, type CallModel, type CallOptions, type CallStatusResponse, type ChatChoice, type ChatCompletionOptions, type ChatMessage, type ChatOptions, type ChatResponse, type ChatResponseWithCost, type ChatUsage, type CostEntry, type CostEstimate, type CreatePaymentOptions, DECISIONS_DEFAULT_MODEL, DEFAULT_BATCH_BUSY_WAIT_MS, DEFAULT_BATCH_IN_DOUBT, DEFAULT_BATCH_LOCK_WAIT_MS, DEFAULT_BATCH_RATE_LIMIT, type DecisionAnswer, type DecisionChoice, type DecisionInputMessage, type DecisionLevel, type DecisionQuestion, type DecisionsRequest, type DecisionsResponse, EVM_NETWORKS, type EvmNetwork, type FunctionCall, type FunctionDefinition, type HistoryOptions, ImageClient, type ImageClientOptions, type ImageData, type ImageEditOptions, type ImageGenerateOptions, type ImageModel, type ImageResponse, KNOWN_PROVIDERS, LLMClient, type LLMClientOptions, type ListOptions, type MarketSession, type Model, MusicClient, type MusicClientOptions, type MusicGenerateOptions, type MusicResponse, NETWORK_ALIASES, type NewsSearchSource, type OnchainStockQuote, OpenAI, type OpenAIChatCompletionChoice, type OpenAIChatCompletionChunk, type OpenAIChatCompletionParams, type OpenAIChatCompletionResponse, type OpenAIClientOptions, PAYMENT_REPLAY, PHONE_PRICES, PORTAL_URL, PORTRAIT_ENROLLMENT_PRICE_USD, PaymentError, type PaymentLinks, PaymentReplayError, type PhoneBuyOptions, type PhoneBuyResponse, PhoneClient, type PhoneClientOptions, type PhoneListResponse, type PhoneLookupResponse, type PhoneNumberRecord, type PhoneReleaseResponse, type PhoneRenewResponse, type PlatformFeeRow, type PollOptions, PortraitClient, type PortraitClientOptions, type PortraitEnrollOptions, type PortraitEnrollResponse, type PriceBar, type PriceCategory, PriceClient, type PriceClientOptions, type PriceHistoryResponse, type PriceOptions, type PricePoint, type PricePointWithExtras, RPC_PRICE_USD, type ReasoningEffort, type Rechallenge, type ResponseFormat, RetiredEndpointError, type RetryDisposition, type RoutingDecision, type RoutingProfile, type RoutingTaskType, type RoutingTier, type RoutingTierConfig, type RpcBatchRequest, RpcClient, type RpcClientOptions, type RpcError, type RpcNetwork, type RpcResponse, type RssSearchSource, SOLANA_NETWORK, SOLANA_WALLET_FILE as SOLANA_WALLET_FILE_PATH, SUPPORTED_NETWORKS, SearchClient, type SearchClientOptions, type SearchOptions, type SearchParameters, type SearchResult, type SearchSource, type SearchUsage, type Settlement, type SmartChatCompletionOptions, type SmartChatCompletionResponse, type SmartChatOptions, type SmartChatResponse, type SolanaBatchEvent, type SolanaBatchOptions, SolanaBatchPayer, type SolanaBatchPayerInit, type SolanaBatchStats, SolanaLLMClient, type SolanaLLMClientOptions, type SolanaWalletInfo, type SoundEffectOptions, type SpeechAudio, SpeechClient, type SpeechClientOptions, type SpeechGenerateOptions, type SpeechModel, type SpeechResponse, type SpeechVoice, type Spending, type SpendingReport, type StockMarket, SurfClient, type SurfClientOptions, type SymbolListResponse, type Tool, type ToolCall, type ToolChoice, USDC_ARC, USDC_BASE, USDC_BASE_CONTRACT, USDC_SOLANA, type UrlCitation, VideoClient, type VideoClientOptions, type VideoClip, type VideoGenerateOptions, type VideoModel, type VideoResponse, VoiceClient, type VoiceClientOptions, type VoiceInfo, type VoicePreset, WALLET_DIR_PATH, WALLET_FILE_PATH, type WalletAuthChallenge, type WalletInfo, type WebSearchSource, type WebSearchTool, type X402ClientLike, type X402HookContext, type XSearchSource, type XSearchTool, buildPaymentRejectedError, clearCache, createPaymentPayload, createSolanaPaymentPayload, createSolanaWallet, createWallet, LLMClient as default, estimateChatCostUsd, evmNetwork, extractPaymentDetails, formatFundingMessageCompact, formatNeedsFundingMessage, formatSolanaWalletMigrationNotice, formatWalletCreatedMessage, formatWalletMigrationNotice, getCached, getCachedByRequest, getCostLogSummary, getCostSummary, getEip681Uri, getOrCreateSolanaWallet, getOrCreateWallet, getPaymentLinks, getWalletAddress, importSolanaWallet, importWallet, isPaymentReplay, listDiscoveredSolanaWallets, listDiscoveredWallets, loadSolanaWallet, loadWallet, logCost, parsePaymentRequired, paymentRejectedErrorFromBody, platformFeePercentOf, readSettlement, retryDisposition, saveSolanaWallet, saveToCache, saveWallet, scanSolanaWallets, scanWallets, setCache, setupAgentClient, setupAgentSolanaWallet, setupAgentWallet, solanaClient, solanaKeyToBytes, solanaPublicKey, status, toWireSearchParameters, toWireTools, validateMaxTokens, validateModel, validateTemperature, validateTopP };