Skip to content

Guide · Agent skill

How to use the ML Kit GenAI Prompt API agent skill

Updated · written with AI from the project's own documentation and checked against our catalogue data

This guide explains how to install and use the ml-kit-genai-prompt-api agent skill, which helps an AI coding agent add on-device generative AI to an Android app with Google's ML Kit GenAI Prompt API. It is written for Android developers who may never have used agent skills before. By the end you will know what the skill does, how to install it, how to phrase requests so it triggers, and what your project needs before it is useful.

ML Kit GenAI Prompt APIandroid/skills · Apache-2.0

Quick start

  1. 1Download and unzip. Download the skill ZIP from this page and unzip it into ~/.claude/skills/ for personal use, or into your project's .claude/skills/ folder.
  2. 2Check your project. Confirm minSdk is 26 or higher and that the build uses com.google.mlkit:genai-prompt at 1.0.0-beta4 or later.
  3. 3Make your request. Describe the task in plain language, such as refactoring a prompt to return structured output, and name the file involved.
  4. 4Review the changes. Read the edits the agent proposes, especially dependency versions, lifecycle calls and availability checks.
  5. 5Test on a supported device. Run the app on a device that can run Gemini Nano, and confirm the model reports AVAILABLE before inference.

What is an agent skill and what does this one do?

An agent skill is a folder of instructions and reference files that an AI agent loads when a task matches the skill's description. This skill's main file, SKILL.md, is a step-by-step guide for integrating and optimizing the ML Kit GenAI Prompt API in Android apps.

With the skill installed, the agent can analyze an Android codebase and help you send natural language requests on-device to Gemini Nano. It covers setup, checking that the model is available, releasing resources, refactoring free-text prompts to return typed structured data, prompt optimization, and prefix caching for long prompts.

  • Checks minSdk and dependency versions, and updates them when they are too low
  • Verifies the model's FeatureStatus is AVAILABLE before inference
  • Calls close() on ML Kit instances when an Activity, Fragment, or ViewModel is destroyed
  • Refactors String-returning prompt code to return @Generable typed objects
  • Advises on prompt design and prefix caching for prompts over 200 words

Install the skill from the ZIP file

Download the ZIP for this skill from this page, then unzip it. The skill folder must end up in one of two places. For a skill available to all your projects, put it in ~/.claude/skills/. For a skill used only in one project, put it in that project's .claude/skills/ folder.

If you use the Claude apps instead, you can upload the skill under Settings → Capabilities → Skills.

  • Personal install: ~/.claude/skills/
  • Project install: .claude/skills/ inside your project
  • Claude apps: Settings → Capabilities → Skills, then upload

Set up your Android project before you ask for code

The skill assumes your project meets a few requirements. Check these first so the agent's changes compile and run.

The app must target Android API level 26 or higher. Add the ML Kit GenAI Prompt API dependency to the app-level build.gradle file at version 1.0.0-beta4 or later. If you use structured output, the optional com.google.mlkit:genai-schema-compiler dependency needs the KSP plugin at 2.3.6 or later. The device running the app must be able to run Gemini Nano.

  • minSdk 26 or higher
  • com.google.mlkit:genai-prompt at 1.0.0-beta4 or later
  • Optional: com.google.mlkit:genai-schema-compiler with KSP plugin 2.3.6 or later
  • A device capable of running Gemini Nano
implementation("com.google.mlkit:genai-prompt:1.0.0-beta4")

How do you trigger the skill with a natural request?

You do not need a special command. Describe the task in plain language inside your Android project, and mention the kind of work you want. The skill's description covers requests to send natural language requests on-device to Gemini Nano, use structured output with Prompt API, implement prefix caching, optimize the current prompt, or apply best practices.

Point the agent at the code you want changed. Specific requests produce better results than general ones.

  • "Refactor parseEmail in EmailParser.kt to return a typed object using the Prompt API structured output."
  • "Add prefix caching to the summary prompt in SummaryViewModel, since it is over 200 words."
  • "Check that Gemini Nano is available before the first inference in my chat screen."
  • "Review my Gemini Nano calls and make sure I release the client when the ViewModel is cleared."

Work through the common tasks

Structured output replaces a free-text String result with a typed class. You mark a data class with @Generable, describe each field with @Guide, and call generateTypedContentRequest. The skill checks isStructuredOutputFeatureAvailable() before using this path.

Prefix caching stores reusable intermediate model state for a shared prompt prefix. Separate the static prefix from the dynamic suffix in your request. The skill's notes say prefix caching is experimental, supports text-only input, and runs only on a subset of devices, so do not use it when your prompt includes an image.

What safety and network points should you know?

This skill does not run scripts. It does use the network, so the agent may fetch the reference guides it links to while it works. Review any changes the agent makes to build.gradle, dependency versions and release logic before you commit them, as with any code change.

The guidance assumes on-device availability. It gives no fallback for devices that cannot run Gemini Nano, so your app needs its own handling for that case.

  • Runs scripts: no
  • Uses network: yes
  • Apps must handle devices where Gemini Nano is unavailable

What people use it for

  • Adding an on-device email summary or parsing feature to an Android app without a cloud model
  • Converting existing Gemini Nano prompt code that returns raw text into typed, structured results
  • Reducing latency for a long, repeated system prompt using prefix caching on text-only requests
  • Reviewing a ViewModel or Activity to confirm the ML Kit client is closed when it is destroyed

Frequently asked questions

How do I install the ml-kit-genai-prompt-api skill?

Download the ZIP from this page and unzip it into ~/.claude/skills/ for personal use or into a project's .claude/skills/ folder. In the Claude apps, you can instead upload it under Settings → Capabilities → Skills.

What are the requirements for this skill?

Your Android project needs minSdk 26 or higher and the com.google.mlkit:genai-prompt dependency at 1.0.0-beta4 or later. Structured output also uses the optional genai-schema-compiler with KSP plugin 2.3.6 or later, and the test device must be able to run Gemini Nano.

Is the ML Kit GenAI Prompt API free to use?

The source material for this skill does not state pricing or licence terms for the API itself. The skill is published under Apache-2.0 as listed on this page, and its SKILL.md points to a LICENSE.txt file for complete terms.

Does this skill work for iOS or web projects?

No. The guidance is specific to ML Kit on Android, so it is the wrong tool for web or iOS work.

Why does the skill need the model to be AVAILABLE?

The model must be fully downloaded and available before the first inference. The skill has the agent check that the FeatureStatus is AVAILABLE before making a request.

What should I do if the device cannot run Gemini Nano?

The skill assumes on-device availability and gives no fallback. You need to add your own handling in the app for devices where Gemini Nano cannot run.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

This skill suits Android developers who want an agent to add or refactor on-device Gemini Nano features with ML Kit, including typed structured output and caching guidance. Pick something else for non-Android projects, for apps that need cloud-hosted large models, or for targets where Gemini Nano cannot run and you need a built-in fallback.

Download the skill