Getting Started
Run Gemini Nano on Android, on the device, with the Vercel AI SDK. The provider wraps Google’s ML Kit GenAI libraries directly. Android serves the models through AICore, so there’s no model to bundle and no API key.
| Feature | Model | ML Kit API |
|---|---|---|
| Text generation | android() |
genai-prompt |
| Tool calling | android(), on Gemini Nano 4 |
genai-prompt |
| Embeddings | android.embeddingModel() |
genai-embedding |
| Transcription | android.transcriptionModel() |
genai-speech-recognition |
Installation
Section titled “Installation”npm install @react-native-ai/android aiyarn add @react-native-ai/android aipnpm add @react-native-ai/android aibun add @react-native-ai/android aiThe provider works with AI SDK v7 and needs its polyfills.
Examples with schemas, such as the tools examples, also
use zod.
Requirements
Section titled “Requirements”- Android with
minSdkVersion26 or higher - Kotlin 2.4 or newer, which the current ML Kit GenAI libraries are built with
- React Native 0.76 or newer, with the New Architecture
- A physical device with AICore support and a locked bootloader. See the ML Kit GenAI documentation for the supported devices. Emulators and device clouds such as Firebase Test Lab have no Gemini Nano.
Native Setup
Section titled “Native Setup”Install the config plugin:
npx expo install expo-build-propertiesSet minSdkVersion and the Kotlin version with expo-build-properties:
{ "expo": { "plugins": [ [ "expo-build-properties", { "android": { "minSdkVersion": 26, "kotlinVersion": "2.4.0" } } ] ] }}Then regenerate the native project:
npx expo prebuild --cleanBare React Native
Section titled “Bare React Native”Set minSdkVersion = 26 and kotlinVersion = "2.4.0" in the ext block of
android/build.gradle.
Basic Usage
Section titled “Basic Usage”Pass android() to the AI SDK. Check that Gemini Nano can run on the device first:
import { android } from '@react-native-ai/android'import { generateText } from 'ai'
const { availability } = await android.getModelInfo()// When downloadable, the first request downloads Gemini Nano on its ownif (availability === 'available' || availability === 'downloadable') { const { text } = await generateText({ model: android(), prompt: 'Summarize on-device AI in one sentence.', })}Models & Availability covers the availability checks and downloading Gemini Nano.