Get Started

Install expo-ai-kit and run your first on-device AI query in minutes.

Prerequisites

Before you begin, make sure you have:

  • Expo SDK 54+
  • iOS: iOS 26.0+ (full support), iOS 15.1+ (limited)
  • Android: API 26+, Supported devices

Expo SDK Requirement

expo-ai-kit requires Expo SDK 54 or later. If you're using an older SDK version, you'll need to upgrade your project first.

Development build required

expo-ai-kit includes native Swift and Kotlin code, so it does not run in Expo Go. Use a development build created with npx expo run:ios, npx expo run:android, or EAS Build.

Installation

Install expo-ai-kit using your preferred package manager:

Terminalbash
npx expo install expo-ai-kit

For bare React Native projects, run npx pod-install after installing.

Android Configuration

Android For Android, install expo-build-properties and set the minimum SDK version:

Terminalbash
npx expo install expo-build-properties
app.jsonjson
{
  "expo": {
    "plugins": [
      [
        "expo-build-properties",
        {
          "android": {
            "minSdkVersion": 26
          }
        }
      ]
    ]
  }
}

Basic Usage

Simple Prompt

The simplest way to use on-device AI:

App.tsxtypescript
import {
  isAvailable,
  prepareBuiltInModel,
  sendMessage,
} from 'expo-ai-kit';

async function askAI(question: string) {
  const supported = await isAvailable();

  if (!supported) {
    console.log('On-device AI not available');
    return null;
  }

  // Downloads Android's OS-managed ML Kit model when needed.
  // On iOS, this validates Apple Foundation Models availability.
  await prepareBuiltInModel();

  const response = await sendMessage([
    { role: 'user', content: question }
  ]);
  return response.text;
}

const answer = await askAI('What is the capital of France?');

Support is not readiness

On Android, isAvailable() can return truewhile the supported ML Kit model still needs to download. AwaitprepareBuiltInModel() once during setup before starting inference.

With Custom System Prompt

Customize the AI's behavior with a system prompt:

App.tsxtypescript
import { sendMessage } from 'expo-ai-kit';

const response = await sendMessage(
  [{ role: 'user', content: 'Tell me a joke' }],
  { systemPrompt: 'You are a comedian who specializes in dad jokes.' }
);

console.log(response.text);

Multi-turn Conversations

On-device models are stateless — keep an array of messages and pass the full history on each call:

chat.tstypescript
import { sendMessage, type LLMMessage } from 'expo-ai-kit';

const messages: LLMMessage[] = [
  { role: 'user', content: 'My name is Alice.' },
];

const first = await sendMessage(messages);
messages.push({ role: 'assistant', content: first.text });

// Add the next turn — the full history gives the model context
messages.push({ role: 'user', content: 'What is my name?' });
const second = await sendMessage(messages);
// second.text -> "Your name is Alice."

You own the history array — append each turn and pass it back. See the Multi-turn guide for patterns like trimming long conversations.

Streaming Responses

For a ChatGPT-like experience where text appears progressively:

StreamingChat.tsxtypescript
import { useState } from 'react';
import { streamMessage } from 'expo-ai-kit';

const [responseText, setResponseText] = useState('');

const { promise, stop } = streamMessage(
  [{ role: 'user', content: 'Tell me a story' }],
  (event) => {
    // Update UI with each token
    setResponseText(event.accumulatedText);

    // event.token - the new token/chunk
    // event.accumulatedText - full text so far
    // event.isDone - whether streaming is complete
  },
  { systemPrompt: 'You are a creative storyteller.' }
);

// Optionally cancel the stream
// stop();

// Wait for completion
await promise;

You're Ready!

You now have expo-ai-kit installed and configured. The library handles all the complexity of interfacing with platform-native AI frameworks.

Next Steps

Now that you have the basics working, explore more features: