Gemini image generation failed: Error 500, Message: An internal error has occurred. Please retry or report in https://developers.generativeai.google/guide/troubleshooting, Status: INTERNAL, Details: []

Problem you have encountered:
Gemini image generation failed: Error 500, Message: An internal error has occurred. Please retry or report in https://developers.generativeai.google/guide/troubleshooting, Status: INTERNAL, Details:

What you expected to happen:
i want to use gemini-2.5-flash-image to create image

Steps to reproduce:

google.golang.org/genai @1.36.0

func (g *NanoBananaService) GenerateNanoBananaImage(ctx context.Context, prompt string, modelName string, aspectRatio string) (string, error) {
cc := &genai.ClientConfig{APIKey: g.ApiKey}
client, err := genai.NewClient(ctx, cc)
if err != nil {
log.Printf(“Gemini client init failed: %v”, err)
return “”, err
}

    generateConfig := &genai.GenerateContentConfig{
            ImageConfig: &genai.ImageConfig{
                    AspectRatio: aspectRatio,
                    ImageSize:   "1K",
            },
    }
    //generateConfig = nil
    // 打印curl命令
    fmt.Printf("curl -X POST '[https://generativelanguage.googleapis.com/v1beta/models/%s:generateContent](https://generativelanguage.googleapis.com/v1beta/models/%s:generateContent)' -H 'Content-Type: application/json' -H 'Authorization: Bearer %s' -d '{prompt: %q}'\\n", modelName, g.ApiKey, prompt)

    result, err := client.Models.GenerateContent(
            ctx,
            modelName,
            genai.Text(prompt),
            generateConfig,
    )
    if err != nil {
            log.Printf("Gemini image generation failed: %v", err)
            return "", err
    }

    for i, candidate := range result.Candidates {
            fmt.Printf("Candidate #%d: FinishReason=%s\\n", i, candidate.FinishReason)
            if candidate.Content != nil {
                    fmt.Printf("  Role: %s\\n", candidate.Content.Role)
                    for j, part := range candidate.Content.Parts {
                            if part.Text != "" {
                                    fmt.Printf("    Part #%d Text: %s\\n", j, part.Text)
                            }
                            if part.InlineData != nil {
                                    fmt.Printf("    Part #%d InlineData: MIMEType=%s, DataLen=%d\\n", j, part.InlineData.MIMEType, len(part.InlineData.Data))
                            }
                    }
            }
    }

    for \_, part := range result.Candidates\[0\].Content.Parts {
            if part.InlineData != nil {
                    imageBytes := part.InlineData.Data
                    bucketName := g.GcsManager.GetBucket()
                    blobName := fmt.Sprintf("gemini_image/%s/%s.png", modelName, uuid.New().String())
                    publicUrl, err := g.uploadBlobAndGetPublicURL(bucketName, imageBytes, blobName)
                    if err != nil {
                            log.Printf("Failed to upload Gemini image to GCS: %v", err)
                            return "", err
                    }
                    fmt.Println(publicUrl)
                    return publicUrl, nil
            }
    }
    return "", fmt.Errorf("No image generated by Gemini")

}

Hi @Ming_Yong
Welcome to the AI Forum!!!

I am using the gemini-2.5-flash-image model to generate images using python, and it works fine on my end. If possible could you please try once with python language because i am not experiencing any issues when generating images with this model.
You can refer this code:

from google import genai
from google.genai import types
from google.colab import userdata

from google.colab import userdata
API_KEY = userdata.get('API_KEY')
client = genai.Client(api_key=API_KEY)

prompt = (
    "Create a picture of a boy"
)

response = client.models.generate_content(
    model="gemini-2.5-flash-image",
    contents=[prompt],
)

for part in response.parts:
    if part.text is not None:
        print(part.text)
    elif part.inline_data is not None:
        image = part.as_image()
        image.save("generated_image.png")

For more detailed information on image generation, please refer to the official documentation.