Skip to content

Getting Started

Run Gemini Nano on Android, on the device, with the Vercel AI SDK. Android provides the model through AICore, so there’s no model to bundle and no API key. When you need a larger model or support for every device, the same provider runs cloud Gemini. It’s built on Google’s Agent Development Kit.

Terminal window
npm install @react-native-ai/adk ai

The AI SDK needs its polyfills.

  • Android with minSdkVersion 26 or higher
  • React Native 0.76 or newer, with the New Architecture
  • For Gemini Nano, a physical device with AICore support, running Android 14 or newer. See the ML Kit GenAI documentation for the supported devices. Cloud Gemini works on any device.

Raise minSdkVersion to 26, and exclude two files that Google’s libraries both ship, so the build doesn’t fail on duplicates.

With expo-build-properties:

{
"expo": {
"plugins": [
[
"expo-build-properties",
{
"android": {
"minSdkVersion": 26,
"packagingOptions": {
"exclude": ["META-INF/INDEX.LIST", "META-INF/DEPENDENCIES"]
}
}
}
]
]
}
}

Then regenerate the native project:

Terminal window
npx expo prebuild --clean

Add this to android/app/build.gradle, and set minSdkVersion to 26:

android {
packagingOptions {
excludes += ["META-INF/INDEX.LIST", "META-INF/DEPENDENCIES"]
}
}

Pass adk() to the AI SDK. Check that Gemini Nano can run on the device first:

import { adk } from '@react-native-ai/adk'
import { generateText } from 'ai'
if (await adk.isAvailable('genai-nano')) {
const { text } = await generateText({
model: adk(),
prompt: 'Summarize on-device AI in one sentence.',
})
}

Models & Availability covers the availability checks and cloud Gemini.