GeminiGörüntü modelinden hem yalnızca metin içeren hem de metin ve dosya içeren istemleri kullanarak görüntü oluşturmasını ve düzenlemesini isteyebilirsiniz. Firebase AI Logic kullanırken bu isteği doğrudan uygulamanızdan gönderebilirsiniz.
Bu özellik sayesinde şunları yapabilirsiniz:
Doğal dildeki sohbetlerle yinelemeli olarak görseller oluşturun, tutarlılığı ve bağlamı koruyarak görselleri ayarlayın.
Uzun metin dizeleri de dahil olmak üzere yüksek kaliteli metin oluşturma özelliğine sahip görüntüler üretin.
Dönüşümlü olarak metin ve resim çıktısı oluşturun. Örneğin, tek bir dönüşte metin ve resim içeren bir blog yayını. Daha önce bu işlem için birden fazla modelin bir araya getirilmesi gerekiyordu.
Gemini'ın dünya bilgisi ve muhakeme özelliklerini kullanarak görüntüler oluşturun.
Desteklenen özelliklerin tam listesini (örnek istemlerle birlikte) bu sayfanın ilerleyen bölümlerinde bulabilirsiniz.
Metinden görüntü oluşturma koduna git Aralıklı metin ve resim koduna git
Görüntü düzenleme koduna git Yinelemeli görüntü düzenleme koduna git
|
Görüntülerle çalışmayla ilgili ek seçenekler için diğer kılavuzlara göz atın Görüntüleri analiz etme Cihaz üzerinde görüntüleri analiz etme Yapılandırılmış çıkış oluşturma |
Başlamadan önce
|
Bu sayfada sağlayıcıya özel içerikleri ve kodu görüntülemek için Gemini API sağlayıcınızı tıklayın. |
Henüz yapmadıysanız başlangıç kılavuzunu tamamlayın. Bu kılavuzda Firebase projenizi nasıl ayarlayacağınız, uygulamanızı Firebase'e nasıl bağlayacağınız, SDK'yı nasıl ekleyeceğiniz, seçtiğiniz Gemini API sağlayıcısı için arka uç hizmetini nasıl başlatacağınız ve GenerativeModel örneğini nasıl oluşturacağınız açıklanmaktadır.
İstemlerinizi test etmek ve yinelemek için Google AI Studio kullanmanızı öneririz.
Bu özelliği destekleyen modeller
gemini-3-pro-image(diğer adıyla "Nano Banana Pro")gemini-3.1-flash-image(diğer adıyla "Nano Banana 2")gemini-2.5-flash-image(diğer adıyla "Nano Banana")
Görüntü oluşturma ve düzenleme
Gemini modelini kullanarak görüntü oluşturabilir ve düzenleyebilirsiniz.
Görüntü oluşturma (yalnızca metin girişi)
|
Bu örneği denemeden önce projenizi ve uygulamanızı ayarlamak için bu kılavuzun Başlamadan önce bölümünü tamamlayın.Bu bölümde, seçtiğiniz Gemini API sağlayıcı için bir düğmeyi de tıklayarak bu sayfada sağlayıcıya özel içerikleri görebilirsiniz. |
Gemini modelinden metin istemiyle görüntü oluşturmasını isteyebilirsiniz.
Bir GenerativeModel örneği oluşturduğunuzdan,
model yapılandırmanıza TEXT ve IMAGE yanıt biçimlerini eklediğinizden
(veya yalnızca görüntü çıkışı istiyorsanız TEXT biçimini hariç tuttuğunuzdan)
ve generateContent işlevini çağırdığınızdan emin olun.
Swift
import FirebaseAILogic
// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a Gemini model that supports image output.
let generativeModel = FirebaseAI.firebaseAI(backend: .googleAI()).generativeModel(
modelName: "gemini-3.1-flash-image",
// Configure the model to respond with text and images (required).
generationConfig: GenerationConfig(responseModalities: [.text, .image])
)
// Provide a text prompt instructing the model to generate an image
let prompt = "Generate an image of the Eiffel tower with fireworks in the background."
// To generate an image, call `generateContent` with the text input
let response = try await model.generateContent(prompt)
// Handle the generated image
guard let inlineDataPart = response.inlineDataParts.first else {
fatalError("No image data in response.")
}
guard let uiImage = UIImage(data: inlineDataPart.data) else {
fatalError("Failed to convert data to UIImage.")
}
Kotlin
// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a Gemini model that supports image output.
val model = Firebase.ai(backend = GenerativeBackend.googleAI()).generativeModel(
modelName = "gemini-3.1-flash-image",
// Configure the model to respond with text and images (required)
generationConfig = generationConfig {
responseModalities = listOf(ResponseModality.TEXT, ResponseModality.IMAGE) }
)
// Provide a text prompt instructing the model to generate an image
val prompt = "Generate an image of the Eiffel tower with fireworks in the background."
// To generate image output, call `generateContent` with the text input
val generatedImageAsBitmap = model.generateContent(prompt)
// Handle the generated image
.candidates.first().content.parts.filterIsInstance<ImagePart>().firstOrNull()?.image
Java
// 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-3.1-flash-image",
// Configure the model to respond with text and images (required)
new GenerationConfig.Builder()
.setResponseModalities(Arrays.asList(ResponseModality.TEXT, ResponseModality.IMAGE))
.build()
);
GenerativeModelFutures model = GenerativeModelFutures.from(ai);
// Provide a text prompt instructing the model to generate an image
Content prompt = new Content.Builder()
.addText("Generate an image of the Eiffel Tower with fireworks in the background.")
.build();
// To generate an image, call `generateContent` with the text input
ListenableFuture<GenerateContentResponse> response = model.generateContent(prompt);
Futures.addCallback(response, new FutureCallback<GenerateContentResponse>() {
@Override
public void onSuccess(GenerateContentResponse result) {
// 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, GoogleAIBackend, ResponseModality } from "firebase/ai";
// TODO(developer) Replace the following with your app's Firebase configuration
// See: https://firebase.google.com/docs/web/learn-more#config-object
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-3.1-flash-image",
// Configure the model to respond with text and images (required)
generationConfig: {
responseModalities: [ResponseModality.TEXT, ResponseModality.IMAGE],
},
});
// Provide a text prompt instructing the model to generate an image
const prompt = 'Generate an image of the Eiffel Tower with fireworks in the background.';
// To generate an image, call `generateContent` with the text input
const result = model.generateContent(prompt);
// Handle the generated image
try {
const inlineDataParts = result.response.inlineDataParts();
if (inlineDataParts?.[0]) {
const image = inlineDataParts[0].inlineData;
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';
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a Gemini model that supports image output.
final model = FirebaseAI.googleAI().generativeModel(
model: 'gemini-3.1-flash-image',
// Configure the model to respond with text and images (required).
generationConfig: GenerationConfig(responseModalities: [ResponseModalities.text, ResponseModalities.image]),
);
// Provide a text prompt instructing the model to generate an image
final prompt = [Content.text('Generate an image of the Eiffel Tower with fireworks in the background.')];
// To generate an image, call `generateContent` with the text input
final response = await model.generateContent(prompt);
if (response.inlineDataParts.isNotEmpty) {
final imageBytes = response.inlineDataParts[0].bytes;
// Process the image
} else {
// Handle the case where no images were generated
print('Error: No images were generated.');
}
Unity
using Firebase;
using Firebase.AI;
// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a Gemini model that supports image output.
var model = FirebaseAI.GetInstance(FirebaseAI.Backend.GoogleAI()).GetGenerativeModel(
modelName: "gemini-3.1-flash-image",
// Configure the model to respond with text and images (required).
generationConfig: new GenerationConfig(
responseModalities: new[] { ResponseModality.Text, ResponseModality.Image })
);
// Provide a text prompt instructing the model to generate an image
var prompt = "Generate an image of the Eiffel Tower with fireworks in the background.";
// To generate an image, call `GenerateContentAsync` with the text input
var response = await model.GenerateContentAsync(prompt);
var text = response.Text;
if (!string.IsNullOrWhiteSpace(text)) {
// Do something with the text
}
// 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
}
}
Dönüşümlü olarak resim ve metin üretme
|
Bu örneği denemeden önce projenizi ve uygulamanızı ayarlamak için bu kılavuzun Başlamadan önce bölümünü tamamlayın.Bu bölümde, seçtiğiniz Gemini API sağlayıcı için bir düğmeyi de tıklayarak bu sayfada sağlayıcıya özel içerikleri görebilirsiniz. |
Gemini modelinden, metin yanıtlarıyla birlikte araya yerleştirilmiş resimler oluşturmasını isteyebilirsiniz. Örneğin, oluşturulan bir tarifin her adımının nasıl görünebileceğine dair resimler oluşturabilir ve adımla ilgili talimatları ekleyebilirsiniz. Ayrıca, modele veya farklı modellere ayrı istekler göndermeniz gerekmez.
GenerativeModel örneği oluşturduğunuzdan,
model yapılandırmanıza TEXT ve IMAGE yanıt biçimlerini eklediğinizden,
ve generateContent işlevini çağırdığınızdan emin olun.
Swift
import FirebaseAILogic
// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a Gemini model that supports image output.
let generativeModel = FirebaseAI.firebaseAI(backend: .googleAI()).generativeModel(
modelName: "gemini-3.1-flash-image",
// Configure the model to respond with text and images (required).
generationConfig: GenerationConfig(responseModalities: [.text, .image])
)
// Provide a text prompt instructing the model to generate interleaved text and images
let prompt = """
Generate an illustrated recipe for a paella.
Create images to go alongside the text as you generate the recipe
"""
// To generate interleaved text and images, call `generateContent` with the text input
let response = try await model.generateContent(prompt)
// Handle the generated text and image
guard let candidate = response.candidates.first else {
fatalError("No candidates in response.")
}
for part in candidate.content.parts {
switch part {
case let textPart as TextPart:
// Do something with the generated text
let text = textPart.text
case let inlineDataPart as InlineDataPart:
// Do something with the generated image
guard let uiImage = UIImage(data: inlineDataPart.data) else {
fatalError("Failed to convert data to UIImage.")
}
default:
fatalError("Unsupported part type: \(part)")
}
}
Kotlin
// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a Gemini model that supports image output.
val model = Firebase.ai(backend = GenerativeBackend.googleAI()).generativeModel(
modelName = "gemini-3.1-flash-image",
// Configure the model to respond with text and images (required)
generationConfig = generationConfig {
responseModalities = listOf(ResponseModality.TEXT, ResponseModality.IMAGE) }
)
// Provide a text prompt instructing the model to generate interleaved text and images
val prompt = """
Generate an illustrated recipe for a paella.
Create images to go alongside the text as you generate the recipe
""".trimIndent()
// To generate interleaved text and images, call `generateContent` with the text input
val responseContent = model.generateContent(prompt).candidates.first().content
// The response will contain image and text parts interleaved
for (part in responseContent.parts) {
when (part) {
is ImagePart -> {
// ImagePart as a bitmap
val generatedImageAsBitmap: Bitmap? = part.asImageOrNull()
}
is TextPart -> {
// Text content from the TextPart
val text = part.text
}
}
}
Java
// 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-3.1-flash-image",
// Configure the model to respond with text and images (required)
new GenerationConfig.Builder()
.setResponseModalities(Arrays.asList(ResponseModality.TEXT, ResponseModality.IMAGE))
.build()
);
GenerativeModelFutures model = GenerativeModelFutures.from(ai);
// Provide a text prompt instructing the model to generate interleaved text and images
Content prompt = new Content.Builder()
.addText("Generate an illustrated recipe for a paella.\n" +
"Create images to go alongside the text as you generate the recipe")
.build();
// To generate interleaved text and images, call `generateContent` with the text input
ListenableFuture<GenerateContentResponse> response = model.generateContent(prompt);
Futures.addCallback(response, new FutureCallback<GenerateContentResponse>() {
@Override
public void onSuccess(GenerateContentResponse result) {
Content responseContent = result.getCandidates().get(0).getContent();
// The response will contain image and text parts interleaved
for (Part part : responseContent.getParts()) {
if (part instanceof ImagePart) {
// ImagePart as a bitmap
Bitmap generatedImageAsBitmap = ((ImagePart) part).getImage();
} else if (part instanceof TextPart){
// Text content from the TextPart
String text = ((TextPart) part).getText();
}
}
}
@Override
public void onFailure(Throwable t) {
System.err.println(t);
}
}, executor);
Web
import { initializeApp } from "firebase/app";
import { getAI, getGenerativeModel, GoogleAIBackend, ResponseModality } from "firebase/ai";
// TODO(developer) Replace the following with your app's Firebase configuration
// See: https://firebase.google.com/docs/web/learn-more#config-object
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-3.1-flash-image",
// Configure the model to respond with text and images (required)
generationConfig: {
responseModalities: [ResponseModality.TEXT, ResponseModality.IMAGE],
},
});
// Provide a text prompt instructing the model to generate interleaved text and images
const prompt = 'Generate an illustrated recipe for a paella.\n.' +
'Create images to go alongside the text as you generate the recipe';
// To generate interleaved text and images, call `generateContent` with the text input
const result = await model.generateContent(prompt);
// Handle the generated text and image
try {
const response = result.response;
if (response.candidates?.[0].content?.parts) {
for (const part of response.candidates?.[0].content?.parts) {
if (part.text) {
// Do something with the text
console.log(part.text)
}
if (part.inlineData) {
// Do something with the image
const image = part.inlineData;
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';
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a Gemini model that supports image output.
final model = FirebaseAI.googleAI().generativeModel(
model: 'gemini-3.1-flash-image',
// Configure the model to respond with text and images (required).
generationConfig: GenerationConfig(responseModalities: [ResponseModalities.text, ResponseModalities.image]),
);
// Provide a text prompt instructing the model to generate interleaved text and images
final prompt = [Content.text(
'Generate an illustrated recipe for a paella\n ' +
'Create images to go alongside the text as you generate the recipe'
)];
// To generate interleaved text and images, call `generateContent` with the text input
final response = await model.generateContent(prompt);
// Handle the generated text and image
final parts = response.candidates.firstOrNull?.content.parts
if (parts.isNotEmpty) {
for (final part in parts) {
if (part is TextPart) {
// Do something with text part
final text = part.text
}
if (part is InlineDataPart) {
// Process image
final imageBytes = part.bytes
}
}
} else {
// Handle the case where no images were generated
print('Error: No images were generated.');
}
Unity
using Firebase;
using Firebase.AI;
// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a Gemini model that supports image output.
var model = FirebaseAI.GetInstance(FirebaseAI.Backend.GoogleAI()).GetGenerativeModel(
modelName: "gemini-3.1-flash-image",
// Configure the model to respond with text and images (required).
generationConfig: new GenerationConfig(
responseModalities: new[] { ResponseModality.Text, ResponseModality.Image })
);
// Provide a text prompt instructing the model to generate interleaved text and images
var prompt = "Generate an illustrated recipe for a paella \n" +
"Create images to go alongside the text as you generate the recipe";
// To generate interleaved text and images, call `GenerateContentAsync` with the text input
var response = await model.GenerateContentAsync(prompt);
// Handle the generated text and image
foreach (var part in response.Candidates.First().Content.Parts) {
if (part is ModelContent.TextPart textPart) {
if (!string.IsNullOrWhiteSpace(textPart.Text)) {
// Do something with the text
}
} else if (part is ModelContent.InlineDataPart dataPart) {
if (dataPart.MimeType == "image/png") {
// Load the Image into a Unity Texture2D object
UnityEngine.Texture2D texture2D = new(2, 2);
if (texture2D.LoadImage(dataPart.Data.ToArray())) {
// Do something with the image
}
}
}
}
Resimleri düzenleme (metin ve resim girişi)
|
Bu örneği denemeden önce projenizi ve uygulamanızı ayarlamak için bu kılavuzun Başlamadan önce bölümünü tamamlayın.Bu bölümde, seçtiğiniz Gemini API sağlayıcı için bir düğmeyi de tıklayarak bu sayfada sağlayıcıya özel içerikleri görebilirsiniz. |
Gemini modelinden, metin ve bir veya daha fazla resimle istem girerek resimleri düzenlemesini isteyebilirsiniz.
Bir GenerativeModel örneği oluşturduğunuzdan,
model yapılandırmanıza TEXT ve IMAGE yanıt biçimlerini eklediğinizden
(veya yalnızca görüntü çıkışı istiyorsanız TEXT biçimini hariç tuttuğunuzdan)
ve generateContent işlevini çağırdığınızdan emin olun.
Swift
import FirebaseAILogic
// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a Gemini model that supports image output.
let generativeModel = FirebaseAI.firebaseAI(backend: .googleAI()).generativeModel(
modelName: "gemini-3.1-flash-image",
// Configure the model to respond with text and images (required).
generationConfig: GenerationConfig(responseModalities: [.text, .image])
)
// Provide an image for the model to edit
guard let image = UIImage(named: "scones") else { fatalError("Image file not found.") }
// Provide a text prompt instructing the model to edit the image
let prompt = "Edit this image to make it look like a cartoon"
// To edit the image, call `generateContent` with the image and text input
let response = try await model.generateContent(image, prompt)
// Handle the generated image
guard let inlineDataPart = response.inlineDataParts.first else {
fatalError("No image data in response.")
}
guard let uiImage = UIImage(data: inlineDataPart.data) else {
fatalError("Failed to convert data to UIImage.")
}
Kotlin
// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a Gemini model that supports image output.
val model = Firebase.ai(backend = GenerativeBackend.googleAI()).generativeModel(
modelName = "gemini-3.1-flash-image",
// Configure the model to respond with text and images (required)
generationConfig = generationConfig {
responseModalities = listOf(ResponseModality.TEXT, ResponseModality.IMAGE) }
)
// Provide an image for the model to edit
val bitmap = BitmapFactory.decodeResource(context.resources, R.drawable.scones)
// Provide a text prompt instructing the model to edit the image
val prompt = content {
image(bitmap)
text("Edit this image to make it look like a cartoon")
}
// To edit the image, call `generateContent` with the prompt (image and text input)
val generatedImageAsBitmap = model.generateContent(prompt)
// Handle the generated text and image
.candidates.first().content.parts.filterIsInstance<ImagePart>().firstOrNull()?.image
Java
// 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-3.1-flash-image",
// Configure the model to respond with text and images (required)
new GenerationConfig.Builder()
.setResponseModalities(Arrays.asList(ResponseModality.TEXT, ResponseModality.IMAGE))
.build()
);
GenerativeModelFutures model = GenerativeModelFutures.from(ai);
// Provide an image for the model to edit
Bitmap bitmap = BitmapFactory.decodeResource(resources, R.drawable.scones);
// Provide a text prompt instructing the model to edit the image
Content promptcontent = new Content.Builder()
.addImage(bitmap)
.addText("Edit this image to make it look like a cartoon")
.build();
// To edit the image, call `generateContent` with the prompt (image and text input)
ListenableFuture<GenerateContentResponse> response = model.generateContent(promptcontent);
Futures.addCallback(response, new FutureCallback<GenerateContentResponse>() {
@Override
public void onSuccess(GenerateContentResponse result) {
// 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;
Bitmap generatedImageAsBitmap = imagePart.getImage();
break;
}
}
}
@Override
public void onFailure(Throwable t) {
t.printStackTrace();
}
}, executor);
Web
import { initializeApp } from "firebase/app";
import { getAI, getGenerativeModel, GoogleAIBackend, ResponseModality } from "firebase/ai";
// TODO(developer) Replace the following with your app's Firebase configuration
// See: https://firebase.google.com/docs/web/learn-more#config-object
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-3.1-flash-image",
// Configure the model to respond with text and images (required)
generationConfig: {
responseModalities: [ResponseModality.TEXT, ResponseModality.IMAGE],
},
});
// Prepare an image for the model to edit
async function fileToGenerativePart(file) {
const base64EncodedDataPromise = new Promise((resolve) => {
const reader = new FileReader();
reader.onloadend = () => resolve(reader.result.split(',')[1]);
reader.readAsDataURL(file);
});
return {
inlineData: { data: await base64EncodedDataPromise, mimeType: file.type },
};
}
// Provide a text prompt instructing the model to edit the image
const prompt = "Edit this image to make it look like a cartoon";
const fileInputEl = document.querySelector("input[type=file]");
const imagePart = await fileToGenerativePart(fileInputEl.files[0]);
// To edit the image, call `generateContent` with the image and text input
const result = await model.generateContent([prompt, imagePart]);
// Handle the generated image
try {
const inlineDataParts = result.response.inlineDataParts();
if (inlineDataParts?.[0]) {
const image = inlineDataParts[0].inlineData;
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';
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a Gemini model that supports image output.
final model = FirebaseAI.googleAI().generativeModel(
model: 'gemini-3.1-flash-image',
// Configure the model to respond with text and images (required).
generationConfig: GenerationConfig(responseModalities: [ResponseModalities.text, ResponseModalities.image]),
);
// Prepare an image for the model to edit
final image = await File('scones.jpg').readAsBytes();
final imagePart = InlineDataPart('image/jpeg', image);
// Provide a text prompt instructing the model to edit the image
final prompt = TextPart("Edit this image to make it look like a cartoon");
// To edit the image, call `generateContent` with the image and text input
final response = await model.generateContent([
Content.multi([prompt,imagePart])
]);
// Handle the generated image
if (response.inlineDataParts.isNotEmpty) {
final imageBytes = response.inlineDataParts[0].bytes;
// Process the image
} else {
// Handle the case where no images were generated
print('Error: No images were generated.');
}
Unity
using Firebase;
using Firebase.AI;
// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a Gemini model that supports image output.
var model = FirebaseAI.GetInstance(FirebaseAI.Backend.GoogleAI()).GetGenerativeModel(
modelName: "gemini-3.1-flash-image",
// Configure the model to respond with text and images (required).
generationConfig: new GenerationConfig(
responseModalities: new[] { ResponseModality.Text, ResponseModality.Image })
);
// Prepare an image for the model to edit
var imageFile = System.IO.File.ReadAllBytes(System.IO.Path.Combine(
UnityEngine.Application.streamingAssetsPath, "scones.jpg"));
var image = ModelContent.InlineData("image/jpeg", imageFile);
// Provide a text prompt instructing the model to edit the image
var prompt = ModelContent.Text("Edit this image to make it look like a cartoon.");
// To edit the image, call `GenerateContent` with the image and text input
var response = await model.GenerateContentAsync(new [] { prompt, image });
var text = response.Text;
if (!string.IsNullOrWhiteSpace(text)) {
// Do something with the text
}
// 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
Texture2D texture2D = new Texture2D(2, 2);
if (texture2D.LoadImage(imagePart.Data.ToArray())) {
// Do something with the image
}
}
Çok aşamalı etkileşimli sohbeti kullanarak resimleri yineleme ve düzenleme
|
Bu örneği denemeden önce projenizi ve uygulamanızı ayarlamak için bu kılavuzun Başlamadan önce bölümünü tamamlayın.Bu bölümde, seçtiğiniz Gemini API sağlayıcı için bir düğmeyi de tıklayarak bu sayfada sağlayıcıya özel içerikleri görebilirsiniz. |
Çok aşamalı etkileşimi kullanarak Gemini modelinin oluşturduğu veya sizin sağladığınız resimler üzerinde yineleme yapabilirsiniz.
GenerativeModel örneği oluşturduğunuzdan,
model yapılandırmanıza TEXT ve IMAGE yanıt biçimlerini dahil ettiğinizden
(veya yalnızca resim çıkışı istiyorsanız TEXT biçimini hariç tuttuğunuzdan),
yeni kullanıcı mesajları göndermek için startChat() ve sendMessage() işlevlerini çağırdığınızdan emin olun.
Swift
import FirebaseAILogic
// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a Gemini model that supports image output.
let generativeModel = FirebaseAI.firebaseAI(backend: .googleAI()).generativeModel(
modelName: "gemini-3.1-flash-image",
// Configure the model to respond with text and images (required).
generationConfig: GenerationConfig(responseModalities: [.text, .image])
)
// Initialize the chat
let chat = model.startChat()
guard let image = UIImage(named: "scones") else { fatalError("Image file not found.") }
// Provide an initial text prompt instructing the model to edit the image
let prompt = "Edit this image to make it look like a cartoon"
// To generate an initial response, send a user message with the image and text prompt
let response = try await chat.sendMessage(image, prompt)
// Inspect the generated image
guard let inlineDataPart = response.inlineDataParts.first else {
fatalError("No image data in response.")
}
guard let uiImage = UIImage(data: inlineDataPart.data) else {
fatalError("Failed to convert data to UIImage.")
}
// Follow up requests do not need to specify the image again
let followUpResponse = try await chat.sendMessage("But make it old-school line drawing style")
// Inspect the edited image after the follow up request
guard let followUpInlineDataPart = followUpResponse.inlineDataParts.first else {
fatalError("No image data in response.")
}
guard let followUpUIImage = UIImage(data: followUpInlineDataPart.data) else {
fatalError("Failed to convert data to UIImage.")
}
Kotlin
// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a Gemini model that supports image output.
val model = Firebase.ai(backend = GenerativeBackend.googleAI()).generativeModel(
modelName = "gemini-3.1-flash-image",
// Configure the model to respond with text and images (required)
generationConfig = generationConfig {
responseModalities = listOf(ResponseModality.TEXT, ResponseModality.IMAGE) }
)
// Provide an image for the model to edit
val bitmap = BitmapFactory.decodeResource(context.resources, R.drawable.scones)
// Create the initial prompt instructing the model to edit the image
val prompt = content {
image(bitmap)
text("Edit this image to make it look like a cartoon")
}
// Initialize the chat
val chat = model.startChat()
// To generate an initial response, send a user message with the image and text prompt
var response = chat.sendMessage(prompt)
// Inspect the returned image
var generatedImageAsBitmap = response
.candidates.first().content.parts.filterIsInstance<ImagePart>().firstOrNull()?.image
// Follow up requests do not need to specify the image again
response = chat.sendMessage("But make it old-school line drawing style")
generatedImageAsBitmap = response
.candidates.first().content.parts.filterIsInstance<ImagePart>().firstOrNull()?.image
Java
// 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-3.1-flash-image",
// Configure the model to respond with text and images (required)
new GenerationConfig.Builder()
.setResponseModalities(Arrays.asList(ResponseModality.TEXT, ResponseModality.IMAGE))
.build()
);
GenerativeModelFutures model = GenerativeModelFutures.from(ai);
// Provide an image for the model to edit
Bitmap bitmap = BitmapFactory.decodeResource(resources, R.drawable.scones);
// Initialize the chat
ChatFutures chat = model.startChat();
// Create the initial prompt instructing the model to edit the image
Content prompt = new Content.Builder()
.setRole("user")
.addImage(bitmap)
.addText("Edit this image to make it look like a cartoon")
.build();
// To generate an initial response, send a user message with the image and text prompt
ListenableFuture<GenerateContentResponse> response = chat.sendMessage(prompt);
// Extract the image from the initial response
ListenableFuture<@Nullable Bitmap> initialRequest = Futures.transform(response, result -> {
for (Part part : result.getCandidates().get(0).getContent().getParts()) {
if (part instanceof ImagePart) {
ImagePart imagePart = (ImagePart) part;
return imagePart.getImage();
}
}
return null;
}, executor);
// Follow up requests do not need to specify the image again
ListenableFuture<GenerateContentResponse> modelResponseFuture = Futures.transformAsync(
initialRequest,
generatedImage -> {
Content followUpPrompt = new Content.Builder()
.addText("But make it old-school line drawing style")
.build();
return chat.sendMessage(followUpPrompt);
},
executor);
// Add a final callback to check the reworked image
Futures.addCallback(modelResponseFuture, new FutureCallback<GenerateContentResponse>() {
@Override
public void onSuccess(GenerateContentResponse result) {
for (Part part : result.getCandidates().get(0).getContent().getParts()) {
if (part instanceof ImagePart) {
ImagePart imagePart = (ImagePart) part;
Bitmap generatedImageAsBitmap = imagePart.getImage();
break;
}
}
}
@Override
public void onFailure(Throwable t) {
t.printStackTrace();
}
}, executor);
Web
import { initializeApp } from "firebase/app";
import { getAI, getGenerativeModel, GoogleAIBackend, ResponseModality } from "firebase/ai";
// TODO(developer) Replace the following with your app's Firebase configuration
// See: https://firebase.google.com/docs/web/learn-more#config-object
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-3.1-flash-image",
// Configure the model to respond with text and images (required)
generationConfig: {
responseModalities: [ResponseModality.TEXT, ResponseModality.IMAGE],
},
});
// Prepare an image for the model to edit
async function fileToGenerativePart(file) {
const base64EncodedDataPromise = new Promise((resolve) => {
const reader = new FileReader();
reader.onloadend = () => resolve(reader.result.split(',')[1]);
reader.readAsDataURL(file);
});
return {
inlineData: { data: await base64EncodedDataPromise, mimeType: file.type },
};
}
const fileInputEl = document.querySelector("input[type=file]");
const imagePart = await fileToGenerativePart(fileInputEl.files[0]);
// Provide an initial text prompt instructing the model to edit the image
const prompt = "Edit this image to make it look like a cartoon";
// Initialize the chat
const chat = model.startChat();
// To generate an initial response, send a user message with the image and text prompt
const result = await chat.sendMessage([prompt, imagePart]);
// Request and inspect the generated image
try {
const inlineDataParts = result.response.inlineDataParts();
if (inlineDataParts?.[0]) {
// Inspect the generated image
const image = inlineDataParts[0].inlineData;
console.log(image.mimeType, image.data);
}
} catch (err) {
console.error('Prompt or candidate was blocked:', err);
}
// Follow up requests do not need to specify the image again
const followUpResult = await chat.sendMessage("But make it old-school line drawing style");
// Request and inspect the returned image
try {
const followUpInlineDataParts = followUpResult.response.inlineDataParts();
if (followUpInlineDataParts?.[0]) {
// Inspect the generated image
const followUpImage = followUpInlineDataParts[0].inlineData;
console.log(followUpImage.mimeType, followUpImage.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';
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a Gemini model that supports image output.
final model = FirebaseAI.googleAI().generativeModel(
model: 'gemini-3.1-flash-image',
// Configure the model to respond with text and images (required).
generationConfig: GenerationConfig(responseModalities: [ResponseModalities.text, ResponseModalities.image]),
);
// Prepare an image for the model to edit
final image = await File('scones.jpg').readAsBytes();
final imagePart = InlineDataPart('image/jpeg', image);
// Provide an initial text prompt instructing the model to edit the image
final prompt = TextPart("Edit this image to make it look like a cartoon");
// Initialize the chat
final chat = model.startChat();
// To generate an initial response, send a user message with the image and text prompt
final response = await chat.sendMessage([
Content.multi([prompt,imagePart])
]);
// Inspect the returned image
if (response.inlineDataParts.isNotEmpty) {
final imageBytes = response.inlineDataParts[0].bytes;
// Process the image
} else {
// Handle the case where no images were generated
print('Error: No images were generated.');
}
// Follow up requests do not need to specify the image again
final followUpResponse = await chat.sendMessage([
Content.text("But make it old-school line drawing style")
]);
// Inspect the returned image
if (followUpResponse.inlineDataParts.isNotEmpty) {
final followUpImageBytes = response.inlineDataParts[0].bytes;
// Process the image
} else {
// Handle the case where no images were generated
print('Error: No images were generated.');
}
Unity
using Firebase;
using Firebase.AI;
// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a Gemini model that supports image output.
var model = FirebaseAI.GetInstance(FirebaseAI.Backend.GoogleAI()).GetGenerativeModel(
modelName: "gemini-3.1-flash-image",
// Configure the model to respond with text and images (required).
generationConfig: new GenerationConfig(
responseModalities: new[] { ResponseModality.Text, ResponseModality.Image })
);
// Prepare an image for the model to edit
var imageFile = System.IO.File.ReadAllBytes(System.IO.Path.Combine(
UnityEngine.Application.streamingAssetsPath, "scones.jpg"));
var image = ModelContent.InlineData("image/jpeg", imageFile);
// Provide an initial text prompt instructing the model to edit the image
var prompt = ModelContent.Text("Edit this image to make it look like a cartoon.");
// Initialize the chat
var chat = model.StartChat();
// To generate an initial response, send a user message with the image and text prompt
var response = await chat.SendMessageAsync(new [] { prompt, image });
// Inspect the returned image
var imageParts = response.Candidates.First().Content.Parts
.OfType<ModelContent.InlineDataPart>()
.Where(part => part.MimeType == "image/png");
// Load the image into a Unity Texture2D object
UnityEngine.Texture2D texture2D = new(2, 2);
if (texture2D.LoadImage(imageParts.First().Data.ToArray())) {
// Do something with the image
}
// Follow up requests do not need to specify the image again
var followUpResponse = await chat.SendMessageAsync("But make it old-school line drawing style");
// Inspect the returned image
var followUpImageParts = followUpResponse.Candidates.First().Content.Parts
.OfType<ModelContent.InlineDataPart>()
.Where(part => part.MimeType == "image/png");
// Load the image into a Unity Texture2D object
UnityEngine.Texture2D followUpTexture2D = new(2, 2);
if (followUpTexture2D.LoadImage(followUpImageParts.First().Data.ToArray())) {
// Do something with the image
}
Referans resimler sağlama
Gemini Görüntü modelleri, isteminize referans görseller eklemenize olanak tanır. Bu görüntüler şunları içerebilir:
Gemini 3.x Pro Image (
gemini-3-pro-image, diğer adıyla "Nano Banana Pro")- Son resme eklenecek, yüksek çözünürlüklü en fazla 6 nesne resmi
- Karakter tutarlılığını korumak için en fazla 5 karakter resmi
- Stil referansı olarak kullanılacak en fazla 3 resim
Gemini 3.x Flash Image (
gemini-3.1-flash-image, diğer adıyla "Nano Banana 2"):- Son resme eklenecek, yüksek çözünürlüklü en fazla 10 nesne resmi
- Karakter tutarlılığını korumak için en fazla 4 karakter resmi
Gemini 2.5 Flash Image (
gemini-2.5-flash-image, diğer adıyla "Nano Banana"):- En fazla 3 resim
Görüntü üretme özelliğini yapılandırma
Gemini Görüntü modelleri varsayılan olarak 1.024 x 1.024 çözünürlükte kare görüntüler
(1:1 en boy oranı) oluşturur. Oluşturulan resimlerinizin çıkışını generationConfig içindeki imageConfig özelliğini kullanarak özelleştirebilirsiniz.
Örneğin, çıkış resmini 16:9 en boy oranına ve 2K çözünürlüğe (2752x1536 boyutunda bir resim) sahip olacak şekilde yapılandırabilirsiniz:
Swift
// ...
let imageConfig = ImageConfig(aspectRatio: .landscape16x9, imageSize: .size2K)
let generationConfig = GenerationConfig(
responseModalities: [.text, .image],
imageConfig: imageConfig
)
// Make sure you initialize your chosen Gemini API backend service
let model = FirebaseAI.firebaseAI().generativeModel(
modelName: "gemini-3.1-flash-image",
generationConfig: generationConfig
)
// ...
Kotlin
// ...
val config = generationConfig {
responseModalities = listOf(ResponseModality.TEXT, ResponseModality.IMAGE)
imageConfig = imageConfig {
aspectRatio = AspectRatio.LANDSCAPE_16x9
imageSize = ImageSize.SIZE_2K
}
}
// Make sure you initialize your chosen Gemini API backend service
val model = Firebase.ai.generativeModel(
modelName = "gemini-3.1-flash-image",
generationConfig = config
)
// ...
Java
// ...
GenerationConfig config = new GenerationConfig.Builder()
.setResponseModalities(Arrays.asList(ResponseModality.TEXT, ResponseModality.IMAGE))
.setImageConfig(
ImageConfig.builder()
.setAspectRatio(AspectRatio.LANDSCAPE_16x9)
.setImageSize(ImageSize.SIZE_2K)
.build()
)
.build();
// Make sure you initialize your chosen Gemini API backend service
GenerativeModel model = FirebaseAI.getInstance().generativeModel(
"gemini-3.1-flash-image",
config
);
// ...
Web
// ...
const generationConfig = {
responseModalities: [ResponseModality.TEXT, ResponseModality.IMAGE],
imageConfig: {
aspectRatio: "16:9",
imageSize: "2K"
}
};
// Make sure you initialize your chosen Gemini API backend service
const model = getGenerativeModel(ai, {
model: "gemini-3.1-flash-image",
generationConfig
});
// ...
Dart
// ...
final generationConfig = GenerationConfig(
responseModalities: [ResponseModalities.text, ResponseModalities.image],
imageConfig: ImageConfig(
aspectRatio: ImageAspectRatio.landscape16x9,
imageSize: ImageSize.size2K,
),
);
// Make sure you initialize your chosen Gemini API backend service
final model = FirebaseAI.instance.generativeModel(
model: 'gemini-3.1-flash-image,
generationConfig: generationConfig,
);
// ...
Unity
// ...
var generationConfig = new GenerationConfig(
responseModalities: new[] { ResponseModality.Text, ResponseModality.Image },
imageConfig: new ImageConfig(
aspectRatio: ImageConfig.AspectRatio.Landscape16x9,
imageSize: ImageConfig.ImageSize.Size2K)
);
// Make sure you initialize your chosen Gemini API backend service
var model = FirebaseAI.GetInstance().GetGenerativeModel(
modelName: "gemini-3.1-flash-image",
generationConfig: generationConfig
);
// ...
Desteklenen en boy oranları
Tüm Gemini görüntü oluşturma modelleri aşağıdaki en boy oranlarını destekler:
Varsayılan: 1:1 (kare)
1:1, 1:4, 1:8, 2:3, 3:2, 3:4, 4:1, 4:3, 4:5, 5:4, 8:1,
9:16, 16:9, 21:9
Desteklenen resim boyutları (çözünürlükler)
Desteklenen resim boyutları (çözünürlükler), kullandığınız modele bağlıdır.
| Gemini Resim modeli | Desteklenen boyutlar (çözünürlükler) |
|---|---|
Gemini 3.x Pro Imagegemini-3-pro-image("Nano Banana Pro") |
Varsayılan: 1K (1024)1K (1024), 2K (2048), 4K (4096)
|
Gemini 3.x Flash Imagegemini-3.1-flash-image("Nano Banana 2") |
Varsayılan: 1K (1024)512, 1K (1024), 2K (2048), 4K (4096)
|
Gemini 2.5 Flash Imagegemini-2.5-flash-image("Nano Banana") |
1K (1024) sürümünde düzeltildi
|
Büyük harf K son eki (ör. 1K, 2K, 4K) kullanmanız gerekir.
512 değerinde K son eki kullanılmaz.
Küçük harfli k soneki (örneğin, 1k) reddedilir.
Desteklenen özellikler
Aşağıdakiler, desteklenen özelliklerdir (ör. yöntemler, araçlar, giriş ve diller).
Her model için desteklenen en boy oranları ve çözünürlükler hakkında bilgi edinmek için bu kılavuzun önceki bölümlerinde yer alan Resim oluşturmayı yapılandırma başlıklı makaleyi inceleyin.
Desteklenen yöntemler
GeminiGörüntü modelleri için aşağıdaki "modaliteler" desteklenir. Bu "modaliteler", isteklerinizde açıkça ayarlanmaz. Bunlar, yaygın kullanım alanları için önerilen kalıplara daha çok benzer. Bu listedeki her modalite için bir örnek istem gösterilir ve bu kılavuzun önceki bölümlerinde örnek kod örnekleri yer alır.
Metin Resimler (yalnızca metinden resme)
- Arka planda havai fişeklerin patladığı Eyfel Kulesi'nin resmini oluştur.
Metin Resimler (resim içinde metin oluşturma)
- Büyük bir binanın ön cephesine yansıtılmış bu devasa metnin yer aldığı sinematik bir fotoğraf oluştur.
Metin Resimler ve Metin (aralıklı)
Paella için resimli bir tarif oluştur. Yemek tarifini oluştururken metnin yanı sıra görseller de oluşturun.
3D çizgi film animasyonu tarzında bir köpek hikayesi oluştur. Her sahne için bir resim oluşturun.
Görseller ve Metin Görseller ve Metin (aralıklı)
- [image of a furnished room] + What other color sofas would work in my space? Resmi güncelleyebilir misin?
Görüntü düzenleme (metin ve resimden resme)
[İngiliz çöreklerinin resmi] + Bu resmi çizgi film gibi görünecek şekilde düzenle
[kedi resmi] + [yastık resmi] + Bu yastıkta kedimin kanaviçe resmini oluştur.
Çok aşamalı etkileşimli görüntü düzenleme (sohbet)
- [Mavi bir arabanın resmi] + Bu arabayı üstü açılır arabaya dönüştür., ardından Şimdi rengini sarı olarak değiştir.
Desteklenen araçlar
Aşağıdakiler için destek:
Gemini 3.x Pro Image (
gemini-3-pro-image, diğer adıyla "Nano Banana Pro")Gemini 3.x Flash Image (
gemini-3.1-flash-image, diğer adıyla "Nano Banana 2")
Desteklenen diğer özellikler
Desteklenen çok formatlı giriş:
Resim girişi: Tüm Gemini görüntü modelleri.
Video girişi: Yalnızca Gemini 3.x Flash Image (
gemini-3.1-flash-image, diğer adıyla "Nano Banana 2")Ses girişi: Gemini Resim modellerinin hiçbiri.
Tüm Gemini görüntü modelleri aşağıdakileri destekler:
- PNG resimler oluşturuluyor.
- İnsanların resimlerini oluşturma ve düzenleme
- Esnek ve daha az kısıtlayıcı bir kullanıcı deneyimi sağlayan güvenlik filtreleri kullanma.
Yapılandırılmış çıkış (ör. JSON) oluşturma desteği:
- Gemini 3.x Pro Image
(
gemini-3-pro-image, diğer adıyla "Nano Banana Pro")
- Gemini 3.x Pro Image
(
Desteklenen diller
Gemini Görüntü modelleri 35'ten fazla dili desteklese de bu bölümde listelenen dillerde en iyi performansı elde edersiniz.
Metin istemi için desteklenen diller:
- Gemini 3.x Image modelleri:
ar-EG,de-DE,EN,es-MX,fr-FR,hi-IN,id-ID,it-IT,ja-JP,ko-KR,pt-BR,ru-RU,ua-UA,vi-VN,zh-CN - Gemini 2.5 Flash Image modeli:
EN,es-MX,ja-JP,zh-CN,hi-IN.
- Gemini 3.x Image modelleri:
Oluşturulan resimdeki metin için desteklenen diller:
- Gemini 3.x Image modelleri: Yukarıdaki listede yer alan diller
- Gemini 2.5 Flash Image modeli: yalnızca İngilizce
Üretilen bir görüntüde belirli bir dili kullanmak için (dil kodu olmadan bile) isteminizde modele sormanız yeterlidir (örneğin, "Bu infografiği İspanyolca olarak güncelle. Resmin başka hiçbir öğesini değiştirmeyin.").
En iyi uygulamalar
Aşağıda, Gemini görüntü modelleriyle ilgili en iyi uygulamalar verilmiştir.
Metin içeren bir resim üretirken önce metni, ardından bu metni içeren bir resim üretin.
Görüntü üretme özelliği her zaman tetiklenmeyebilir. Ayrıca, resim veya metin oluşturma şu durumlarda beklendiği gibi çalışmayabilir:
Model yalnızca metin oluşturabilir ve görüntü oluşturmayabilir (özellikle istem belirsizse). Bu durumda
FinishReason,NO_IMAGEolur.
Görüntü çıkışlarını açıkça istemeyi deneyin. Örneğin, "resim oluştur", "ilerledikçe resim sağla", "resmi güncelle".Model, oluşturma işlemini yarıda durdurabilir.
Tekrar deneyin veya farklı bir istem kullanın.Model, metni resim olarak oluşturabilir.
Metin çıkışlarını açıkça istemeyi deneyin. Örneğin, "generate narrative text along with illustrations" (anlatı metni ve resimler oluştur).İstem güvenli değilse model, isteği işlemeyebilir ve bunun yerine güvenli olmayan resimler oluşturamayacağını belirten bir yanıt döndürebilir. Bu durumda
FinishReasonSTOPolur.