Google killed three Imagen 4 API endpoints on August 17. If your production app calls generate_images()
with any of those model IDs, it is throwing a hard error right now — not a deprecation warning, not a graceful fallback. A hard stop. And if you migrated to gemini-2.5-flash-image
based on Google’s earlier guidance, you have six weeks before that one dies too. Here is the complete fix.
What Google Shut Down #
Three endpoints died on August 17, 2026:
imagen-4.0-generate-001
(Standard, $0.040/image)imagen-4.0-fast-generate-001
(Fast, $0.020/image)imagen-4.0-ultra-generate-001
(Ultra, $0.060/image)
Vertex AI users saw these deprecated in March. Gemini API users hit the wall yesterday. Run a codebase audit now — search for generate_images
, imagen-4.0
, and GenerateImagesConfig
.
The Migration Is Not a Drop-In Swap #
Three things changed at the API level. Miss any of them and you ship broken code.
1. The method is gone. client.models.generate_images()
does not exist on Gemini image models. Switch to client.models.generate_content()
.
2. The response structure changed. response.generated_images
is gone. Iterate over response.candidates[0].content.parts
and check each part for inline_data
.
3. Multiple images require a loop. There is no direct equivalent to number_of_images=4
in the same request shape. Call in a loop or check whether your target model supports the n
config parameter.
Here is a minimal before-and-after:
Old Code (Broken as of August 17)
from google import genai
from google.genai import types
client = genai.Client()
response = client.models.generate_images(
model='imagen-4.0-generate-001',
prompt='A photo of a golden retriever on a beach',
config=types.GenerateImagesConfig(number_of_images=1),
)
response.generated_images[0].image.save('output.png')
New Code (Working with Gemini 3.1 Flash Image)
from google import genai
from google.genai.types import GenerateContentConfig, Modality
from PIL import Image
from io import BytesIO
client = genai.Client()
response = client.models.generate_content(
model="gemini-3.1-flash-image",
contents="A photo of a golden retriever on a beach",
config=GenerateContentConfig(response_modalities=[Modality.IMAGE]),
)
for part in response.candidates[0].content.parts:
if part.inline_data is not None:
image = Image.open(BytesIO(part.inline_data.data))
image.save("output.png")
Firebase AI Logic users have a separate migration path — check Google’s Firebase migration guide for the SDK-specific calls.
Do Not Stop at Gemini 2.5 Flash Image #
Google’s initial migration guidance pointed at gemini-2.5-flash-image
. That model retires on October 2, 2026 — 44 days from now. If you migrate to it today, you are doing this again in six weeks.
Go directly to gemini-3.1-flash-image
(Nano Banana 2) or gemini-3.1-flash-lite-image
(Nano Banana 2 Lite). Both are GA with no announced retirement date. Google’s model retirement tracker is worth bookmarking if you run multiple Google AI integrations.
Which Model Is Right for Your Workload #
Two real options:
| Model | Price (1K img) | Speed | Max Res | Status |
|---|---|---|---|---|
gemini-3.1-flash-image |
$0.067 | ~10s | 4K | GA — safe |
gemini-3.1-flash-lite-image |
$0.034 | ~4s | 1K | GA — safe |
gemini-3.1-flash-image (Batch) |
$0.034 | async | 4K | GA — safe |
gemini-2.5-flash-image |
~$0.050 | ~7s | 2K | Retires Oct 2 |
Gemini 3.1 Flash Image is the full-quality target. Four-K output, 14 aspect ratios, multi-subject consistency across up to five characters, native world knowledge. List price is approximately $0.067 per 1K-resolution image. Run it through the Batch API and the price drops to $0.034 with async delivery.
Gemini 3.1 Flash Lite Image is the budget option. At $0.034 per image, it is cheaper than old Imagen 4 Standard ($0.040) and roughly matches what Imagen 4 Fast cost in bulk. Outputs cap at 1K resolution, text rendering is weaker on small fonts, and there is no Search grounding. For draft generation, thumbnail pipelines, or high-volume preview workflows, it earns its place.
At standard resolution, real-time, Nano Banana 2 costs 67% more than Imagen 4 Standard used to. That is the honest number. There is no GA equivalent to Imagen 4 Fast’s $0.020 price point. Nano Banana 2 Lite closes the gap and brings you a stable model in return.
The Quick Decision #
Final-quality images, full resolution, or conversational image editing: use gemini-3.1-flash-image
. High-volume previews, drafts, or anything where 1K is sufficient: use gemini-3.1-flash-lite-image
. Need full quality at Imagen 4 Standard pricing: use Nano Banana 2 through the Batch API.
Either way, migrate once to a 3.1 model and you are on GA with no announced sunset. That stability is worth the extra cost over the alternative — staying on Gemini 2.5 Flash Image and scheduling the same migration for October.
For the full list of changes in the Gemini API across all model types, the official Gemini API changelog is the authoritative source.