Experimental Hybrid Inference for Android and New Gemini Models
Key point
Hybrid inference combining on-device and cloud, along with new Gemini models, has been released in Firebase AI Logic.
Details
A new API for hybrid inference has been added to Firebase AI Logic, allowing Android apps to handle on-device and cloud inference in a single flow.
This implementation currently uses rule-based routing, and apps can run Gemini Nano locally or switch to a Gemini model in the cloud. On-device execution uses the ML Kit Prompt API, while cloud inference supports all Gemini models from Vertex AI and the Developer API.
To use it, you need to add the firebase-ai-ondevice dependency along with firebase-ai. During initialization, you pass OnDeviceConfig into GenerativeModel; for example, setting it to PREFER_ON_DEVICE prioritizes Gemini Nano on the device and falls back to the cloud when it's unavailable. Conversely, PREFER_IN_CLOUD prioritizes the cloud and falls back to on-device inference when offline.
This feature is currently experimental, and the on-device model has the following limitations:
- Focused on single-turn text generation
- Supports text input or a single Bitmap image input
- Features not yet available should be checked in the separate limitations documentation
A new sample utilizing this hybrid inference has also been added to the AI Sample Catalog. It demonstrates a flow that generates reviews on a few topics and then translates them into multiple languages.
Two new image generation models have been introduced:
- Nano Banana Pro (Gemini 3 Pro Image): Designed for professional asset creation, with strengths in high-precision text rendering, including specific fonts or handwriting.
- Nano Banana 2 (Gemini 3.1 Flash Image): A model built for high-speed, high-volume processing, suitable for tasks like infographics, virtual stickers, and contextual illustrations.
Both models leverage real-world knowledge and deep reasoning to generate more accurate and detailed images. As an example, the Magic Selfie sample has been changed so that the image generation model directly handles background separation as well, resulting in a simpler implementation.
Finally, Gemini 3.1 Flash-Lite has also been released. While retaining the advantages of the Flash-Lite line that Android developers have preferred, it supports more advanced use cases with latency close to that of Gemini 2.5 Flash-Lite. It can be checked out right away in the Firebase AI Logic SDK and documentation.
This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.
Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.