모든 Imagen 모델은 지원 중단되었으며 2026년 8월 17일에 종료될 예정입니다. 이 지원 중단 및 종료는 Google 전반과 Gemini Developer API 및 Agent Platform Gemini API (formerly Vertex AI) 모두에 적용됩니다.
서비스 중단을 방지하려면 이 가이드에 설명된 대로 이 종료 날짜 전에 앱을 Imagen 모델에서 Gemini Nano Banana 모델로 마이그레이션해야 합니다.
이 지원 중단 및 종료와 관련된 긴급한 문제가 있는 경우 Firebase 지원팀에 문의하세요.
교체 모델 Nano Banana개
다음 표를 참고하여 앱에 사용할 대체 Nano Banana 모델을 선택하세요.
| 모델 Imagen개 | 모델 Gemini Nano Banana개 |
|---|---|
imagen-4.0-fast-generate-001 |
gemini-nano-banana-2.1 (사고 수준 MINIMAL)
|
imagen-4.0-generate-001 |
gemini-nano-banana-2.1 (사고 수준 HIGH)
|
imagen-4.0-ultra-generate-001 |
gemini-3-pro-image
|
imagen-3.0-capability-001 |
gemini-nano-banana-2.1
|
앱 마이그레이션
이 섹션에서는 Imagen 모델에서 Gemini Nano Banana 모델로 마이그레이션하기 전과 후의 예시를 보여줍니다.
텍스트에서 이미지 생성
|
Gemini API 제공업체를 클릭하여 이 페이지에서 제공업체별 콘텐츠와 코드를 확인합니다. |
텍스트에서 이미지를 생성하려면 다음과 같이 변경하여 앱을 마이그레이션합니다.
적절한 대체 Nano Banana 모델(예:
gemini-nano-banana-2.1)을 사용합니다.ImagenModel인스턴스 대신GenerativeModel인스턴스를 만듭니다.Nano Banana 모델을 수용하도록 모델 구성 옵션을 업데이트합니다.
- 이 구성의 일부로 응답 형식을
IMAGE로 설정합니다.
Nano Banana 모델은 이미지와 텍스트를 모두 반환하도록 구성할 수 있습니다.
- 이 구성의 일부로 응답 형식을
Swift
이전
import FirebaseAILogic
// Initialize the Gemini Developer API backend service.
let ai = FirebaseAI.firebaseAI(backend: .googleAI())
// Create an `ImagenModel` instance with a model that supports your use case.
let model = ai.imagenModel(modelName: "IMAGEN_MODEL_NAME")
// Provide an image generation prompt.
let prompt = "An astronaut riding a horse"
// To generate an image, call `generateImages` with the text prompt.
let response = try await model.generateImages(prompt: prompt)
// Handle the generated image.
guard let image = response.images.first else {
fatalError("No image in the response.")
}
let uiImage = UIImage(data: image.data)
이후
import FirebaseAILogic
// Initialize the Gemini Developer API backend service.
let ai = FirebaseAI.firebaseAI(backend: .googleAI())
// Create a `GenerativeModel` instance with a Gemini model that supports image output.
let model = ai.generativeModel(
modelName: "GEMINI_NANOBANANA_MODEL_NAME",
generationConfig: GenerationConfig(
responseModalities: [.image],
imageConfig: ImageConfig(aspectRatio: .landscape4x3)
)
)
// Provide an image generation prompt.
let prompt = "An astronaut riding a horse"
// To generate an image, call `generateContent` with the text prompt.
let response = try await model.generateContent(prompt)
// Handle the case where no images were generated.
guard let inlineDataPart = response.inlineDataParts.first else {
fatalError("No image in the response.")
}
// Process the image.
guard let uiImage = UIImage(data: inlineDataPart.data) else {
fatalError("Failed to convert data to UIImage.")
}
Kotlin
이전
// Initialize the Gemini Developer API backend service.
val ai = Firebase.ai(backend = GenerativeBackend.googleAI())
// Create an `ImagenModel` instance with an Imagen model that supports your use case.
val model = ai.imagenModel("IMAGEN_MODEL_NAME")
// Provide an image generation prompt.
val prompt = "An astronaut riding a horse"
// To generate an image, call `generateImages` with the text prompt.
val imageResponse = model.generateImages(prompt)
// Handle the generated image.
val image = imageResponse.images.first()
val bitmapImage = image.asBitmap()
이후
// Initialize the Gemini Developer API backend service.
val ai = Firebase.ai(backend = GenerativeBackend.googleAI())
// Create a `GenerativeModel` instance with a Gemini model that supports image output.
val model = ai.generativeModel(
modelName = "GEMINI_NANOBANANA_MODEL_NAME",
generationConfig = generationConfig {
responseModalities = listOf(ResponseModality.IMAGE),
imageConfig = imageConfig {
aspectRatio = AspectRatio.LANDSCAPE_4x3
}
}
)
// Provide an image generation prompt.
val prompt = "An astronaut riding a horse"
// To generate an image, call `generateContent` with the text prompt.
val imageResponse = model.generateContent(prompt)
if (imageResponse.finishReason == FinishReason.NO_IMAGE) {
// Handle the case where no images were generated.
} else {
// Handle the generated image.
val bitmapImage = imageResponse.candidates.first().content.parts.filterIsInstance().firstOrNull()?.image
}
Java
이전
// Initialize the Gemini Developer API backend service.
// Create an `ImagenModel` instance with an Imagen model that supports your use case.
ImagenModel imagenModel = FirebaseAI.getInstance(GenerativeBackend.googleAI())
.imagenModel(
/* modelName */ "IMAGEN_MODEL_NAME");
ImagenModelFutures model = ImagenModelFutures.from(imagenModel);
// Provide an image generation prompt.
String prompt = "An astronaut riding a horse";
// To generate an image, call `generateImages` with the text prompt.
Futures.addCallback(model.generateImages(prompt), new FutureCallback<ImagenGenerationResponse>() {
@Override
public void onSuccess(ImagenGenerationResponse result) {
if (result.getImages().isEmpty()) {
Log.d("TAG", "No images generated");
}
Bitmap bitmap = result.getImages().get(0).asBitmap();
// Use the bitmap to display the image in your UI.
}
@Override
public void onFailure(Throwable t) {
// ...
}
}, Executors.newSingleThreadExecutor());
이후
// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a Gemini model that supports image output.
GenerativeModel ai = FirebaseAI.getInstance(GenerativeBackend.googleAI()).generativeModel(
"GEMINI_NANOBANANA_MODEL_NAME",
new GenerationConfig.Builder()
.setResponseModalities(Arrays.asList(ResponseModality.IMAGE))
.setImageConfig(new ImageConfig(AspectRatio.LANDSCAPE_4x3, null))
.build()
);
GenerativeModelFutures model = GenerativeModelFutures.from(ai);
// Provide a text prompt instructing the model to generate an image.
Content prompt = new Content.Builder()
.addText("An astronaut riding a horse")
.build();
// To generate an image, call `generateContent` with the text input.
Executor executor = Executors.newSingleThreadExecutor();
ListenableFuture response = model.generateContent(prompt);
Futures.addCallback(response, new FutureCallback() {
@Override
public void onSuccess(GenerateContentResponse result) {
if (result.finishReason == FinishReason.NO_IMAGE) {
// handle the case where no images were generated
return;
}
// iterate over all the parts in the first candidate in the result object.
for (Part part : result.getCandidates().get(0).getContent().getParts()) {
if (part instanceof ImagePart) {
ImagePart imagePart = (ImagePart) part;
// The returned image as a bitmap
Bitmap generatedImageAsBitmap = imagePart.getImage();
break;
}
}
}
@Override
public void onFailure(Throwable t) {
t.printStackTrace();
}
}, executor);
Web
이전
import { initializeApp } from "firebase/app";
import { getAI, getGenerativeModel, getImagenModel, GoogleAIBackend } from "firebase/ai";
// TODO(developer): Replace the following with your app's Firebase configuration
const firebaseConfig = {
// ...
};
// Initialize FirebaseApp
const firebaseApp = initializeApp(firebaseConfig);
// Initialize the Gemini Developer API backend service.
const ai = getAI(firebaseApp, { backend: new GoogleAIBackend() });
// Create an `ImagenModel` instance with an Imagen model that supports your use case.
const model = getImagenModel(ai, { model: "IMAGEN_MODEL_NAME" });
// Provide an image generation prompt.
const prompt = "An astronaut riding a horse.";
// To generate an image, call `generateImages` with the text prompt.
const response = await model.generateImages(prompt)
// If fewer images were generated than were requested,
// then `filteredReason` will describe the reason they were filtered out.
if (response.filteredReason) {
console.log(response.filteredReason);
}
if (response.images.length == 0) {
throw new Error("No images in the response.")
}
const image = response.images[0];
이후
import { initializeApp } from "firebase/app";
import {
getAI,
getGenerativeModel,
GoogleAIBackend,
ResponseModality,
ImageConfigAspectRatio,
FinishReason
} from "firebase/ai";
// TODO(developer): Replace the following with your app's Firebase configuration
const firebaseConfig = {
// ...
};
// Initialize FirebaseApp
const firebaseApp = initializeApp(firebaseConfig);
// Initialize the Gemini Developer API backend service.
const ai = getAI(firebaseApp, { backend: new GoogleAIBackend() });
// Create a `GenerativeModel` instance with a model that supports your use case.
const model = getGenerativeModel(ai, {
model: "GEMINI_NANOBANANA_MODEL_NAME",
generationConfig: {
responseModalities: [ResponseModality.IMAGE],
imageConfig: {
aspectRatio: ImageConfigAspectRatio.LANDSCAPE_4x3
}
},
});
// Provide an image generation prompt.
const prompt = "An astronaut riding a horse.";
// To generate an image, call `generateContent` with the text prompt.
const result = await model.generateContent(prompt);
// Handle the generated image.
try {
const response = result.response;
if (response.candidates?.[0].finishReason == FinishReason.NO_IMAGE) {
// Handle the case where no images were generated.
}
const inlineDataParts = response.inlineDataParts();
if (inlineDataParts?.[0]) {
const image = inlineDataParts[0].inlineData;
// Use this mimeType and base64 data to display the image using your preferred tooling.
console.log(image.mimeType, image.data);
}
} catch (err) {
console.error('Prompt or candidate was blocked:', err);
}
Dart
이전
import 'package:firebase_ai/firebase_ai.dart';
import 'package:firebase_core/firebase_core.dart';
import 'firebase_options.dart';
// Initialize FirebaseApp
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
// Initialize the Gemini Developer API backend service.
final ai = FirebaseAI.googleAI();
// Create an `ImagenModel` instance with an Imagen model that supports your use case.
final model = ai.imagenModel(model: 'IMAGEN_MODEL_NAME');
// Provide an image generation prompt.
const prompt = 'An astronaut riding a horse.';
// To generate an image, call `generateImages` with the text prompt.
final response = await model.generateImages(prompt);
if (response.images.isNotEmpty) {
final image = response.images[0];
// Process the image.
} else {
// Handle the case where no images were generated.
print('Error: No images were generated.');
}
이후
import 'package:firebase_ai/firebase_ai.dart';
import 'package:firebase_core/firebase_core.dart';
import 'firebase_options.dart';
// Initialize FirebaseApp
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
// Initialize the Gemini Developer API backend service.
final ai = FirebaseAI.googleAI();
// Create a `GenerativeModel` instance with a Gemini model that supports image output.
final model = ai.generativeModel(
model: 'GEMINI_NANOBANANA_MODEL_NAME',
generationConfig: GenerationConfig(
responseModalities: [ResponseModalities.image],
imageConfig: ImageConfig(aspectRatio: ImageAspectRatio.landscape4x3)
),
);
// Provide a text prompt instructing the model to generate an image.
final prompt = [Content.text('An astronaut riding a horse.')];
// To generate an image, call `generateContent` with the text prompt.
final response = await model.generateContent(prompt);
if (response.inlineDataParts.isNotEmpty) {
final imageBytes = response.inlineDataParts.first.bytes;
// Process the image.
} else {
// Handle the case where no images were generated.
print('Error: No images were generated.');
}
Unity
이전
using Firebase.AI;
// Initialize the Gemini Developer API backend service
var ai = FirebaseAI.GetInstance(FirebaseAI.Backend.GoogleAI());
// Create an `ImagenModel` instance with a model that supports your use case
var model = ai.GetImagenModel(modelName: "IMAGEN_MODEL_NAME");
// Provide an image generation prompt
var prompt = "An astronaut riding a horse";
// To generate an image, call `generateImages` with the text prompt
var response = await model.GenerateImagesAsync(prompt: prompt);
// Handle the generated image
if (response.Images.Count == 0) {
throw new Exception("No image in the response.");
}
var image = response.Images[0].AsTexture2D();
이후
using Firebase;
using Firebase.AI;
// Initialize the Gemini Developer API backend service.
var ai = FirebaseAI.GetInstance(FirebaseAI.Backend.GoogleAI());
// Create a `GenerativeModel` instance with a Gemini model that supports image output.
var model = ai.GetGenerativeModel(
modelName: "GEMINI_NANOBANANA_MODEL_NAME",
generationConfig: new GenerationConfig(
responseModalities: new[] { ResponseModality.Image },
imageConfig: new ImageConfig(aspectRatio: ImageConfig.AspectRatio.Landscape4x3)
)
);
// Provide an image generation prompt.
var prompt = "An astronaut riding a horse";
// To generate an image, call `GenerateContentAsync` with the text prompt.
var response = await model.GenerateContentAsync(prompt);
if (response.Candidates.First().FinishReason == FinishReason.NoImage) {
// Handle the case where no images were generated.
}
// Handle the generated image.
var imageParts = response.Candidates.First().Content.Parts
.OfType<ModelContent.InlineDataPart>()
.Where(part => part.MimeType == "image/png");
foreach (var imagePart in imageParts) {
// Load the Image into a Unity Texture2D object.
UnityEngine.Texture2D texture2D = new(2, 2);
if (texture2D.LoadImage(imagePart.Data.ToArray())) {
// Do something with the image.
}
}
교체 구성 옵션
이 섹션에서는 모델의 응답을 제어하는 데 도움이 되는 다양한 모델 구성 옵션의 대체 옵션을 설명합니다.
안전 설정
ImagenSafetySettings를 사용하여 Imagen 모델의 안전 설정을 구성합니다. 하지만 Nano Banana 모델의 경우 SafetySetting를 사용하도록 마이그레이션해야 합니다.
모델 구성 파라미터
ImagenGenerationConfig으로 Imagen 모델을 구성합니다. 하지만 Nano Banana 모델의 경우 GenerationConfig 및 중첩된 ImageConfig(선택사항)를 사용하도록 이전해야 합니다(2026년 5월 초 SDK 버전부터 사용 가능).
GenerationConfig의 일부로 IMAGE의 응답 형식을 설정합니다(이 가이드 앞부분의 '이후' 코드 샘플 참고). 원하는 경우 IMAGE 및 TEXT를 모두 반환하도록 Nano Banana 모델을 구성할 수 있습니다.
다음 표는 모델 구성 파라미터를 Imagen에서 Nano Banana 모델로 마이그레이션하는 방법을 이해하는 데 도움이 됩니다.
| 모델 Imagen개 | 모델 Gemini Nano Banana개 |
|---|---|
addWatermark |
지원되지 않음 Nano Banana 모델은 항상 SynthID 워터마크가 포함된 AI 생성 이미지를 반환합니다. |
aspectRatio |
코드 샘플과 지원되는 값은 Nano Banana 모델 가이드의 이미지 생성 구성을 참고하세요. |
imageFormat |
지원되지 않음 Nano Banana 모델은 항상 AI 생성 이미지를 PNG 형식으로 반환합니다. |
negativePrompt |
지원되지 않음
부정 메시지 기능은 기존 기능이며, 이후로는 더 이상 지원되지 않는다는 점에 유의하십시오. |
numberOfImages |
지원되지 않음
Nano Banana 모델은 항상 생성된 단일 이미지를 반환합니다.
|
personGeneration |
지원되지 않음 기본적으로 Nano Banana 모델은 사람의 이미지를 생성할 수 있습니다. |