The recent updates from Google regarding the Gemini Nano APIs through the ML Kit present an exciting opportunity for developers looking to incorporate generative AI capabilities into their Android applications. With the introduction of the new GenAI APIs, developers can now perform on-device inference, meaning that all operations—input, processing, and output—are executed locally on the device. This innovative approach not only enhances user privacy but also eliminates the costs typically associated with cloud processing.
Developers can harness a variety of features through the GenAI APIs, including:
- Summarization: This feature can condense articles of up to 3,000 English words into succinct formats.
- Proofreading: It refines text for grammatical accuracy and maintains style consistency.
- Rewriting: Users can rewrite text in different tones or styles, such as formal, casual, or friendly.
- Image Description: This function generates brief descriptions for images, thereby improving accessibility.
For those eager to implement the Summarization API, a practical Java snippet is available:
val articleToSummarize = ...
val summarizerOptions = SummarizerOptions.builder(context)
.setInputType(InputType.ARTICLE)
.setOutputType(OutputType.ONE_BULLET)
.setLanguage(Language.ENGLISH)
.build()
val summarizer = Summarization.getClient(summarizerOptions)
val summarizationRequest = SummarizationRequest.builder(text).build()
summarizer.runInference(summarizationRequest) { newText ->
// Show new text in UI
}
Device Compatibility and Performance
The ML Kit GenAI APIs are optimized for a range of Android devices, particularly those utilizing MediaTek Dimensity, Qualcomm Snapdragon, and Google Tensor platforms. Notable supported devices include the Pixel 9 series and Samsung Galaxy S25, among others. This compatibility broadens the application of the GenAI APIs beyond Google’s own hardware, promoting wider adoption across the Android ecosystem.
Designed for efficiency, the GenAI APIs operate on-device without requiring internet connectivity. This ensures a seamless user experience with rapid response times, as processing does not depend on external servers. Developers can anticipate significant performance improvements for tasks such as summarization, proofreading, and rewriting compared to the base Gemini Nano model. The APIs are engineered to deliver high-quality results right out of the box, reducing the need for extensive prompt engineering.
Privacy and Security
A standout feature of the GenAI APIs is their enhanced privacy. By processing data locally on the device, developers can provide users with the assurance that their sensitive information remains secure. This is especially pertinent for applications that handle personal data, such as email and text communications. The ML Kit incorporates various safety protocols, including classifiers and evaluations, to safeguard the integrity of the data being processed.