@blockrun/llm 3.23.1 → 3.23.2

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 CHANGED
@@ -1600,9 +1600,9 @@ await status();
1600
1600
 
1601
1601
  `getOrCreateWallet()` resolves the Base wallet in a fixed order:
1602
1602
  `BLOCKRUN_WALLET_KEY` or `BASE_CHAIN_WALLET_KEY`, then `~/.blockrun/.session`,
1603
- then the legacy `~/.blockrun/wallet.key`. `LLMClient` itself reads only
1604
- `BASE_CHAIN_WALLET_KEY` (or an explicit `privateKey`). For a single run of the
1605
- helpers without changing anything, use `export BLOCKRUN_WALLET_KEY=<private-key>`.
1603
+ then the legacy `~/.blockrun/wallet.key`. `LLMClient` reads an explicit
1604
+ `privateKey`, then `BASE_CHAIN_WALLET_KEY`, then `BLOCKRUN_WALLET_KEY`. For a
1605
+ single run without changing anything, use `export BLOCKRUN_WALLET_KEY=<private-key>`.
1606
1606
 
1607
1607
  ### Wallet discovery and migration
1608
1608
 
@@ -1686,7 +1686,7 @@ const configured = new LLMClient({
1686
1686
  | `BLOCKRUN_API_KEY` | Account key (`brk_...`): account billing, no wallet needed. Create one at [user.blockrun.ai/dashboard/keys](https://user.blockrun.ai/dashboard/keys) |
1687
1687
  | `BLOCKRUN_API_BASE_URL` | Account API endpoint (default `https://api.blockrun.ai`) |
1688
1688
  | `BASE_CHAIN_WALLET_KEY` | EVM wallet private key for `LLMClient` (Base / Arc) and every EVM client |
1689
- | `BLOCKRUN_WALLET_KEY` | EVM wallet key honoured by the service clients, `BlockrunClient`, `setupAgentWallet()` and `AnthropicClient` (checked before `BASE_CHAIN_WALLET_KEY`); **not** read by `LLMClient` |
1689
+ | `BLOCKRUN_WALLET_KEY` | EVM wallet key read by every EVM client. The service clients, `BlockrunClient`, `setupAgentWallet()` and `AnthropicClient` check it before `BASE_CHAIN_WALLET_KEY`; `LLMClient` checks it after, so a process holding both keeps paying from the same wallet |
1690
1690
  | `SOLANA_WALLET_KEY` | Solana secret key, bs58-encoded, for `SolanaLLMClient` |
1691
1691
  | `SOLANA_RPC_URL` | Solana RPC for payments and balance (also `rpcUrl`) |
1692
1692
  | `SOLANA_RPC_API_KEY` / `SOLANA_RPC_HEADERS` | Header auth for that RPC (also `rpcHeaders`) |
package/dist/index.cjs CHANGED
@@ -4833,7 +4833,7 @@ function getCostSummary() {
4833
4833
  }
4834
4834
 
4835
4835
  // src/version.ts
4836
- var SDK_VERSION = "3.23.1";
4836
+ var SDK_VERSION = "3.23.2";
4837
4837
  var USER_AGENT = `blockrun-ts/${SDK_VERSION}`;
4838
4838
 
4839
4839
  // src/client.ts
@@ -4908,16 +4908,16 @@ var LLMClient = class _LLMClient {
4908
4908
  /**
4909
4909
  * Initialize the BlockRun LLM client.
4910
4910
  *
4911
- * @param options - Client configuration options (optional if BASE_CHAIN_WALLET_KEY env var is set)
4911
+ * @param options - Client configuration options (optional if BLOCKRUN_API_KEY, BASE_CHAIN_WALLET_KEY or BLOCKRUN_WALLET_KEY is set)
4912
4912
  */
4913
4913
  constructor(options = {}) {
4914
4914
  this.apiAuth = resolveApiKeyAuth(options);
4915
4915
  if (!this.apiAuth) {
4916
- const envKey = typeof process !== "undefined" && process.env ? process.env.BASE_CHAIN_WALLET_KEY : void 0;
4916
+ const envKey = typeof process !== "undefined" && process.env ? process.env.BASE_CHAIN_WALLET_KEY || process.env.BLOCKRUN_WALLET_KEY : void 0;
4917
4917
  const privateKey = options.privateKey || envKey;
4918
4918
  if (!privateKey) {
4919
4919
  throw new Error(
4920
- "Private key required. Pass privateKey in options or set BASE_CHAIN_WALLET_KEY environment variable."
4920
+ "Private key required. Pass privateKey in options or set BASE_CHAIN_WALLET_KEY (or BLOCKRUN_WALLET_KEY) environment variable."
4921
4921
  );
4922
4922
  }
4923
4923
  validatePrivateKey(privateKey);
@@ -5606,7 +5606,7 @@ var LLMClient = class _LLMClient {
5606
5606
  }
5607
5607
  /**
5608
5608
  * Make a request with automatic x402 payment handling, returning raw JSON.
5609
- * Used for non-ChatResponse endpoints (X/Twitter, search, image edit, etc.).
5609
+ * Used for non-ChatResponse endpoints (search, image edit, etc.).
5610
5610
  */
5611
5611
  async requestWithPaymentRaw(endpoint, body) {
5612
5612
  const url = `${this.apiUrl}${endpoint}`;
@@ -6014,7 +6014,8 @@ var LLMClient = class _LLMClient {
6014
6014
  return data;
6015
6015
  }
6016
6016
  /**
6017
- * Standalone search (web, X/Twitter, news).
6017
+ * Standalone search over web and news. For X/Twitter, use chat on an
6018
+ * `xai/*` model with an `x_search` tool.
6018
6019
  *
6019
6020
  * @param query - Search query
6020
6021
  * @param options - Optional search parameters
@@ -8508,6 +8509,7 @@ var import_accounts12 = require("viem/accounts");
8508
8509
  var DEFAULT_API_URL11 = "https://blockrun.ai/api";
8509
8510
  var DEFAULT_TIMEOUT11 = 6e4;
8510
8511
  var SURF_PREFIX = "/v1/surf";
8512
+ var warnedRetired = false;
8511
8513
  var SurfClient = class {
8512
8514
  _account;
8513
8515
  get account() {
@@ -8525,6 +8527,12 @@ var SurfClient = class {
8525
8527
  apiUrl;
8526
8528
  timeout;
8527
8529
  constructor(options = {}) {
8530
+ if (!warnedRetired) {
8531
+ warnedRetired = true;
8532
+ console.warn(
8533
+ "[blockrun] SurfClient is deprecated: the gateway retired /v1/surf/* (410 endpoint_retired). Use PriceClient, LLMClient.defi*, LLMClient.pm() or LLMClient.dex* instead."
8534
+ );
8535
+ }
8528
8536
  this.apiAuth = resolveApiKeyAuth(options);
8529
8537
  if (!this.apiAuth) {
8530
8538
  const envKey = typeof process !== "undefined" && process.env ? process.env.BLOCKRUN_WALLET_KEY || process.env.BASE_CHAIN_WALLET_KEY : void 0;
package/dist/index.d.cts CHANGED
@@ -499,7 +499,7 @@ interface PaymentRequired {
499
499
  extensions?: Record<string, unknown>;
500
500
  }
501
501
  interface LLMClientOptions extends ApiKeyOptions {
502
- /** EVM wallet private key (hex string starting with 0x). Optional if BASE_CHAIN_WALLET_KEY env var is set. */
502
+ /** EVM wallet private key (hex string starting with 0x). Optional if BASE_CHAIN_WALLET_KEY (or BLOCKRUN_WALLET_KEY) is set. */
503
503
  privateKey?: `0x${string}` | string;
504
504
  /** API endpoint URL (default: https://blockrun.ai/api) */
505
505
  apiUrl?: string;
@@ -975,7 +975,10 @@ interface VideoGenerateOptions {
975
975
  returnLastFrame?: boolean;
976
976
  }
977
977
  interface SearchOptions {
978
- /** Source types to search (e.g. ["web", "x", "news"]) */
978
+ /**
979
+ * Source types to search: `"web"` and/or `"news"` (default `["web"]`). `"x"` is
980
+ * rejected by the gateway; X search runs in chat on `xai/*` models (`x_search`).
981
+ */
979
982
  sources?: string[];
980
983
  /** Maximum number of results (default: 10) */
981
984
  maxResults?: number;
@@ -1119,6 +1122,7 @@ interface PriceClientOptions extends ApiKeyOptions {
1119
1122
  /** If false, construction succeeds without a wallet (free endpoints only). */
1120
1123
  requireWallet?: boolean;
1121
1124
  }
1125
+ /** @deprecated Surf is retired; see {@link SurfClient}. */
1122
1126
  interface SurfClientOptions extends ApiKeyOptions {
1123
1127
  privateKey?: `0x${string}` | string;
1124
1128
  apiUrl?: string;
@@ -1351,7 +1355,7 @@ declare class LLMClient {
1351
1355
  /**
1352
1356
  * Initialize the BlockRun LLM client.
1353
1357
  *
1354
- * @param options - Client configuration options (optional if BASE_CHAIN_WALLET_KEY env var is set)
1358
+ * @param options - Client configuration options (optional if BLOCKRUN_API_KEY, BASE_CHAIN_WALLET_KEY or BLOCKRUN_WALLET_KEY is set)
1355
1359
  */
1356
1360
  constructor(options?: LLMClientOptions);
1357
1361
  /**
@@ -1510,7 +1514,7 @@ declare class LLMClient {
1510
1514
  chatCompletionStream(model: string, messages: ChatMessage[], options?: ChatCompletionOptions): Promise<Response>;
1511
1515
  /**
1512
1516
  * Make a request with automatic x402 payment handling, returning raw JSON.
1513
- * Used for non-ChatResponse endpoints (X/Twitter, search, image edit, etc.).
1517
+ * Used for non-ChatResponse endpoints (search, image edit, etc.).
1514
1518
  */
1515
1519
  private requestWithPaymentRaw;
1516
1520
  /**
@@ -1574,7 +1578,8 @@ declare class LLMClient {
1574
1578
  */
1575
1579
  imageEdit(prompt: string, image: string | string[], options?: ImageEditOptions): Promise<ImageResponse>;
1576
1580
  /**
1577
- * Standalone search (web, X/Twitter, news).
1581
+ * Standalone search over web and news. For X/Twitter, use chat on an
1582
+ * `xai/*` model with an `x_search` tool.
1578
1583
  *
1579
1584
  * @param query - Search query
1580
1585
  * @param options - Optional search parameters
@@ -2328,6 +2333,7 @@ declare class PriceClient {
2328
2333
 
2329
2334
  type QueryValue$1 = string | number | boolean | null | undefined;
2330
2335
  type QueryParams$1 = Record<string, QueryValue$1 | QueryValue$1[]>;
2336
+ /** @deprecated Surf is retired (`410 endpoint_retired`); see the module docs for replacements. */
2331
2337
  declare class SurfClient {
2332
2338
  private _account?;
2333
2339
  private get account();
package/dist/index.d.ts CHANGED
@@ -499,7 +499,7 @@ interface PaymentRequired {
499
499
  extensions?: Record<string, unknown>;
500
500
  }
501
501
  interface LLMClientOptions extends ApiKeyOptions {
502
- /** EVM wallet private key (hex string starting with 0x). Optional if BASE_CHAIN_WALLET_KEY env var is set. */
502
+ /** EVM wallet private key (hex string starting with 0x). Optional if BASE_CHAIN_WALLET_KEY (or BLOCKRUN_WALLET_KEY) is set. */
503
503
  privateKey?: `0x${string}` | string;
504
504
  /** API endpoint URL (default: https://blockrun.ai/api) */
505
505
  apiUrl?: string;
@@ -975,7 +975,10 @@ interface VideoGenerateOptions {
975
975
  returnLastFrame?: boolean;
976
976
  }
977
977
  interface SearchOptions {
978
- /** Source types to search (e.g. ["web", "x", "news"]) */
978
+ /**
979
+ * Source types to search: `"web"` and/or `"news"` (default `["web"]`). `"x"` is
980
+ * rejected by the gateway; X search runs in chat on `xai/*` models (`x_search`).
981
+ */
979
982
  sources?: string[];
980
983
  /** Maximum number of results (default: 10) */
981
984
  maxResults?: number;
@@ -1119,6 +1122,7 @@ interface PriceClientOptions extends ApiKeyOptions {
1119
1122
  /** If false, construction succeeds without a wallet (free endpoints only). */
1120
1123
  requireWallet?: boolean;
1121
1124
  }
1125
+ /** @deprecated Surf is retired; see {@link SurfClient}. */
1122
1126
  interface SurfClientOptions extends ApiKeyOptions {
1123
1127
  privateKey?: `0x${string}` | string;
1124
1128
  apiUrl?: string;
@@ -1351,7 +1355,7 @@ declare class LLMClient {
1351
1355
  /**
1352
1356
  * Initialize the BlockRun LLM client.
1353
1357
  *
1354
- * @param options - Client configuration options (optional if BASE_CHAIN_WALLET_KEY env var is set)
1358
+ * @param options - Client configuration options (optional if BLOCKRUN_API_KEY, BASE_CHAIN_WALLET_KEY or BLOCKRUN_WALLET_KEY is set)
1355
1359
  */
1356
1360
  constructor(options?: LLMClientOptions);
1357
1361
  /**
@@ -1510,7 +1514,7 @@ declare class LLMClient {
1510
1514
  chatCompletionStream(model: string, messages: ChatMessage[], options?: ChatCompletionOptions): Promise<Response>;
1511
1515
  /**
1512
1516
  * Make a request with automatic x402 payment handling, returning raw JSON.
1513
- * Used for non-ChatResponse endpoints (X/Twitter, search, image edit, etc.).
1517
+ * Used for non-ChatResponse endpoints (search, image edit, etc.).
1514
1518
  */
1515
1519
  private requestWithPaymentRaw;
1516
1520
  /**
@@ -1574,7 +1578,8 @@ declare class LLMClient {
1574
1578
  */
1575
1579
  imageEdit(prompt: string, image: string | string[], options?: ImageEditOptions): Promise<ImageResponse>;
1576
1580
  /**
1577
- * Standalone search (web, X/Twitter, news).
1581
+ * Standalone search over web and news. For X/Twitter, use chat on an
1582
+ * `xai/*` model with an `x_search` tool.
1578
1583
  *
1579
1584
  * @param query - Search query
1580
1585
  * @param options - Optional search parameters
@@ -2328,6 +2333,7 @@ declare class PriceClient {
2328
2333
 
2329
2334
  type QueryValue$1 = string | number | boolean | null | undefined;
2330
2335
  type QueryParams$1 = Record<string, QueryValue$1 | QueryValue$1[]>;
2336
+ /** @deprecated Surf is retired (`410 endpoint_retired`); see the module docs for replacements. */
2331
2337
  declare class SurfClient {
2332
2338
  private _account?;
2333
2339
  private get account();
package/dist/index.js CHANGED
@@ -4702,7 +4702,7 @@ function getCostSummary() {
4702
4702
  }
4703
4703
 
4704
4704
  // src/version.ts
4705
- var SDK_VERSION = "3.23.1";
4705
+ var SDK_VERSION = "3.23.2";
4706
4706
  var USER_AGENT = `blockrun-ts/${SDK_VERSION}`;
4707
4707
 
4708
4708
  // src/client.ts
@@ -4777,16 +4777,16 @@ var LLMClient = class _LLMClient {
4777
4777
  /**
4778
4778
  * Initialize the BlockRun LLM client.
4779
4779
  *
4780
- * @param options - Client configuration options (optional if BASE_CHAIN_WALLET_KEY env var is set)
4780
+ * @param options - Client configuration options (optional if BLOCKRUN_API_KEY, BASE_CHAIN_WALLET_KEY or BLOCKRUN_WALLET_KEY is set)
4781
4781
  */
4782
4782
  constructor(options = {}) {
4783
4783
  this.apiAuth = resolveApiKeyAuth(options);
4784
4784
  if (!this.apiAuth) {
4785
- const envKey = typeof process !== "undefined" && process.env ? process.env.BASE_CHAIN_WALLET_KEY : void 0;
4785
+ const envKey = typeof process !== "undefined" && process.env ? process.env.BASE_CHAIN_WALLET_KEY || process.env.BLOCKRUN_WALLET_KEY : void 0;
4786
4786
  const privateKey = options.privateKey || envKey;
4787
4787
  if (!privateKey) {
4788
4788
  throw new Error(
4789
- "Private key required. Pass privateKey in options or set BASE_CHAIN_WALLET_KEY environment variable."
4789
+ "Private key required. Pass privateKey in options or set BASE_CHAIN_WALLET_KEY (or BLOCKRUN_WALLET_KEY) environment variable."
4790
4790
  );
4791
4791
  }
4792
4792
  validatePrivateKey(privateKey);
@@ -5475,7 +5475,7 @@ var LLMClient = class _LLMClient {
5475
5475
  }
5476
5476
  /**
5477
5477
  * Make a request with automatic x402 payment handling, returning raw JSON.
5478
- * Used for non-ChatResponse endpoints (X/Twitter, search, image edit, etc.).
5478
+ * Used for non-ChatResponse endpoints (search, image edit, etc.).
5479
5479
  */
5480
5480
  async requestWithPaymentRaw(endpoint, body) {
5481
5481
  const url = `${this.apiUrl}${endpoint}`;
@@ -5883,7 +5883,8 @@ var LLMClient = class _LLMClient {
5883
5883
  return data;
5884
5884
  }
5885
5885
  /**
5886
- * Standalone search (web, X/Twitter, news).
5886
+ * Standalone search over web and news. For X/Twitter, use chat on an
5887
+ * `xai/*` model with an `x_search` tool.
5887
5888
  *
5888
5889
  * @param query - Search query
5889
5890
  * @param options - Optional search parameters
@@ -8377,6 +8378,7 @@ import { privateKeyToAccount as privateKeyToAccount11 } from "viem/accounts";
8377
8378
  var DEFAULT_API_URL11 = "https://blockrun.ai/api";
8378
8379
  var DEFAULT_TIMEOUT11 = 6e4;
8379
8380
  var SURF_PREFIX = "/v1/surf";
8381
+ var warnedRetired = false;
8380
8382
  var SurfClient = class {
8381
8383
  _account;
8382
8384
  get account() {
@@ -8394,6 +8396,12 @@ var SurfClient = class {
8394
8396
  apiUrl;
8395
8397
  timeout;
8396
8398
  constructor(options = {}) {
8399
+ if (!warnedRetired) {
8400
+ warnedRetired = true;
8401
+ console.warn(
8402
+ "[blockrun] SurfClient is deprecated: the gateway retired /v1/surf/* (410 endpoint_retired). Use PriceClient, LLMClient.defi*, LLMClient.pm() or LLMClient.dex* instead."
8403
+ );
8404
+ }
8397
8405
  this.apiAuth = resolveApiKeyAuth(options);
8398
8406
  if (!this.apiAuth) {
8399
8407
  const envKey = typeof process !== "undefined" && process.env ? process.env.BLOCKRUN_WALLET_KEY || process.env.BASE_CHAIN_WALLET_KEY : void 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockrun/llm",
3
- "version": "3.23.1",
3
+ "version": "3.23.2",
4
4
  "type": "module",
5
5
  "description": "TypeScript SDK for BlockRun - every frontier model behind one OpenAI-compatible client. Pay with a BlockRun API key or per-call in USDC. Smart routing picks the cheapest capable model. No rate limits.",
6
6
  "main": "dist/index.cjs",