Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/anthropic-compat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<import('@anthropic-ai/sdk').default> {
Expand Down
2 changes: 1 addition & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
4 changes: 2 additions & 2 deletions src/openai-compat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}`,
Expand Down
6 changes: 3 additions & 3 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
Loading