A longer streaming call fails with a deadline-exceeded error.
Why this happens
Requests can breach client-side deadlines during prolonged generations or network delays.
Answer 1: Use a realistic client timeout
from google import genai
from google.genai import types
client = genai.Client(http_options=types.HttpOptions(timeout=60_000))
response = client.models.generate_content_stream(
model="gemini-2.5-pro",
contents="Write an essay"
)
Reference: Google Gen AI SDK HTTP options. The HTTP timeout is specified in milliseconds; 60_000 means 60 seconds.
