500 INTERNAL -- google.genai.errors.ServerError

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()

This is happening to me also. I am using a couple different Nano Banana 2 nodes in comfyUI with my API key and they all fail today with the 500 error. Switching to gemini-2.5-flash-image works just fine, so the NB Pro and NB 2 pipelines must be having issues. Generating NB2 content directly in Google AI Studio did work for me however, so it must just be a problem with the public API pathways? Very frustrating, I haven’t had a single request go through today in comfyUI.

Worth noting I also use the Astria Nano Banana 2 plugin directly inside photoshop, and I’ve received 4K results with 3.1 from them, so Astria must have a different pathway that’s working ok today since Astria has their own API.

1 Like

We are working on it, will keep this thread updated.

1 Like

I just saw a request go through!

Any update on this problem? I’m still getting instantly rejected with 4K calls this morning:

POST https://generativelanguage.googleapis.com/v1beta/models/gemini-3.1-flash-image-preview:generateContent “HTTP/1.1 503 Service Unavailable”

ERROR: ServerError in NanoBanana2AIO: 503 UNAVAILABLE. {‘error’: {‘code’: 503, ‘message’: ‘This model is currently experiencing high demand. Spikes in demand are usually temporary. Please try again later.’, ‘status’: ‘UNAVAILABLE’}}

503 and 500 errors on 2K as well. Thus far 2K had been delivering but that seems to be broken now too.

any updates on this? i’ve been getting 503s to my calls this week as well. even 3 retries isn’t helping