Vertex AI Gemini API  |  Android Developers Skip to main content Essentials Build AI experiences Build AI-powered Android apps with Gemini APIs and more. Get started Get started Create your first app. Use Compose for UI and adaptive app development to support multiple device form factors. Hello, world! Developer Verification Adaptive apps Compose for UI AI-powered IDE Training Monetization with Play ↗️ Optimize by form factor Build apps that optimize the user experience on phones, tablets, foldables, cars, XR, and more. Phones, tablets, foldables Android for Cars Android TV Android XR Googlebook ChromeOS Wear OS Build by category Learn to build for your use case by following Google's prescriptive and opinionated guidance. Games Camera & media Social & messaging Health & fitness Productivity Enterprise apps Get the latest Stay in touch with the latest releases throughout the year, join our preview programs, and give us your feedback. Latest updates Experimental updates Android Studio preview Jetpack & Compose libraries Wear OS releases Privacy Sandbox ↗️ Design & Plan Excellent Experiences Build the best experiences for your best users. Learn more UI Design Design a beautiful user interface using Android best practices. Design for Android Mobile Desktop experiences XR Headsets & XR Glasses AI Glasses Widgets Wear OS Android TV Android for Cars Architecture Design robust, testable, and maintainable app logic and services. Introduction Libraries Navigation Modularization Testing Kotlin Multiplatform Quality Plan for app quality and align with Play store guidelines. Overview Core value User experience Accessibility Technical quality Excellent Experiences Security Safeguard users against threats and ensure a secure Android experience. Overview Privacy Permissions Identity Fraud prevention Develop Gemini in Android Studio Your AI development companion for Android development. Learn more Get Android Studio Core areas Get the samples and docs for the features you need. Samples Multidevice support User interfaces Background work Data and files Connectivity All core areas ⤵️ Tools and workflow Use the IDE to write and build your app, or create your own pipeline. Write and debug code Build projects Test your app Performance Command-line tools Gradle plugin API Android Bench Device tech Write code for form factors. Connect devices and share data. Phones, tablets, foldables ChromeOS Android for Cars Android TV Android XR Wear OS Android Health Better Together All devices ⤵️ Libraries Browse API reference documentation with all the details. Android platform Jetpack libraries Compose libraries Google Play services ↗️ Google Play SDK index ↗️ Google Play Play Console Publish your app or game and grow your business on Google Play. Go to Play Console Learn more ↗️ Fundamentals Learn how to engage users, monitize, and secure your app. Play Monetization Play Integrity Play Policies Play Programs ↗️ Games Dev Center Develop and deliver games. Get tools, downloads, and samples. Overview Play Asset Delivery Play Games Services Play Games on PC Level Up guidelines All Play guides ⤵️ Libraries Browse API reference documentation with all the details. Play Feature Delivery Play In-app Updates Play In-app Reviews Play Install Referrer Google Play services ↗️ Google Play SDK index ↗️ All Play libraries ⤵️ Tools & resources Tools for publishing, promoting, and managing your app. Android App Bundles Brand & marketing Play Console APIs ↗️ Blog the Android Developer's Blog Read the latest Explore the authors → Explore categories Case Studies Real-world results from real-world users. Explore how different teams use our tools to achieve their goals. Events & Programs Get the details on upcoming webinars, workshops, meetups, and special initiatives designed to help you grow. Product News Stay in the loop with the latest updates, feature releases, and behind-the-scenes looks at how we’re evolving. Community Discover stories from our users, spotlight features, and the collaborative projects that bring us all together. How-tos From quick tips to deep-dive tutorials, these step-by-step guides are designed to help you work smarter and faster. / English Deutsch Español – América Latina Français Indonesia Italiano Polski Português – Brasil Tiếng Việt Türkçe Русский עברית العربيّة فارسی हिंदी বাংলা ภาษาไทย 中文 – 简体 中文 – 繁體 日本語 한국어 Android Studio Sign in AI Overview Samples Guides Reference Essentials More Design & Plan More Develop More Overview Samples Guides Reference Google Play More Blog More Android Studio Generative AI on Android Overview Gemini Nano Gemini Pro & Gemini Flash Overview Gemini Developer API Gemini Live API Vertex AI Gemini API Hybrid inference Agentic AI AppFunctions Overview Add AppFunctions to your app Computer Control ADK agents Machine learning LiteRT ML Kit ⍈ Build AI experiences Get started Get started Hello, world! Developer Verification Adaptive apps Compose for UI AI-powered IDE Training Monetization with Play ↗️ Optimize by form factor Phones, tablets, foldables Android for Cars Android TV Android XR Googlebook ChromeOS Wear OS Build by category Games Camera & media Social & messaging Health & fitness Productivity Enterprise apps Get the latest Latest updates Experimental updates Android Studio preview Jetpack & Compose libraries Wear OS releases Privacy Sandbox ↗️ Excellent Experiences Learn more UI Design Design for Android Mobile Desktop experiences XR Headsets & XR Glasses AI Glasses Widgets Wear OS Android TV Android for Cars Architecture Introduction Libraries Navigation Modularization Testing Kotlin Multiplatform Quality Overview Core value User experience Accessibility Technical quality Excellent Experiences Security Overview Privacy Permissions Identity Fraud prevention Gemini in Android Studio Learn more Get Android Studio Core areas Samples Multidevice support User interfaces Background work Data and files Connectivity All core areas ⤵️ Tools and workflow Write and debug code Build projects Test your app Performance Command-line tools Gradle plugin API Android Bench Device tech Phones, tablets, foldables ChromeOS Android for Cars Android TV Android XR Wear OS Android Health Better Together All devices ⤵️ Libraries Android platform Jetpack libraries Compose libraries Google Play services ↗️ Google Play SDK index ↗️ Play Console Go to Play Console Learn more ↗️ Fundamentals Play Monetization Play Integrity Play Policies Play Programs ↗️ Games Dev Center Overview Play Asset Delivery Play Games Services Play Games on PC Level Up guidelines All Play guides ⤵️ Libraries Play Feature Delivery Play In-app Updates Play In-app Reviews Play Install Referrer Google Play services ↗️ Google Play SDK index ↗️ All Play libraries ⤵️ Tools & resources Android App Bundles Brand & marketing Play Console APIs ↗️ the Android Developer's Blog Read the latest Explore the authors → Explore categories Case Studies Events & Programs Product News Community How-tos Android Developers Develop AI Guides Send feedback Vertex AI Gemini API Stay organized with collections Save and categorize content based on your preferences. If you're new to the Gemini API, the Gemini Developer API is the recommended API provider for Android Developers. But if you have specific data location requirements or you are already embedded in the Vertex AI or Google Cloud environment, you can use the Vertex AI Gemini API. Getting started Before you interact with the Vertex AI Gemini API directly from your app, you can experiment with prompts in Vertex AI Studio. Set up a Firebase project and connect your app to Firebase Once you're ready to call the API from your app, follow the instructions in "Step 1" of the Firebase AI Logic getting started guide to set up Firebase and enable required APIs and services. Add the Gradle dependencies Add the following Gradle dependencies to your app module: Kotlin dependencies { // ... other androidx dependencies // Import the BoM for the Firebase platform implementation(platform("com.google.firebase:firebase-bom:34.16.0")) // Add the dependencies for the Firebase AI Logic and App Check libraries // When using the BoM, you don't specify versions in Firebase library dependencies implementation("com.google.firebase:firebase-ai") implementation("com.google.firebase:firebase-appcheck-debug") } Java dependencies { // Import the BoM for the Firebase platform implementation(platform("com.google.firebase:34.16.0")) // Add the dependencies for the Firebase AI Logic and App Check libraries // When using the BoM, you don't specify versions in Firebase library dependencies implementation("com.google.firebase:firebase-ai") implementation("com.google.firebase:firebase-appcheck-debug") // Required for one-shot operations (to use `ListenableFuture` from Guava Android) implementation("com.google.guava:guava:31.0.1-android") // Required for streaming operations (to use `Publisher` from Reactive Streams) implementation("org.reactivestreams:reactive-streams:1.0.4") } Configure the App Check debug provider for local development Starting early July 2026, as part of the guided setup workflow for AI Logic in the Firebase console, Firebase App Check is automatically enforced to protect the Gemini API. For local development, you need to configure the App Check debug provider to bypass attestation while still maintaining the enforcement of App Check. In your debug build, configure App Check to use the debug provider factory: Kotlin Firebase.initialize(context = this) Firebase.appCheck.installAppCheckProviderFactory( DebugAppCheckProviderFactory.getInstance(), ) Java FirebaseApp.initializeApp(/*context=*/ this); FirebaseAppCheck firebaseAppCheck = FirebaseAppCheck.getInstance(); firebaseAppCheck.installAppCheckProviderFactory( DebugAppCheckProviderFactory.getInstance()); Obtain your debug token: Run your app in the emulator or on your test device. Look for the App Check debug token in your logs. For example: D DebugAppCheckProvider: Enter this debug secret into the allow list in the Firebase Console for your project: 123a4567-b89c-12d3-e456-789012345678 Copy the token (for example, 123a4567-b89c-12d3-e456-789012345678). Register your debug token with App Check: In the Firebase console, go to the Security > App Check > Apps tab. Find your app, click the overflow menu (more_vert), and then select Manage debug tokens. Follow the on-screen instructions to register your debug token. For details about the debug provider (including how to get a new debug token), check out the official App Check docs. Here are some critical points about the App Check debug provider: Keep your debug token and debug build private. Don't commit your debug token to a public repository, and don't ship your debug token or debug build in production builds of your app. Register your app with a production attestation provider before releasing to end users. You'll need to register your app with a production App Check attestation provider (for example, Play Integrity) so that your end-users can use your feature with App Check enforced. Initialize the generative model Start by instantiating a GenerativeModel and specifying the model name: Kotlin val model = Firebase.ai(backend = GenerativeBackend.vertexAI()) .generativeModel("gemini-2.5-flash") VertexAiGeminiApi.kt Java GenerativeModel firebaseAI = FirebaseAI.getInstance(GenerativeBackend.vertexAI()) .generativeModel("gemini-2.5-flash"); GenerativeModelFutures model = GenerativeModelFutures.from(firebaseAI); VertexAiGeminiApiJava.java In the Firebase documentation, you can learn more about the available Gemini models. You can also learn about configuring model parameters. Generate text To generate a text response, call generateContent() with your prompt. Kotlin suspend fun generateText(model: GenerativeModel) { // Note: generateContent() is a suspend function, which integrates well // with existing Kotlin code. val response = model.generateContent("Write a story about a magic backpack.") // ... } VertexAiGeminiApi.kt Java Content prompt = new Content.Builder() .addText("Write a story about a magic backpack.") .build(); ListenableFuture<GenerateContentResponse> response = model.generateContent(prompt); Futures.addCallback(response, new FutureCallback<GenerateContentResponse>() { @Override public void onSuccess(GenerateContentResponse result) { String resultText = result.getText(); // ... } @Override public void onFailure(Throwable t) { t.printStackTrace(); } }, executor); VertexAiGeminiApiJava.java Similar to the Gemini Developer API, you can also pass images, audio, video, and files with your text prompt. For details, see Interact with the Gemini Developer API from your app. To learn more about Firebase AI Logic SDK, read the Firebase documentation. Send feedback Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates. Last updated 2026-07-15 UTC. Need to tell us more? [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-07-15 UTC."],[],[]] X Follow @AndroidDev on X YouTube Check out Android Developers on YouTube LinkedIn Connect with the Android Developers community on LinkedIn More Android Android Android for Enterprise Security Source News Blog Podcasts Discover Gaming Machine Learning Health & Fitness Camera & Media Privacy 5G Android Devices Large screens Wear OS ChromeOS devices Android for cars Android TV Releases Android 17 Android 16 Android 15 Android 14 Android 13 Android 12 Android 11 Documentation and Downloads Android Studio guide Developers guides API reference Download Studio Android NDK Support Report platform bug Report documentation bug Google Play support Join research studies Android Chrome Firebase Google Cloud Platform All products Privacy License Brand guidelines Manage cookies Get news and tips by email Subscribe English Deutsch Español – América Latina Français Indonesia Italiano Polski Português – Brasil Tiếng Việt Türkçe Русский עברית العربيّة فارسی हिंदी বাংলা ภาษาไทย 中文 – 简体 中文 – 繁體 日本語 한국어