Genace

An internal error has occurred. Please retry or report in — Gemini API 500 INTERNAL on image requests

HTTP 500 INTERNAL Retry depends on cause

The exact error

500 INTERNAL. {'error': {'code': 500, 'message': 'An internal error has occurred. Please retry or report in https://developers.generativeai.google/guide/troubleshooting', 'status': 'INTERNAL'}}

The Gemini API failed on Google’s side without saying why. The message tells you to retry, and sometimes that is enough. The case to watch for is the one where the same request fails every single time, because then retrying only burns time.

What it means

500 INTERNAL is a generic server-side failure; the payload carries no reason beyond the status. Google’s troubleshooting guide groups 5xx responses with transient errors that are worth retrying with exponential backoff.

The best-documented report of this exact message, python-genai issue #1304, shows the other face of it. The reporter says requests to gemini-2.5-pro with an image in the input failed consistently with this 500 on the google-genai SDK, while text-only requests to the same model worked and the same image request to gemini-2.0-flash-exp also worked. Note that this was an image-understanding request (an image going in), not image generation.

A second user in the same issue narrowed their own case down to the request configuration: with an image, a JSON response_schema and a safety_settings list (including HARM_CATEGORY_CIVIC_INTEGRITY at BLOCK_ONLY_HIGH) on gemini-2.5-flash, the call failed; commenting out the safety_settings line made it work. Another responder could not reproduce the original report, and the issue was closed as stale without a root cause from Google. Treat both findings as user reports, not documented behaviour.

The takeaway: this message can mean “Google had a hiccup” or “Google’s backend cannot handle this particular request”, and the text is identical in both cases.

How to confirm it’s this

  • HTTP 500 and status INTERNAL, with this message. A 503 is a different error even when it is also server-side.
  • Retry the identical payload two or three times. If it succeeds, it was transient. If it fails every time, you are in the #1304 situation.
  • A/B the request. Following what the reporters in #1304 did: drop the image and send text only; send the same request to a different model; remove optional config fields one at a time, starting with safety_settings. The change that makes the 500 disappear is your trigger.

Fix

Transient 500: nothing to change; retry with backoff (below).

Repeatable 500 on one request shape:

  1. Remove optional configuration and add it back piece by piece. In #1304 the trigger reported by one user was the safety_settings list; for another it was the model and input combination.
  2. Try another model for that request. The original reporter’s workaround was a different model that accepted the same image and code.
  3. If you find a minimal request that fails every time, report it with the model name, SDK version and the smallest reproducing payload, as the second reporter in #1304 did.

The link inside the message points to a troubleshooting URL; Google’s current Gemini API troubleshooting guide is on ai.google.dev.

Retry or not

Depends. Retry, but with a small cap.

Google’s troubleshooting guide says to retry transient errors including 5xx with exponential backoff and jitter, and that the official SDKs already retry 5xx automatically (the Python SDK up to four times by default). So by the time your code sees this 500, the SDK may already have retried it.

For agent code:

  • Allow one or two further retries of the identical payload with backoff.
  • If it still fails, stop retrying and treat it as a request-shape problem: log the full request config, and either fall back to another model or fail the task with that config attached so a human can bisect it.
  • Do not let the agent start rewriting the prompt. Nothing in #1304 points at prompt wording; the reported triggers were the model and the request configuration.

When it’s not this

  • 503 UNAVAILABLE, “Deadline expired before operation could complete.” Reported in python-genai #1808 on a Nano Banana Pro image-generation request after a few minutes. It is a 503, not a 500. The issue’s assignee described 503 as the service being temporarily overloaded or down and suggested waiting and retrying or switching models; the reporter said a later retry worked.
  • 503, “The model is overloaded.” A capacity error; retry is the fix.
  • A 429. Quota or capacity allocation, not a server fault.
  • A safety block. A blocked image is a different outcome with its own handling; see the IMAGE_SAFETY page.

Error text last verified against the sources below on .

Where these facts come from