ml-kit-genai-prompt-api

Integrates ML Kit Prompt API for on-device Gemini Nano inference in Android applications.

9.3k|601|Updated Mar 16, 2026
Ready to run
npx skills add https://github.com/android/skills --skill ml-kit-genai-prompt-api-android
💬 Prompt for ChatGPT / Claude Chat▼
Please help me install this Agent Skill.
Skill: ml-kit-genai-prompt-api
Source: https://github.com/android/skills/tree/main/device-ai/ml-kit-genai-prompt-api
Command: npx skills add https://github.com/android/skills --skill ml-kit-genai-prompt-api-android

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? This Skill eliminates the need for manual integration of on-device AI features in Android apps by providing optimized prompts and structured outputs for Gemini Nano. ## Core Features & Use Cases - Prompt Optimization: Refine prompts for better model performance. - Prefix Caching: Reduce inference latency for repeated prompts. - Structured Output: Parse responses into typed Kotlin objects. - Use Case: Extract structured data from emails or classify sentiments on-device. ## Quick Start Add the ML Kit GenAI Prompt API dependency to your build.gradle file and initialize a GenerativeModel instance.

Frequently Asked Questions about ml-kit-genai-prompt-api

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I integrate the ML Kit Prompt API in an Android app?▼

Add the com.google.mlkit:genai-prompt dependency to your build.gradle file, check the model status, and initialize a GenerativeModel instance.

What is structured output in the Prompt API?▼

It allows returning typed Kotlin objects from model responses using @Generable annotations instead of raw strings.

How does prefix caching improve inference speed?▼

It stores intermediate LLM states for shared prompt prefixes to reduce repeated processing time.

What Android version is required for the Prompt API?▼

Android API level 26 or higher is required for the ML Kit GenAI Prompt API.

Can I use system instructions with the Prompt API?▼

Yes, system instructions can be provided in GenerateContentRequest for setting personas or constraints.