I am trying to solve a math problem from a pdf file.
I discovered there is a 60s timeout when I call generate_content(), so when gemini needs to think for longer than 60s, it always raise
“httpx.RemoteProtocolError: Server disconnected without sending a response.”.
any one knows how to set a longer timeout? below is my script, thanks.
from google import genai
client = genai.Client(api_key=“api_key”)
pdf = client.files.upload(file=“F5L09_Trigonometry (2D).pdf”)
response = client.models.generate_content(
model= “gemini-2.5-pro-preview-05-06”,
contents= [“Solve question 9 of section 2”,pdf],
)
print(response.text)
------------------------------------------------------update-----------------------------------------------------------------
I tried run another script that dont require uploading a pdf and takes more than 60s to response, and same error exist.
from google.genai import types
from google import genai
model= “gemini-2.5-pro-preview-05-06”
client = genai.Client(api_key=api_key)
response = client.models.generate_content(
model= model,
# contents= [“Solve question 14 of section IV”,pdf],
contents=[
“”"
Consider the sequence $a_n$ defined as follows:
\begin{itemize}
\item $a_1 = 7$
\item For $n>1$, $a_n$ is the number formed by concatenating the digits of $a_{n-1}$ with the digits of $S_{n-1}$, where $S_{n-1}$ is the sum of the first $n-1$ terms of the sequence (i.e., $S_{n-1} = a_1 + a_2 + \dots + a_{n-1}$).
\end{itemize}
Let $D(x)$ denote the digital root of a positive integer $x$. (The digital root is found by repeatedly summing the digits of a number until a single-digit number is obtained. For example, $D(123) = D(1+2+3) = D(6) = 6$, and $D(992) = D(9+9+2) = D(20) = D(2+0) = 2$).
The sequence of digital roots $d_n = D(a_n)$ will eventually become periodic.
"""
]
)
print(response.text)