This morning, I found that my code accessing gemini-3-pro-image-preview was responding with 500 INTERNAL errors “Internal error encountered.”, “status”: “INTERNAL”, and I haven’t been able to figure out what’s wrong.
I know that my GEMINI_API_KEY is fine, because it works just fine at aistudio.google.com, and I can see it clearly in my environment.
I tried to use other models, and it hasn’t worked, outside models that return only text.
The code is quite simple (attached at the bottom here.) Not only is it simple, it was supplied from aistudio itself. (I had to make one adjustment, to remove a blank “person_generation” parameter.)
I made a whole system for making and submitting requests to Nano Banana 2 just yesterday, and it was working perfectly fine just 10 and a half hours ago. (GitHub - LionKimbro/renderlab · GitHub) And this morning, I only find 500 INTERNAL server errors, no matter what path I take.
Is my code here wrong or excessive in some way? “Create an image of a bird.” Seems conservative to me.
# To run this code you need to install the following dependencies:
# pip install google-genai
import mimetypes
import os
from google import genai
from google.genai import types
def save_binary_file(file_name, data):
f = open(file_name, "wb")
f.write(data)
f.close()
print(f"File saved to to: {file_name}")
def generate():
client = genai.Client(
api_key=os.environ.get("GEMINI_API_KEY"),
)
model = "gemini-3-pro-image-preview"
contents = [
types.Content(
role="user",
parts=[
types.Part.from_text(text="""create an image of a bird"""),
],
),
]
generate_content_config = types.GenerateContentConfig(
image_config = types.ImageConfig(
aspect_ratio="1:1",
image_size="1K"
),
response_modalities=[
"IMAGE",
"TEXT",
],
)
file_index = 0
for chunk in client.models.generate_content_stream(
model=model,
contents=contents,
config=generate_content_config,
):
if (
chunk.parts is None
):
continue
if chunk.parts[0].inline_data and chunk.parts[0].inline_data.data:
file_name = f"ENTER_FILE_NAME_{file_index}"
file_index += 1
inline_data = chunk.parts[0].inline_data
data_buffer = inline_data.data
file_extension = mimetypes.guess_extension(inline_data.mime_type)
save_binary_file(f"{file_name}{file_extension}", data_buffer)
else:
print(chunk.text)
if __name__ == "__main__":
generate()