Gemini API Hangs Indefinitely When Processing Images

Issue Description

Code hangs with no output when processing images with the Gemini API. When the image input is removed, the code works normally.

Reproduction Code

from google import genai  
from google.genai import types  
import PIL.Image  

image = PIL.Image.open('/path/to/image.png')  

client = genai.Client(api_key="YOUR_API_KEY")  # Note: Don't share your actual API key on forums  
response = client.models.generate_content(  
    model="gemini-2.0-flash",  
    contents=["What is this image?", image])  

print(response.text)

Hi @user1496, Welcome to forum!!!

It might be an intermittent issue. I just tried your code and it’s working. Can you follow this gist.

Thanks