diff --git a/blockrun_llm/anthropic_client.py b/blockrun_llm/anthropic_client.py index dbbf523..b0b418b 100644 --- a/blockrun_llm/anthropic_client.py +++ b/blockrun_llm/anthropic_client.py @@ -29,6 +29,11 @@ load_dotenv() +# Default chat HTTP timeout (seconds). Was 120; reasoning models (opus-4.8) think +# 200–300s+, which the old default cut off mid-generation. Override via the +# BLOCKRUN_CHAT_TIMEOUT env var. Mirrors client.py / solana_client.py. +DEFAULT_CHAT_TIMEOUT = float(os.environ.get("BLOCKRUN_CHAT_TIMEOUT", "600")) + class _BlockRunX402Transport(httpx.BaseTransport): """Custom httpx transport that intercepts 402 responses and signs x402 payments.""" @@ -123,7 +128,7 @@ def __init__( self, private_key: Optional[str] = None, api_url: Optional[str] = None, - timeout: float = 120.0, + timeout: float = DEFAULT_CHAT_TIMEOUT, **kwargs, ): """ @@ -133,7 +138,8 @@ def __init__( private_key: Base chain wallet private key (or set BLOCKRUN_WALLET_KEY env var). Key is used for LOCAL signing only — never transmitted. api_url: BlockRun API endpoint (default: https://blockrun.ai/api). - timeout: Request timeout in seconds (default: 120). + timeout: Request timeout in seconds (default: 600, override via + BLOCKRUN_CHAT_TIMEOUT env). Reasoning models need 200–300s+. **kwargs: Additional keyword arguments passed to anthropic.Anthropic. Raises: diff --git a/blockrun_llm/client.py b/blockrun_llm/client.py index d158c2d..621b723 100644 --- a/blockrun_llm/client.py +++ b/blockrun_llm/client.py @@ -239,7 +239,7 @@ def __init__( private_key: Base chain wallet private key (or set BLOCKRUN_WALLET_KEY env var) NOTE: Key is used for LOCAL signing only - never transmitted api_url: API endpoint URL (default: https://blockrun.ai/api) - timeout: Request timeout in seconds (default: 120). Used for regular chat requests. + timeout: Request timeout in seconds (default: 600, override via BLOCKRUN_CHAT_TIMEOUT env). Used for regular chat requests. search_timeout: Timeout for xAI Live Search requests (default: 300 = 5 minutes). Live Search can be slow as it searches X, web, and news sources. Auto-detected when search_parameters or search=True is passed. @@ -2202,7 +2202,7 @@ def __init__( Args: private_key: Base chain wallet private key (or set BLOCKRUN_WALLET_KEY env var) api_url: API endpoint URL (default: https://blockrun.ai/api) - timeout: Request timeout in seconds (default: 120). Used for regular chat requests. + timeout: Request timeout in seconds (default: 600, override via BLOCKRUN_CHAT_TIMEOUT env). Used for regular chat requests. search_timeout: Timeout for xAI Live Search requests (default: 300 = 5 minutes). Auto-detected when search_parameters or search=True is passed. transaction_log: Same opt-in per-call log as ``LLMClient``. ``True`` → diff --git a/blockrun_llm/solana_client.py b/blockrun_llm/solana_client.py index 66fdd47..0992de1 100644 --- a/blockrun_llm/solana_client.py +++ b/blockrun_llm/solana_client.py @@ -86,7 +86,9 @@ def _create_signer(private_key: str) -> KeypairSigner: # # Public callers can also override per-call via ``timeout=`` on # ``chat_completion`` / ``image`` / ``image_edit`` / ``search``. -DEFAULT_CHAT_TIMEOUT = float(os.environ.get("BLOCKRUN_CHAT_TIMEOUT", "600")) # was 120; reasoning models need 200–300s+ +DEFAULT_CHAT_TIMEOUT = float( + os.environ.get("BLOCKRUN_CHAT_TIMEOUT", "600") +) # was 120; reasoning models need 200–300s+ DEFAULT_IMAGE_TIMEOUT = 200.0 DEFAULT_SEARCH_TIMEOUT = 300.0 DEFAULT_FAST_TIMEOUT = 30.0 # pyth / x_user_info / quick lookups