惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
罗磊的独立博客
宝玉的分享
宝玉的分享
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
V
V2EX
酷 壳 – CoolShell
酷 壳 – CoolShell
T
Tailwind CSS Blog
博客园_首页
量子位
月光博客
月光博客
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 司徒正美
人人都是产品经理
人人都是产品经理
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
爱范儿
爱范儿
S
SegmentFault 最新的问题
雷峰网
雷峰网
小众软件
小众软件
博客园 - 聂微东
美团技术团队
Apple Machine Learning Research
Apple Machine Learning Research
WordPress大学
WordPress大学
Jina AI
Jina AI
Hugging Face - Blog
Hugging Face - Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Imagen 3 & 4 Shut Down June 24: Migrate to Gemini Image (...
Anup Karanjkar · 2026-06-22 · via DEV Community

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

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

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;

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

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

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

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

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

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