saidkaban/expo-ai-kit
关于
On-device AI for Expo and React Native. Local LLM, speech-to-text, vision, and embeddings. No API keys, no cloud.
网站与应用开发实测星标增长
- 24小时
- 0
- 7天
- +1
- 15天
- +1
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文expo-ai-kit
On-device AI for React Native. Local LLM, speech-to-text, vision, and embeddings for Expo apps and React Native apps with Expo modules installed. No API keys, no cloud.
Documentation · Examples · npm · Changelog
- Private and offline. Inference runs on the device. Prompts, audio, and images never leave it.
- No API key, no per-request cost. Nothing to provision, meter, or proxy.
- One TypeScript API for both platforms. Apple Foundation Models, Speech, and Vision on iOS; ML Kit and MediaPipe on Android; LiteRT-LM for downloadable models such as Gemma.
- Pay only for what you use. Every feature is opt-in, so unused native code, models, and permissions never ship. Zero runtime JavaScript dependencies.
Install
npx expo install expo-ai-kit
Turn on the features you use in your app config, then make a native build. Until you enable a feature, none of its native code is compiled into your app. To use text generation:
{
"expo": {
"plugins": [["expo-ai-kit", { "llm": true }]]
}
}
Requires Expo SDK 54+ (or compatible Expo modules in an existing React Native app) and a native development or production build. Expo Go is not supported. Follow Get Started for native setup and a working app example. Device and OS requirements vary by feature; see platform support.
First request
With llm enabled, on a device with a supported built-in text model:
import { isAvailable, prepareBuiltInModel, sendMessage } from 'expo-ai-kit';
async function ask(question: string) {
if (!(await isAvailable())) {
return 'The built-in text model is unavailable on this device.';
}
await prepareBuiltInModel();
const { text } = await sendMessage([{ role: 'user', content: question }]);
return text;
}
const answer = await ask('Explain gravity in one sentence.');
The built-in text model requires Apple Intelligence on iOS 26+ or a supported Android device. Android may download its model during preparation. You can also download a model such as Gemma.
LLM
Generate and stream text, return structured JSON, or let the model call your functions. Stream tokens into your UI as they arrive:
import { streamMessage } from 'expo-ai-kit';
const { promise, stop } = streamMessage(
[{ role: 'user', content: 'Write a haiku about the sea.' }],
(event) => setText(event.accumulatedText)
);
await promise; // call stop() to cancel early
Pass the full message history on each call. One generation runs at a time. Enable the llm
option and rebuild.
Speech
Transcribe microphone audio or recorded files
with streamTranscription and transcribe. Enable the speech plugin option and rebuild.
iOS requires 26+; Android requires 12+ and processes file audio at real-time rate.
Vision
Remove backgrounds, label images, and read text
with removeBackground, labelImage, and recognizeText.
Find faces with detectFaces:
import { detectFaces } from 'expo-ai-kit';
const { width, height, faces } = await detectFaces({ uri: photo.uri });
// faces[0].bounds (normalized 0–1) and faces[0].pixelBounds, largest face first
Enable vision on Android and rebuild, or name only the features you use, for example
{ "vision": ["face-detection"] }, so the app ships only that detector. Face detection uses a
bundled model and needs no download.
Embeddings
Semantic search and retrieval with
embed, chunkText, and createVectorStore. iOS uses the system embedding model;
Android requires the androidEmbeddings option and an explicit model download.
Build options
Every option is off by default. Each one compiles a single feature into the app; leave it off
and that feature's native code, models, and permissions stay out of the build, and its functions
throw a typed *_NOT_ENABLED error. Changing an option requires a new native build.
| Option | Enables | Adds to the app |
|---|---|---|
llm |
Text generation, JSON output, tool calling, model downloads, the AI SDK provider | LiteRT-LM runtime (about 30 MB of iOS arm64 code, 21 MB on Android); Android minSdkVersion 26 |
speech |
transcribe, streamTranscription |
Android ML Kit speech and microphone permission; iOS microphone usage string |
vision |
Android removeBackground, labelImage, recognizeText, detectFaces |
true adds every ML Kit vision client and bundled model; an array such as ["face-detection"] adds only those features. iOS needs no option |
androidEmbeddings |
Android embed |
MediaPipe TextEmbedder (about 25 MB); the model downloads at runtime |
The config reference covers bare React Native setup and every option in detail.
More
- Vercel AI SDK: use
expo-ai-kit/aiwith the AI SDK. - API reference: functions, options, results, and typed errors.
- Troubleshooting and GitHub issues.
- llms.txt: documentation index and essential contracts for coding agents.
MIT © Said Kaban.
探索相关项目
加载中…