diff --git a/src/anthropic-compat.ts b/src/anthropic-compat.ts index 8858520..1f4703b 100644 --- a/src/anthropic-compat.ts +++ b/src/anthropic-compat.ts @@ -7,6 +7,7 @@ import { } from './x402.js'; import { getOrCreateWallet } from './wallet.js'; import { validatePrivateKey, validateApiUrl, validateResourceUrl } from './validation.js'; +import { DEFAULT_TIMEOUT } from './client.js'; // ====================================================================== // Types @@ -41,7 +42,7 @@ export class AnthropicClient { const apiUrl = options.apiUrl ?? 'https://blockrun.ai/api'; validateApiUrl(apiUrl); this._apiUrl = apiUrl.replace(/\/$/, ''); - this._timeout = options.timeout ?? 60000; + this._timeout = options.timeout ?? DEFAULT_TIMEOUT; } private async _getClient(): Promise { diff --git a/src/client.ts b/src/client.ts index eeed322..027ead1 100644 --- a/src/client.ts +++ b/src/client.ts @@ -163,7 +163,7 @@ function resolveDefaultTimeout(): number { return 600_000; // 600s } -const DEFAULT_TIMEOUT = resolveDefaultTimeout(); +export const DEFAULT_TIMEOUT = resolveDefaultTimeout(); // SDK version for User-Agent header (client identification in server logs) const SDK_VERSION = "1.5.0"; diff --git a/src/openai-compat.ts b/src/openai-compat.ts index f7a4537..4b99a05 100644 --- a/src/openai-compat.ts +++ b/src/openai-compat.ts @@ -19,7 +19,7 @@ * }); */ -import { LLMClient } from "./client"; +import { LLMClient, DEFAULT_TIMEOUT } from "./client"; import type { ChatMessage, ChatResponse, ResponseFormat, Tool, ToolCall, ToolChoice } from "./types"; // OpenAI-compatible types @@ -272,7 +272,7 @@ export class OpenAI { constructor(options: OpenAIClientOptions = {}) { const privateKey = options.walletKey || options.privateKey; const apiUrl = options.baseURL || "https://blockrun.ai/api"; - const timeout = options.timeout || 60000; + const timeout = options.timeout ?? DEFAULT_TIMEOUT; this.client = new LLMClient({ privateKey: privateKey as `0x${string}`, diff --git a/src/types.ts b/src/types.ts index e3482c9..663fe51 100644 --- a/src/types.ts +++ b/src/types.ts @@ -287,7 +287,7 @@ export interface LLMClientOptions { privateKey?: `0x${string}` | string; /** API endpoint URL (default: https://blockrun.ai/api) */ apiUrl?: string; - /** Request timeout in milliseconds (default: 60000) */ + /** Request timeout in milliseconds (default: 600000 / 600s; override via BLOCKRUN_CHAT_TIMEOUT env, in seconds) */ timeout?: number; } @@ -953,7 +953,7 @@ export interface PhoneClientOptions { privateKey?: `0x${string}` | string; /** API endpoint URL (default: https://blockrun.ai/api) */ apiUrl?: string; - /** Request timeout in milliseconds (default: 60000) */ + /** Request timeout in milliseconds (default: 600000 / 600s; override via BLOCKRUN_CHAT_TIMEOUT env, in seconds) */ timeout?: number; } @@ -1032,7 +1032,7 @@ export interface PortraitClientOptions { privateKey?: `0x${string}` | string; /** API endpoint URL (default: https://blockrun.ai/api) */ apiUrl?: string; - /** Request timeout in milliseconds (default: 60000) */ + /** Request timeout in milliseconds (default: 600000 / 600s; override via BLOCKRUN_CHAT_TIMEOUT env, in seconds) */ timeout?: number; }