On this page
Building on-device generative features used to mean bundling a model, managing GPU delegates and tuning prompts yourself. ML Kit GenAI packages common tasks as high-level APIs on top of Gemini Nano, which Android's AICore service manages. You call a client, check availability, and get results without network or per-request fees.
At the time of writing, Google lists Summarization, Proofreading, Rewriting, Image Description and Prompt as beta, and Speech Recognition as alpha. Beta APIs can change and have no SLA, and device support is limited to specific models. Always check the official pages for current details.
The APIs
| API | Input โ output | Typical feature |
|---|---|---|
| Summarization | Article or conversation โ 1โ3 bullet points | "Summarise this note/chat" |
| Proofreading | Short text โ corrected text | Fix typos before sending |
| Rewriting | Short text โ restyled versions (e.g. shorter, friendlier, more professional) | Tone adjustment in a composer |
| Image Description | Bitmap โ short description | Alt text, accessibility |
| Speech Recognition | Audio โ text | Dictation, voice notes |
| Prompt | Custom text or image prompt โ generated text | Classification, extraction, custom short tasks |
The shared lifecycle
Example: Rewriting
// implementation("com.google.mlkit:genai-rewriting:<version>")
class ToneRewriter(context: Context) : AutoCloseable {
private val shorten = Rewriting.getClient(
RewriterOptions.builder(context)
.setOutputType(RewriterOptions.OutputType.SHORTEN)
.setLanguage(RewriterOptions.Language.ENGLISH)
.build()
)
suspend fun isReady(): Boolean = shorten.checkFeatureStatus().await() == FeatureStatus.AVAILABLE
/** Returns up to a few suggestions; the user picks one. */
suspend fun shorter(text: String): List<String> =
shorten.runInference(RewritingRequest.builder(text).build()).await()
.results.map { it.text }
override fun close() = shorten.close()
}Example: Proofreading
// implementation("com.google.mlkit:genai-proofreading:<version>")
val proofreader = Proofreading.getClient(
ProofreaderOptions.builder(context)
.setInputType(ProofreaderOptions.InputType.KEYBOARD) // typed text (vs. VOICE)
.setLanguage(ProofreaderOptions.Language.ENGLISH)
.build()
)
suspend fun fix(text: String): String? =
proofreader.runInference(ProofreadingRequest.builder(text).build()).await()
.results.firstOrNull()?.textExample: Image Description
// implementation("com.google.mlkit:genai-image-description:<version>")
val describer = ImageDescription.getClient(ImageDescriberOptions.builder(context).build())
suspend fun altText(bitmap: Bitmap): String =
describer.runInference(ImageDescriptionRequest.builder(bitmap).build()).await().descriptionTask API or Prompt API?
- Task APIs (summarise, proofread, rewrite, describe) come with tuned prompts and quality evaluation by Google. Prefer them whenever your feature matches.
- Prompt API gives flexibility for custom tasks such as classifying a message, extracting fields or generating short labels. You own prompt quality and evaluation, and outputs can vary by Gemini Nano version.
Constraints to design around
- Device support is limited. Check status before showing UI, and provide a fallback or hide the feature.
- Foreground only: background inference is blocked.
- Quotas: per-app inference quota (
BUSY) and battery-use quotas. - Input limits and languages vary per API. Summarisation, for example, documents roughly 4,000 input tokens and a small set of languages.
Real-world uses
Messaging
Proofread and rewrite in the composer. Private messages never leave the phone.
Notes and email
Summaries of long notes or threads, offered only on supported devices.
Accessibility
Auto-generated alt text drafts for user-uploaded images, editable before saving.
Common mistakes
- Showing AI buttons without checking feature status.
- Running inference automatically on every keystroke and hitting quotas.
- Applying suggestions automatically without letting the user review them.
- Forgetting
close(), which leaks resources.
Frequently asked questions
Do ML Kit GenAI APIs cost money?
There's no per-request fee, because inference runs on the device. Your costs are engineering effort and the user's device resources.
Can I use them on the emulator?
Generally not, since Gemini Nano requires supported physical devices. Test on the devices listed in the documentation.
What about unsupported devices?
Hide the feature, or offer a cloud alternative with user consent. See Cloud AI vs On-Device AI.
Conclusion
ML Kit GenAI offers private, on-device generative features with a consistent lifecycle: get a client, check status, download, run inference, close. Prefer the task APIs where they fit, use the Prompt API for custom tasks, and design for limited device support, foreground-only use and quotas.
Next step: build a complete feature with these APIs in How to Build an AI Writing Assistant for Android.
Official references
๐ฑ Apps built by Yunok Tech
Real Android apps on Google Play, free to download.
Walzi4K wallpapers for lock and home screenGet it โธ
NotiVaultNotification history: recover dismissed notificationsGet it โธ
Ready to build real Android applications?
Every AI feature still runs inside an Android app that has to be fast, reliable and well structured. Strengthen the Kotlin, Jetpack Compose and architecture skills that AI integrations depend on, then apply these AI concepts with confidence.
Move beyond theory and strengthen your Android development skills with Yunoktech's Android course. Learn core concepts, practical implementation, modern Android development techniques, and the reasoning behind building maintainable applications.
Explore the Android course and take your next step as an Android developer.