DEV Community

Anup Karanjkar
Anup Karanjkar

Posted on • Originally published at wowhow.cloud

Imagen 3 & 4 Shut Down June 24: Migrate to Gemini Image (2026)

June 24, 2026. That is the shutdown date for every Imagen model on Firebase AI Logic — imagen-3.0-generate-002, imagen-4.0-generate-001, imagen-4.0-ultra-generate-001, imagen-4.0-fast-generate-001. All of them. If you have been putting off this migration, you have run out of runway.

The replacement is Google's Gemini Image models — internally called "Nano Banana," publicly named gemini-2.5-flash-image. The migration is mostly a one-function rename and a response structure update, around 90 minutes of work for most codebases. The catch: one Imagen capability, mask-based editing, has no replacement at all. That separate deadline hits June 30.

What Goes Dark and When

Firebase AI Logic's migration documentation confirms these shutdown dates:

  • imagen-3.0-generate-002 — June 24, 2026

  • imagen-4.0-generate-001 — June 24, 2026

  • imagen-4.0-ultra-generate-001 — June 24, 2026

  • imagen-4.0-fast-generate-001 — June 24, 2026

  • imagen-3.0-capability-001 (mask editing: inpainting, outpainting, object removal) — June 30, 2026

Vertex AI runs on a slightly different clock — Google recommends migrating before June 30, with a hard shutdown date of August 17 for Vertex AI users on legacy Imagen endpoints. Firebase AI Logic is the shorter deadline. Don't assume extra time if your app uses the Firebase SDK.

The Core Migration: Python

Three things change simultaneously: the method name, the model identifier, and the response structure. All three break if you miss any one of them.

Before (Imagen):

import google.generativeai as genai

client = genai.Client(api_key="YOUR_KEY")

response = client.models.generate_images(
    model="imagen-4.0-generate-001",
    prompt="A red fox running through snow",
    config={"number_of_images": 1, "output_mime_type": "image/jpeg"}
)

image_bytes = response.generated_images[0].image.image_bytes
Enter fullscreen mode Exit fullscreen mode

After (Gemini Image):

import google.generativeai as genai

client = genai.Client(api_key="YOUR_KEY")

response = client.models.generate_content(
    model="gemini-2.5-flash-image",
    contents="A red fox running through snow"
)

image_bytes = response.candidates[0].content.parts[0].inline_data.data
Enter fullscreen mode Exit fullscreen mode

generate_images becomes generate_content. The response path shifts from .generated_images[0].image.image_bytes to .candidates[0].content.parts[0].inline_data.data. The config dict drops entirely — gemini-2.5-flash-image does not accept number_of_images as a parameter. If you need multiple images, call the API multiple times.

The response structure change is where most migration bugs land. Imagen returned a typed ImageGenerationResponse with a strongly-typed .images array. Gemini Image returns a GenerateContentResponse with a mixed .parts array. If your call generates both text and an image in the same response (Gemini Image supports this; Imagen did not), you cannot reliably grab index 0 — you need to filter parts by type.

TypeScript / Node.js

// Before
const response = await ai.models.generateImages({
  model: 'imagen-4.0-generate-001',
  prompt: 'A red fox running through snow',
  config: { numberOfImages: 1, outputMimeType: 'image/jpeg' }
});
const imageBytes = response.generatedImages[0].image.imageBytes;

// After
const response = await ai.models.generateContent({
  model: 'gemini-2.5-flash-image',
  contents: 'A red fox running through snow'
});
const imageBytes = response.candidates[0].content.parts[0].inlineData.data;
Enter fullscreen mode Exit fullscreen mode

Same pattern: method rename, model name, response path. The camelCase shifts to match — inlineData rather than inline_data in the JavaScript SDK. Watch for that.

Firebase SDK Migration (Swift and Kotlin)

Mobile developers using Firebase AI Logic have platform-specific SDK changes on top of the model swap.

Swift — Before:

let imagenModel = FirebaseAI.imagenModel(modelName: "imagen-4.0-generate-001")
let response = try await imagenModel.generateImages(from: "A red fox in snow")
let imageData = response.images.first?.data
Enter fullscreen mode Exit fullscreen mode

Swift — After:

let geminiModel = FirebaseAI.generativeModel(modelName: "gemini-2.5-flash-image")
let response = try await geminiModel.generateContent("A red fox in snow")
let imageData = response.candidates.first?.content.parts
    .compactMap { $0 as? InlineDataPart }
    .first?.data
Enter fullscreen mode Exit fullscreen mode

Kotlin — Before:

val imagenModel = Firebase.ai.imagenModel("imagen-4.0-generate-001")
val response = imagenModel.generateImages("A red fox in snow")
val imageData = response.images.firstOrNull()?.data
Enter fullscreen mode Exit fullscreen mode

Kotlin — After:

val geminiModel = Firebase.ai.generativeModel("gemini-2.5-flash-image")
val response = geminiModel.generateContent("A red fox in snow")
val imageData = response.candidates.firstOrNull()?.content?.parts
    ?.filterIsInstance()
    ?.firstOrNull()?.inlineData?.data
Enter fullscreen mode Exit fullscreen mode

The Swift version uses .compactMap { $0 as? InlineDataPart } to filter the parts array. Kotlin uses filterIsInstance<InlineDataPart>(). Both are more verbose than the old response.images.first, but both handle the mixed-parts response correctly regardless of whether the model returns text alongside the image.

The Gap Nobody Has a Solution For

imagen-3.0-capability-001 handles mask-based editing — inpainting (fill a masked region with generated content), outpainting (extend the canvas beyond its borders), and object removal (fill with background). Its shutdown date is June 30, not June 24. That is not extra time; it is a separate deadline for a separate endpoint being retired without a direct replacement.

Google's DevRel team confirmed this in a developer forum thread on June 18 with 147 replies. The frustration was pointed: developers using Imagen mask editing for product photo cleanup, e-commerce background removal, and virtual try-on have no equivalent Gemini Image API call. The recommended path from the Google team was to migrate core generation to gemini-2.5-flash-image now, and handle the mask editing gap via third-party services until Google ships a native solution — with no ETA given.

If mask editing is a peripheral feature in your app, stub it out with an error message and plan a replacement later. If mask editing is central to your product value, you need a fallback before June 30. Stability AI's SDXL inpainting API accepts similar mask formats. Replicate hosts several inpainting models at comparable quality levels. Cloudflare Workers AI includes a Stable Diffusion inpainting endpoint that skips GPU infrastructure management entirely. None of these are drop-in replacements, but all expose mask-based editing that won't disappear on you in eight days.

What the Outputs Actually Look Like After Migration

The API is not the only thing that changes. Run your existing prompt library through Gemini Image before cutting prod traffic over.

Aspect ratios. Imagen 4 accepted explicit parameters: 1:1, 4:3, 3:4, 16:9, 9:16. Gemini Image defaults to 1:1 and reads aspect ratio guidance from the prompt itself. For landscape or portrait outputs, add directional language — "horizontal landscape image" or "vertical portrait format" — directly in the prompt. Missing this is the most common migration regression reported in the Google developer forums.

Text rendering. Imagen 4.0-ultra was the benchmark for readable text within generated images. Gemini Image handles text better than Imagen 3 did, but trails 4.0-ultra on multi-word phrases, sub-12px apparent font sizes, and text on complex backgrounds. If your prompts include specific text strings like business cards, labels, or signage, benchmark explicitly before launch.

Safety filtering. Gemini Image runs Gemini's content safety system, which is more conservative than Imagen's on ambiguous content. Prompts involving artistic violence, medical imagery, or certain cultural content that Imagen processed without intervention may now return refusals. Run your full prompt corpus through Google AI Studio — free tier handles this — and note which prompts need adjustment before touching production code.

SynthID watermarks. Both Imagen and Gemini Image embed SynthID digital watermarks. The implementations differ in their metadata format. If your pipeline reads, strips, or validates SynthID data, test that code path against Gemini Image outputs specifically.

Price per image. Imagen used flat per-image pricing. Gemini Image on Vertex AI bills per output token — a typical 1024×1024 JPEG runs 400–600 image output tokens. At current Vertex AI rates, that lands higher than Imagen's standard tier for most workloads. Run cost projections against your actual usage before cutting over if you generate at volume.

Vertex AI Migration

Vertex AI users have a slightly different SDK path. The old Imagen endpoint was imagegeneration@006 under the Vision Models library. The replacement uses the Generative Models SDK:

from vertexai.generative_models import GenerativeModel

# Before
from vertexai.preview.vision_models import ImageGenerationModel
model = ImageGenerationModel.from_pretrained("imagegeneration@006")
response = model.generate_images(prompt="A red fox in snow")
image = response.images[0]

# After
model = GenerativeModel("gemini-2.5-flash-image")
response = model.generate_content("A red fox in snow")
image_data = response.candidates[0].content.parts[0].inline_data.data
Enter fullscreen mode Exit fullscreen mode

Check your Vertex AI quota for gemini-2.5-flash-image before migration. The default is 60 requests per minute per region — separate from text model quotas and separate from the old Imagen quotas. If you are running at any meaningful volume, file a quota increase request through Google Cloud Console today. Standard processing is 24–48 hours, and the buffer before Vertex AI shutdown on August 17 disappears faster than it looks.

Migration Checklist

  1. Grep the codebase for imagenModel, generate_images, generateImages, imagegeneration@, and every Imagen model name string. One pass surfaces every file that needs updating.

  2. Run your 20 most-used prompts through gemini-2.5-flash-image in Google AI Studio (free tier). Document output differences — especially aspect ratios and text rendering. Adjust prompts before touching code.

  3. Update method names, model identifiers, and response parsing paths in a feature branch. The code changes are mechanical; the response structure update is where bugs hide.

  4. Check Vertex AI quota for gemini-2.5-flash-image and request an increase if needed.

  5. If the app uses mask-based editing: stand up a third-party fallback before June 30. This takes longer than the core migration — start it today.

  6. Deploy to staging, run the full test suite. Snapshot tests will need to be reset — model outputs differ.

  7. Cut Firebase production traffic to Gemini Image by June 24. Keep the old Imagen code paths behind a feature flag for one week as a rollback target.

Speed on the other side of this migration is genuinely better: Imagen 4 averaged 4–6 seconds per 1024×1024 image; Gemini Image averages 2–3 seconds. Users notice. The mask editing gap is real, and Google has given no timeline for closing it. The rest of the migration is three renamed functions and a different response path. Start the grep now.

Originally published at wowhow.cloud

Top comments (0)