Google Imagen 4 Sunset Countdown: Can ERNIE-Image Be the Open-Source Alternative?
On August 17, 2026, Google will officially shut down all three Imagen 4 endpoints. For developers and businesses relying on Google's image generation API, the countdown is ticking — less than three weeks remain. For those who need multilingual text rendering, local deployment, and zero API costs, the open-source community has a compelling answer.
Imagen 4: From Google Flagship to Retirement
In April 2026, Google was still actively promoting Imagen 4's text rendering capabilities and high-fidelity image generation. Just three months later, the entire Imagen 4 lineup has entered its retirement countdown.
According to Google's official deprecations page, the following three Imagen 4 model endpoints will shut down on August 17, 2026:
| Model ID | Status | Shutdown Date | Recommended Replacement |
|---|---|---|---|
imagen-4.0-generate-001 |
Deprecated | 2026-08-17 | gemini-3.1-flash-image |
imagen-4.0-ultra-generate-001 |
Deprecated | 2026-08-17 | gemini-3.1-flash-image |
imagen-4.0-fast-generate-001 |
Deprecated | 2026-08-17 | gemini-3.1-flash-image |
This isn't Google's first image model retirement. Imagen 3 was shut down in November 2025. Each model iteration brings API endpoint changes, code rewrites, and migration costs.
Google recommends migrating to Gemini 3.1 Flash Image (community nickname: Nano Banana). But Nano Banana is also a closed-source API model — you can't download it, run it locally, fine-tune it, or train LoRAs on it.
For many developers, this means: yet another API migration, yet more vendor lock-in.
Why Look for an Open-Source Alternative?
Closed-source API models carry three fundamental risks:
- Vendor lock-in: Google can change pricing, shut down endpoints, or modify terms of service at any time. Imagen 4 users who migrated to the new API in June 2025 now face another migration in August 2026.
- Privacy and compliance: Every API call means your prompts and generated images pass through Google's servers. For scenarios involving customer data or trade secrets, this may be unacceptable.
- Unpredictable costs: API calls are billed per-use. At high throughput, costs accumulate rapidly. Self-hosted models require a one-time hardware investment with near-zero marginal cost thereafter.
ERNIE-Image: 8B Parameters, Apache 2.0, Open-Source Ready
On April 15, 2026, Baidu open-sourced ERNIE-Image — an 8B-parameter text-to-image model built on a single-stream Diffusion Transformer (DiT) architecture, released under the Apache 2.0 license.
Key Specifications:
| Feature | ERNIE-Image | Imagen 4 | Nano Banana |
|---|---|---|---|
| Open Source | ✅ Apache 2.0 | ❌ Closed | ❌ Closed |
| Local Deployment | ✅ Supported | ❌ Not supported | ❌ Not supported |
| Parameters | 8B | Unknown (closed) | Unknown (closed) |
| Chinese Text Rendering | ✅ Best-in-class | ❌ English only | ✅ Supported |
| Cost | Zero (self-hosted) | API billing | API billing |
| Fine-tuning/LoRA | ✅ Supported | ❌ Not supported | ❌ Not supported |
| Privacy | ✅ Fully local | ❌ Data to cloud | ❌ Data to cloud |
Benchmark Comparison
GenEval Complex Instruction Following
On GenEval, ERNIE-Image (w/o PE) leads all open-source models with a score of 0.8856:
| Model | Single Obj | Two Obj | Counting | Colors | Position | Att. Binding | Overall |
|---|---|---|---|---|---|---|---|
| ERNIE-Image (w/o PE) | 1.0000 | 0.9596 | 0.7781 | 0.9282 | 0.8550 | 0.7925 | 0.8856 |
| Qwen-Image | 0.9900 | 0.9200 | 0.8900 | 0.8800 | 0.7600 | 0.7700 | 0.8683 |
| FLUX.2-klein-9B | 0.9313 | 0.9571 | 0.8281 | 0.9149 | 0.7175 | 0.7400 | 0.8481 |
LongTextBench Text Rendering
Text rendering is ERNIE-Image's strongest advantage. On LongTextBench:
| Model | English | Chinese | Average |
|---|---|---|---|
| Seedream 4.5 (closed) | 0.9890 | 0.9873 | 0.9882 |
| ERNIE-Image (w/ PE) | 0.9804 | 0.9661 | 0.9733 |
| GLM-Image | 0.9524 | 0.9788 | 0.9656 |
| Qwen-Image-2512 | 0.9560 | 0.9650 | 0.9605 |
ERNIE-Image is the strongest text-rendering open-source model, handling both English and Chinese. By contrast, Imagen 4 only supports English prompts and consistently lags behind ERNIE-Image in third-party text rendering evaluations.
Migrating from Imagen 4 to ERNIE-Image: A Three-Step Guide
Step 1: Environment Setup
ERNIE-Image has minimal hardware requirements — a single 24GB GPU (RTX 3090/4090) is sufficient.
Quick Start with Diffusers:
pip install git+https://github.com/huggingface/diffusers
import torch
from diffusers import ErnieImagePipeline
pipe = ErnieImagePipeline.from_pretrained(
"baidu/ERNIE-Image",
torch_dtype=torch.bfloat16,
).to("cuda")
image = pipe(
prompt="A photo of a Japanese-style ramen shop interior, warm lighting, wooden counter, steam rising from the soup",
height=1024,
width=1024,
num_inference_steps=50,
guidance_scale=4.0,
use_pe=True
).images[0]
image.save("output.png")
Step 2: Migrate Imagen API Calls to Local
Before (Imagen API):
from google import genai
client = genai.Client()
response = client.models.generate_images(
model='imagen-4.0-generate-001',
prompt='A futuristic cityscape at sunset',
config={'number_of_images': 1, 'aspect_ratio': '16:9'}
)
After (ERNIE-Image Local):
import torch
from diffusers import ErnieImagePipeline
pipe = ErnieImagePipeline.from_pretrained(
"baidu/ERNIE-Image", torch_dtype=torch.bfloat16
).to("cuda")
image = pipe(
prompt="A futuristic cityscape at sunset, cyberpunk style, neon lights reflecting on wet streets, flying vehicles in the sky",
height=848,
width=1512,
num_inference_steps=50,
guidance_scale=4.0,
use_pe=True
).images[0]
Key differences:
- Imagen 4 uses API key + remote calls; ERNIE-Image uses local models
- ERNIE-Image supports much longer prompts (far exceeding Imagen's 480-token limit)
- ERNIE-Image supports Chinese prompts (Imagen 4 does not)
- ERNIE-Image allows custom inference steps and guidance scale
Step 3: Production Deployment
For production, SGLang deployment is recommended for optimal performance:
# Install SGLang
git clone https://github.com/sgl-project/sglang.git
pip install -e "python[diffusion]"
Start ERNIE-Image service
sglang serve --model-path baidu/ERNIE-Image
--num-gpus 1
--performance-mode auto
--port 30010
Once running, call via OpenAI-compatible API:
curl -X POST http://localhost:30010/v1/images/generations \
-H "Content-Type: application/json" \
-d '{
"prompt": "An oil painting of a mountain lake, impressionist style",
"height": 1024,
"width": 1024,
"num_inference_steps": 50,
"guidance_scale": 4.0,
"use_pe": true
}' \
--output output.png
You can replace Imagen API calls with your self-hosted endpoint with near-zero code changes — just update the base_url in any language client.
Turbo Mode: 8-Step Inference for Speed
If Imagen 4 Fast's response speed matters to you, ERNIE-Image-Turbo requires only 8 inference steps, generating a 1024×1024 image in 2-3 seconds on an RTX 4090:
pipe = ErnieImagePipeline.from_pretrained(
"baidu/ERNIE-Image-Turbo", torch_dtype=torch.bfloat16
).to("cuda")
image = pipe(
prompt="A minimalist logo design with geometric shapes",
height=1024,
width=1024,
num_inference_steps=8,
guidance_scale=1.0,
use_pe=True
).images[0]
The Turbo model uses DMD (Distribution Matching Distillation) and RL optimization to deliver 6×+ speedup while maintaining quality.
Cost Comparison
| Solution | Initial Cost | Monthly Operating Cost | Cost Per Image | Privacy |
|---|---|---|---|---|
| Imagen 4 API | $0 | ~$150 (100K images/mo) | ~$0.0015/image | ❌ |
| Nano Banana API | $0 | ~$390 (100K images/mo) | ~$0.039/image | ❌ |
| ERNIE-Image Self-hosted (RTX 4090) | ~$2,000 (one-time) | ~$50 (electricity) | ~$0.0005/image | ✅ |
| ERNIE-Image Cloud GPU (RunPod) | $0 | ~$100 (A100 40GB) | ~$0.001/image | ✅ |
Note: Estimates vary based on usage volume and cloud provider.
Who Should Migrate Immediately?
Strongly recommended to migrate:
- Chinese content creators: If you need images with Chinese text (posters, social media graphics, e-commerce images), ERNIE-Image's Chinese text rendering far exceeds Imagen 4 (which doesn't even support Chinese prompts)
- Privacy-sensitive applications: Healthcare, finance, legal — scenarios where data cannot leave local infrastructure
- High-throughput scenarios: 100K+ images per month — self-hosting offers dramatic cost advantages
- Advanced customization: Users needing LoRA fine-tuning, ControlNet, or custom VAE control
Can wait:
- Users working exclusively in English who don't need local deployment can migrate to Nano Banana
- Users primarily needing image editing — ERNIE-Image's editing model hasn't been released yet (community alternatives like FLUX Kontext or Bernini-R can fill the gap)
The Editing Model: Community Expectations
As of July 30, 2026, the ERNIE-Image editing model (Inpainting/Outpainting) has not been officially released. However, the community has several effective alternatives:
- Simple edits: img2img + mask solution is fully functional
- High-quality edits: FLUX Kontext provides professional-grade editing
- Text + edits: Bernini-R hybrid pipeline preserves text rendering advantage
Based on Baidu's roadmap, the editing model Beta is expected in July-August 2026 via ComfyUI nodes. For users needing editing capabilities, a recommended workflow combines ERNIE-Image for base generation with community alternatives for editing.
Summary: The Era of Open-Source Alternatives Has Arrived
Imagen 4's retirement is not an isolated event — it's the latest example of the inherent risks of closed-source API models. Every model iteration, every endpoint shutdown reminds developers: the convenience of APIs comes with the cost of vendor lock-in.
ERNIE-Image, as the strongest open-source text-to-image model under Apache 2.0, achieves SOTA performance in text rendering, instruction following, and structured generation. In Chinese text rendering, it's the only model that can compete with closed-source flagships.
Migrating from Imagen 4 to ERNIE-Image is more than a technical decision — it's a transition from "renting capability" to "owning capability."
Sources: Google Gemini API Deprecations, ERNIE-Image Technical Report (arXiv:2605.25347), HuggingFace baidu/ERNIE-Image, SGLang Documentation, Google Imagen Migration Guide