Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a40a3d6
refactor: AI-generated refactor
thatfiredev Mar 6, 2026
67c2297
tiny refactor
thatfiredev Mar 6, 2026
f427e15
More viewmodels!!
thatfiredev Mar 6, 2026
17f4787
refactor: move svg logic to SvgViewModel
thatfiredev Mar 6, 2026
0089209
refactor: move bidi logic to BidiViewModel
thatfiredev Mar 6, 2026
da990ca
to each their own
thatfiredev Mar 6, 2026
1b82d24
refactor: imagen viewmodels!!!
thatfiredev Mar 6, 2026
6fee4fc
Server Prompt Templates
thatfiredev Mar 6, 2026
a98f710
remove LegacyChatViewModel
thatfiredev Mar 6, 2026
c6fd26e
simplify Sample class
thatfiredev Mar 6, 2026
7667057
TextGenScreen --> ServerPromptScreen
thatfiredev Mar 6, 2026
b325f9b
move screens to ui package
thatfiredev Mar 6, 2026
07e417e
refactor: simplify navigation
thatfiredev Mar 6, 2026
78ef880
Move CameraView to ui
thatfiredev Mar 6, 2026
3acff0c
undo InvalidImportDetectorTest.kt changes
thatfiredev Mar 6, 2026
d48cf76
yeet sampleId
thatfiredev Mar 6, 2026
d19f87d
Update README.md
thatfiredev Mar 6, 2026
404f2bc
Update README.md
thatfiredev Mar 6, 2026
fac0e9e
fix the chat loading behavior
thatfiredev Mar 6, 2026
39ed6de
2 separate bidi routes
thatfiredev Mar 6, 2026
32ee7e2
fix lint errors
thatfiredev Mar 6, 2026
20616e5
always specify the GenerativeBackend
thatfiredev Mar 6, 2026
cf7339c
tiny improvements
thatfiredev Mar 6, 2026
9b8e91f
safe cast viewmodel
thatfiredev Mar 6, 2026
2c5ae5a
Apply suggestions from code review
thatfiredev Mar 12, 2026
9a346f9
nullability check for city, state and date
thatfiredev Mar 12, 2026
6663274
address reviewer comments
thatfiredev Mar 13, 2026
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
70 changes: 53 additions & 17 deletions firebase-ai/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,68 @@

This Android sample app demonstrates how to use state-of-the-art
generative AI models (like Gemini) to build AI-powered features and applications.

For more information about Firebase AI Logic, visit the [documentation](http://firebase.google.com/docs/ai-logic).

## Setup & Configuration

### Prerequisites
* **Google AI (Gemini) API Key**: Most samples work out of the box with the Google AI SDK.
* **Vertex AI**: Samples marked with *(Vertex AI)* require you to enable the Vertex AI API in your Google Cloud project and have your files in Cloud Storage.
* **Server Prompt Templates**: These samples require you to set up templates in the [Firebase Console](https://console.firebase.google.com/project/_/ai-logic).

## Getting Started

To try out this sample app, you need to use latest stable version of Android Studio.
However, if you want to latest lint checks and AI productivity features in Android
Studio use the latest preview version of [Android Studio](https://developer.android.com/studio/preview).

* [Set up your Android app for Firebase][setup-android]
* Use the package name `com.google.firebase.quickstart.ai`
* [Set up Firebase AI Logic][setup-ai-logic]
* Run the app on an Android device or emulator.

## Features

There are 2 main files that demonstrate the use of Firebase AI Logic:

- [ChatViewModel.kt](app/src/main/java/com/google/firebase/quickstart/ai/feature/text/ChatViewModel.kt)
which can do things such as:
- [Generate Text](https://firebase.google.com/docs/ai-logic/generate-text)
- [Generate structured output (JSON)](https://firebase.google.com/docs/ai-logic/generate-structured-output)
- [Analyze images](https://firebase.google.com/docs/ai-logic/analyze-images)
- [Analyze video](https://firebase.google.com/docs/ai-logic/analyze-video)
- [Analyze audio](https://firebase.google.com/docs/ai-logic/analyze-audio)
- [Analyze documents (PDFs)](https://firebase.google.com/docs/ai-logic/analyze-documents)
- [Generate images using Gemini 2.0](https://firebase.google.com/docs/ai-logic/generate-images-imagen)
- [Function calling](https://firebase.google.com/docs/ai-logic/function-calling)
- [ImagenViewModel](app/src/main/java/com/google/firebase/quickstart/ai/feature/media/imagen/ImagenViewModel.kt)
which shows how to [Generate images using Imagen models](https://firebase.google.com/docs/ai-logic/generate-images-imagen)
You can find the implementation for each feature by clicking on the links below:

### Text / Chat
- [Travel tips](app/src/main/java/com/google/firebase/quickstart/ai/feature/text/TravelTipsViewModel.kt): The user wants the model to help a new traveler with travel tips
- [Chatbot recommendations for courses](app/src/main/java/com/google/firebase/quickstart/ai/feature/text/CourseRecommendationsViewModel.kt): A chatbot suggests courses for a performing arts program.
- [Weather Chat](app/src/main/java/com/google/firebase/quickstart/ai/feature/text/WeatherChatViewModel.kt): Use function calling to get the weather conditions for a specific US city on a specific date.
- [Grounding with Google Search](app/src/main/java/com/google/firebase/quickstart/ai/feature/text/GoogleSearchGroundingViewModel.kt): Use Grounding with Google Search to get responses based on up-to-date information from the web.
- [Thinking](app/src/main/java/com/google/firebase/quickstart/ai/feature/text/ThinkingChatViewModel.kt): Gemini 2.5 Flash with dynamic thinking
- [Server Prompt Templates - Gemini](app/src/main/java/com/google/firebase/quickstart/ai/feature/text/ServerPromptTemplateViewModel.kt): Generate an invoice using server prompt templates.

### Image analysis / generation
- [Imagen 4 - image generation](app/src/main/java/com/google/firebase/quickstart/ai/feature/media/imagen/ImagenGenerationViewModel.kt): Generate images using Imagen 4
- [Imagen 3 - Inpainting (Vertex AI)](app/src/main/java/com/google/firebase/quickstart/ai/feature/media/imagen/ImagenInpaintingViewModel.kt): Replace part of an image using Imagen 3
- [Imagen 3 - Outpainting (Vertex AI)](app/src/main/java/com/google/firebase/quickstart/ai/feature/media/imagen/ImagenOutpaintingViewModel.kt): Expand an image by drawing in more background
- [Imagen 3 - Subject Reference (Vertex AI)](app/src/main/java/com/google/firebase/quickstart/ai/feature/media/imagen/ImagenSubjectReferenceViewModel.kt): Generate an image using a referenced subject (must be an animal)
- [Imagen 3 - Style Transfer (Vertex AI)](app/src/main/java/com/google/firebase/quickstart/ai/feature/media/imagen/ImagenStyleTransferViewModel.kt): Change the art style of a cat picture using a reference
- [Gemini 2.5 Flash Image (aka nanobanana)](app/src/main/java/com/google/firebase/quickstart/ai/feature/text/ImageGenerationViewModel.kt): Generate and/or edit images using Gemini 2.5 Flash Image aka nanobanana
- [Server Prompt Template - Imagen](app/src/main/java/com/google/firebase/quickstart/ai/feature/media/imagen/ImagenTemplateViewModel.kt): Generate an image using a server prompt template.
- [SVG Generator](app/src/main/java/com/google/firebase/quickstart/ai/feature/text/SvgViewModel.kt): Use Gemini 3 Flash preview to create SVG illustrations
- [Blog post creator (Vertex AI)](app/src/main/java/com/google/firebase/quickstart/ai/feature/text/ImageBlogCreatorViewModel.kt): Create a blog post from an image file stored in Cloud Storage.

### Audio analysis
- [Audio Summarization](app/src/main/java/com/google/firebase/quickstart/ai/feature/text/AudioSummarizationViewModel.kt): Summarize an audio file
- [Translation from audio (Vertex AI)](app/src/main/java/com/google/firebase/quickstart/ai/feature/text/AudioTranslationViewModel.kt): Translate an audio file stored in Cloud Storage

### Video analysis
- [Hashtags for a video (Vertex AI)](app/src/main/java/com/google/firebase/quickstart/ai/feature/text/VideoHashtagGeneratorViewModel.kt): Generate hashtags for a video ad stored in Cloud Storage
- [Summarize video](app/src/main/java/com/google/firebase/quickstart/ai/feature/text/VideoSummarizationViewModel.kt): Summarize a video and extract important dialogue.

### Live API (Real-time bidrectional streaming)
- [ForecastTalk](app/src/main/java/com/google/firebase/quickstart/ai/feature/live/StreamAudioViewModel.kt): Use bidirectional streaming to get information about weather conditions
- [Gemini Live (Video input)](app/src/main/java/com/google/firebase/quickstart/ai/feature/live/StreamVideoViewModel.kt): Use bidirectional streaming to chat with Gemini using your phone's camera

### Document (PDFs) analysis
- [Document comparison (Vertex AI)](app/src/main/java/com/google/firebase/quickstart/ai/feature/text/DocumentComparisonViewModel.kt): Compare the contents of 2 documents in Cloud Storage.


## All samples

The full list of available samples can be found in the
[FirebaseAISamples.kt file](app/src/main/java/com/google/firebase/quickstart/ai/FirebaseAISamples.kt).
[FirebaseAISamples.kt file](app/src/main/java/com/google/firebase/quickstart/ai/ui/navigation/FirebaseAISamples.kt).

[setup-android]: https://firebase.google.com/docs/android/setup
[setup-ai-logic]: https://firebase.google.com/docs/ai-logic/get-started?api=dev#set-up-firebase
Loading
Loading