Overview of the ML Kit GenAI APIs

ML Kit's GenAI APIs harness the power of Gemini Nano to help your apps perform on-device generative AI tasks. These APIs are built on top of AICore, an Android system service that manages on-device foundation models and accelerates inference while keeping user data private.

The ML Kit GenAI API Additional Terms of Service apply to the use of the GenAI APIs. Developers are solely responsible for the safety of their API client and their app's user experience.

Key capabilities

ML Kit organizes its GenAI capabilities into the following categories:

Custom generation and agents

Work directly with the Gemini Nano foundation model for custom prompting and autonomous agentic workflows:

  • Direct model access (using the GenerativeModel class): Generate text or typed structured output from custom text-only or multimodal prompts, or manage your own multi-turn chat history directly by using a List<Content> object with USER and MODEL roles and a sessionId value, and manage tool declarations directly.
  • Agentic workflows (using the AgentRunner class): Built on top of the GenerativeModel class, automating multi-turn session management (including in-memory conversation history) and multi-step tool-calling loops.

Speech and audio

Transcribe, translate, and synthesize speech audio on-device:

Text and image tasks

Use task-specific APIs optimized for common vision, writing, and search tasks without prompt engineering:

  • Image description: Generate a short description of a given image.
  • Summarization: Summarize articles or chat conversations as a bulleted list.
  • Proofreading: Polish short content by refining grammar and fixing spelling errors.
  • Rewriting: Rewrite short messages in different tones or styles.
  • Embeddings: Generate vector embeddings for text and images using the Embeddings API and pair them with AndroidX AppSearch to find content by meaning.

Benefits of GenAI APIs

Similar to other existing ML Kit features, GenAI APIs run entirely on-device and thus provide the following benefits:

  • Input, inference, and output data is processed locally
  • Functionality remains the same without reliable internet connection
  • No additional server cost incurred for each API call

In addition, since GenAI APIs are built on top of AICore and powered by Gemini Nano, apps and task-specific APIs share the same underlying Gemini Nano base model on the device. This avoids waiting for a separate model to be downloaded if Gemini Nano already exists on a device, and in turn conserves storage space. Learn more about how AICore isolates requests to protect privacy.

Streaming versus non-streaming

ML Kit GenAI APIs offer both streaming and non-streaming options for receiving results. The streaming API delivers responses incrementally as they are generated, providing a continuous flow of data. In contrast, the non-streaming API waits until the entire response is complete before returning it as a single block.

Choose the streaming API for lengthy responses, as it allows for quicker initial feedback. The non-streaming API is more suitable for short responses or when processing results in batches.

Device support

Device support for custom generation and agents and text and image task APIs is described in the following sections. For any features that aren't listed in this section, see the individual feature pages for device support information.

Custom generation and agent device support

Direct model access and agentic workflows are supported on the following devices:

nano-v2

  • Honor: Magic V5, Magic 7, Magic 7 Pro
  • iQOO: iQOO 13
  • Motorola: Razr 60 Ultra, Razr Ultra 2025
  • OnePlus: OnePlus 13, OnePlus 13s
  • OPPO: Find N5
  • POCO: POCO F7 Ultra, POCO F8 Pro, POCO F8 Ultra, POCO X7 Pro, POCO X8 Pro
  • realme: realme GT 7 Pro
  • Samsung: Galaxy Z Fold7, Galaxy Z TriFold
  • vivo: vivo X200 FE, vivo T4 Ultra
  • Xiaomi: Xiaomi 14T Pro, Xiaomi 15, Xiaomi 15T, Xiaomi 15T Pro, Xiaomi 15 Ultra, Xiaomi 17, Xiaomi 17 Ultra, Xiaomi Pad Mini

nano-v3

  • Google: Pixel 10, Pixel 10 Pro, Pixel 10 Pro XL, Pixel 10 Pro Fold, Pixel 9, Pixel 9 Pro, Pixel 9 Pro XL, Pixel 9 Pro Fold
  • Honor: Honor Magic 8 Pro
  • iQOO: iQOO 15
  • Lenovo: Lenovo Idea Tab Pro Gen 2, Lenovo Legion Tab Gen 5(8.8")
  • Motorola: Signature
  • OnePlus: OnePlus 15, OnePlus 15R
  • OPPO: Find X9, Find X9 Pro, Find X8, Find X8 Pro, Reno 14 Pro 5G, Reno 15 Pro 5G, Reno 15 Pro Mini 5G, Reno 15 Pro Max 5G
  • realme: realme GT 7T
  • Samsung: Galaxy S26, Galaxy S26+, Galaxy S26 Ultra
  • Sharp: AQUOS R11
  • Sony: Xperia 1 VIII
  • vivo: vivo X200T, vivo X200, vivo X200 Pro, vivo X300, vivo X300 Pro

nano-v4

  • Google: Pixel 11, Pixel 11 Pro, Pixel 11 Pro XL, Pixel 11 Pro Fold
  • Samsung: Galaxy Z Flip8, Galaxy Z Fold8, Galaxy Z Fold8 Ultra

Text and image task device support

The Image Description, Summarization, Proofreading, and Rewriting APIs are available on the following devices, with plans to expand support to additional devices:

  • Google: Pixel 11, Pixel 11 Pro, Pixel 11 Pro XL, Pixel 11 Pro Fold, Pixel 10, Pixel 10 Pro, Pixel 10 Pro XL, Pixel 10 Pro Fold, Pixel 9, Pixel 9 Pro, Pixel 9 Pro XL, Pixel 9 Pro Fold
  • Honor: Honor 400 Pro, Magic 7, Magic 7 Pro, Magic 8 Pro, Magic V5
  • iQOO: iQOO 13, iQOO 15
  • Lenovo: Lenovo Idea Tab Pro Gen 2, Lenovo Legion Tab Gen 5(8.8")
  • Motorola: Razr 60 Ultra, Razr Ultra 2025, Signature
  • OnePlus: OnePlus 15, OnePlus 15R, OnePlus 13, OnePlus 13s
  • OPPO: Find N5, Find X9, Find X9 Pro, Find X8, Find X8 Pro, Reno 14 Pro 5G, Reno 15 Pro 5G, Reno 15 Pro Mini 5G, Reno 15 Pro Max 5G
  • POCO: POCO F7 Ultra, POCO F8 Pro, POCO F8 Ultra, POCO X7 Pro, POCO X8 Pro
  • realme: realme GT 7 Pro, realme GT 7T
  • Samsung: Galaxy S25, Galaxy S25+, Galaxy S25 Ultra, Galaxy S26, Galaxy S26+, Galaxy S26 Ultra, Galaxy Z Flip8, Galaxy Z Fold8, Galaxy Z Fold8 Ultra, Galaxy Z Fold7, Galaxy Z TriFold
  • Sharp: AQUOS R11
  • Sony: Xperia 1 VIII
  • vivo: vivo X200T, vivo X200 FE, vivo X200, vivo X200 Pro, vivo X300, X300 Pro, vivo X Fold3 Pro, vivo X Fold5, vivo T4 Ultra
  • Xiaomi: Xiaomi 14T Pro, Xiaomi 15, Xiaomi 15T, Xiaomi 15T Pro, Xiaomi 15 Ultra, Xiaomi 17, Xiaomi 17 Ultra, Xiaomi Pad Mini

Availability of specific language support may vary depending on the particular device's configuration and the models that have been downloaded to the device.

Retrieve Gemini Nano version

Different versions of Gemini Nano run on different devices. To return the version of Gemini Nano on a device, use the getBaseModelName() method.

Quota per application

AICore enforces an inference quota per app. Making too many GenAI API requests in a short period will result in an ErrorCode.BUSY response. When receiving such an error, consider using exponential backoff to retry the request. Also, ErrorCode.PER_APP_BATTERY_USE_QUOTA_EXCEEDED can be returned if an app exceeds a long-duration quota (for example, a daily quota).

Background usage

GenAI API inference is permitted only when the app is the top foreground application. Using the API when the app is not in the foreground, including using a foreground service, will result in an ErrorCode.BACKGROUND_USE_BLOCKED response.

Sample code

To get this code, check out the following samples: