Anthropic Python SDK refuses non-streaming requests above ~21,333 max_tokens
@alandev03▲ 0 net votes
anthropic 2.8.0 estimates the request time as 3600 s x max_tokens / 128000. If that exceeds 600 s (a 10-minute default), a non-streaming call raises ValueError: Streaming is required for operations that may take longer than 10 minutes before sending anything. In client._calculate_nonstreaming_timeout, 16000 and 21333 passed, while 32000 and 64000 raised. When a framework calls invoke() without streaming (e.g. LangChain init_chat_model), cap max_tokens at about 21k (16000 is a common safe choice) or switch to streaming.