Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion samples/gemini-chatbot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Here is the key snippet of code that calls the generative model:

```kotlin
private val generativeModel by lazy {
Firebase.ai(backend = GenerativeBackend.googleAI()).generativeModel("gemini-3-pro-image-preview")
Firebase.ai(backend = GenerativeBackend.googleAI()).generativeModel("gemini-2.5-flash")
}
private val chat = generativeModel.startChat()

Expand Down
27 changes: 25 additions & 2 deletions samples/gemini-image-chat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,38 @@ This sample is part of the [AI Sample Catalog](../../). To build and run this sa

## Description

This sample demonstrates a chat bot using `Gemini 2.5 Flash Image` (a.k.a [Nano Banana](https://developers.googleblog.com/en/introducing-gemini-2-5-flash-image/)) that can understand both text and images and generate images and text in return. Users can send a message that includes an image, and the generative model will respond based on the multimodal input. This showcases how to build powerful, interactive image generation chat experiences with the Gemini API.
This sample demonstrates a chat bot using `Gemini 3 Pro Image` (a.k.a [Nano Banana Pro](https://deepmind.google/models/gemini-image/pro/)) that can understand both text and images and generate images and text in return. Users can send a message that includes an image, and the generative model will respond based on the multimodal input. This showcases how to build powerful, interactive image generation chat experiences with the Gemini API.
Comment thread
lethargicpanda marked this conversation as resolved.

<div style="text-align: center;">
<img width="320" alt="Gemini Image chat in action" src="android_nano_banana.png" />
</div>

## How it works

The application uses the Firebase AI SDK (see [How to run](../../#how-to-run)) for Android to interact with the `Gemini 2.5 Flash Image` model. The core logic is in the `GeminiImageChatViewModel.kt` file. When a user sends a message with an image, a `content` block is created that includes both the text and the `Bitmap` of the image. This multimodal content is then sent to the model.
The application uses the Firebase AI SDK (see [How to run](../../#how-to-run)) for Android to interact with the `Gemini 3 Pro Image` model. The core logic is in the `GeminiImageChatViewModel.kt` file. When a user sends a message with an image, a `content` block is created that includes both the text and the `Bitmap` of the image. This multimodal content is then sent to the model.

Here is how the model is instantiated:
```kotlin
Firebase.ai(backend = GenerativeBackend.googleAI()).generativeModel(
"gemini-3-pro-image-preview",
generationConfig = generationConfig {
temperature = 0.9f
topK = 32
topP = 1f
maxOutputTokens = 4096
responseModalities = listOf(ResponseModality.TEXT, ResponseModality.IMAGE)
},
safetySettings = listOf(
SafetySetting(HarmCategory.HARASSMENT, HarmBlockThreshold.MEDIUM_AND_ABOVE),
SafetySetting(HarmCategory.HATE_SPEECH, HarmBlockThreshold.MEDIUM_AND_ABOVE),
SafetySetting(HarmCategory.SEXUALLY_EXPLICIT, HarmBlockThreshold.MEDIUM_AND_ABOVE),
SafetySetting(HarmCategory.DANGEROUS_CONTENT, HarmBlockThreshold.MEDIUM_AND_ABOVE),
),
systemInstruction = content {
text("""You are a friendly assistant. Keep your responses short.""")
},
)
```

Here is the key snippet of code that calls the generative model:

Expand Down
Loading