error object. Do not retry every
failure with the same request.
A typical error response has this shape:
Prevent common validation failures
- Omit
imageSizeforgemini-2.5-flash-image. - Lite accepts an omitted size or uppercase
1K. - Flash and Pro accept an omitted size for 1K, or uppercase
1K,2K, or4K. - Omit
candidateCountor set it to1. - Use raw Base64 in
inlineData.data; do not include a data URL prefix. - Match
inlineData.mimeTypeto the source bytes.
413 as a request-size failure, not a transient server error.
Prevent GPT Image validation failures
- Use
low,medium,high, orautofor either GPT Image route; the selected upstream determines the effect. - Set
sizeexplicitly to1024x1024,2048x2048, or3840x2160. - Omit
nor use1. - Send Edit as
multipart/form-datawith oneimagefile and a prompt. - Submit asynchronous generation or editing to
/v1/images/taskswithaction=generate|edit. - For
action=edit, provide 1–16input_imagesitems with matching MIME. - Keep reverse-image requests at
n=1; omit masks, transparency, output-format controls, and partial-image streaming. - Parse GPT task output from native
result.data[].b64_json; parse Nano Banana from nativeresult.candidates[].content.parts[].inlineData.
Treat an async submit timeout as unknown
Before submitting, create anIdempotency-Key of at most 255 bytes and persist
it with the application job. A retry with the same body returns the original
task instead of creating duplicate billable work. Reusing the key with another
body returns HTTP 409. There is no task-list query for recovering a lost ID,
so persist task_id as soon as HTTP 202 returns.
429 is not a fixed gateway RPM limit
The documented Nano Banana routes do not have a fixed platform-side RPM cap; the gateway access layer supports at least 5,000 API requests per minute. A429 on these routes should be handled as an official-upstream rate or capacity
response. Google may enforce RPM, images per minute, spend, project tier, or
model-capacity limits independently of the gateway.
The 5,000 RPM figure describes request ingress, not 5,000 completed images per
minute. See traffic capacity and availability
for the complete scope.
The 5,000 RPM and 98% statements are scoped to the documented Nano Banana gateway routes. No separate GPT Image gateway RPM or availability objective is currently published. GPT Image clients should still honor Retry-After, use bounded backoff with jitter, and stop after a deadline.
Bound retry behavior
Retry only transient rate-limit or server failures. Set a maximum attempt count or deadline, add random jitter, and stop retrying when the response indicates a validation, credential, balance, or ownership problem.Authenticate correctly
Create, store, and rotate a YingTu development key.
Use bounded polling
Implement Retry-After, jitter, deadline, and terminal-state handling.
Plan traffic capacity
Separate gateway RPM, upstream capacity, and the availability objective.
Check model parameters
Open the selected model’s exact size and ratio contract.
Check GPT Image parameters
Choose Web or VIP and send only its supported fields.
Contact API support
Send a redacted report with responseId or task_id when documented actions fail.