A React Native plugin to access Apple Intelligence Foundation Model framework using native on-device LLM APIs. This module lets you check model availability, create sessions, generate structured outputs (JSON), and generate with tools using Apple's LLMs, all from React Native. Note that this is a beta feature, so bugs and compatibility issues may rise. Issues are welcome.
- On-device Apple Intelligence - Access Apple's Foundation Models locally
- Privacy-focused - All processing happens on-device, no data sent to servers
- Structured JSON output - Generate structured data with JSON schemas
- Text generation - Create human-like text responses
- Session management - Configure and manage LLM sessions
- TypeScript support - Full type safety and IntelliSense
- Custom tools - User defined tool-box available for LLM use
- iOS 26.0
- Xcode 26
- Apple Intelligence enabled device (iPhone 15 Pro, iPhone 16 series, M1+ iPad/Mac) or simulator (MacOS 26 required)
- Install the package:
npm install react-native-apple-llm
# or
yarn add react-native-apple-llm
# or
pnpm add react-native-apple-llm
- Link the native module (if not autolinked):
npx pod-install
# or if using CocoaPods directly
cd ios && pod install
This plugin is perfect for building:
- AI-powered mobile apps with privacy-first approach
- Chatbots and virtual assistants that work offline
- Content generation tools for social media and blogs
- Data extraction and structuring from user input
- Smart forms that auto-fill based on natural language
- Educational apps with personalized AI tutoring
- Accessibility tools with intelligent text processing
import {
isFoundationModelsEnabled,
AppleLLMSession,
} from "react-native-apple-llm";
// Check if Apple Intelligence is available
const checkAvailability = async () => {
const status = await isFoundationModelsEnabled();
console.log("Apple Intelligence status:", status);
};
// Generate simple text
const generateSimpleText = async () => {
const session = new AppleLLMSession();
await session.configure({
instructions: "You are a helpful assistant.",
});
const response = await session.generateText({
prompt: "Explain React Native in one sentence",
});
console.log(response);
session.dispose();
};
import {
AppleLLMSession,
ToolDefinition,
ToolSchema
} from "react-native-apple-llm";
// Define your tools
const weatherSchema: ToolSchema = {
name: 'weather',
description: 'Get the current weather in a given location',
parameters: {
city: {
type: 'string',
description: 'The city to get the weather for',
name: 'city'
}
}
};
const weatherHandler = async (param: any) => {
return `The weather in ${param.city.value} is severe thunderstorms. Take shelter immediately.`;
};
const weatherTool: ToolDefinition = {
schema: weatherSchema,
handler: weatherHandler
};
// Use with session, don't forget to check availability first like above
const session = new AppleLLMSession();
await session.configure({
instructions: "You are a helpful assistant.",
}, [weatherTool]);
const response = await session.generateWithTools({
prompt: "What is the weather in Monrovia, California?",
});
console.log(response);
session.dispose();
- Streaming support using
Event Emitters
- Schema as zod
- Function calling capabilities
The AppleLLMSession
class provides context and tool management for each isolated session:
const session = new AppleLLMSession();
Configures the session with instructions and optional tools.
await session.configure({
instructions: "You are a helpful assistant.",
}, [weatherTool]);
Generates natural text responses.
const response = await session.generateText({
prompt: "Explain React Native",
});
Generates structured JSON output.
const data = await session.generateStructuredOutput({
structure: { name: { type: "string" } },
prompt: "Extract name from: John Smith",
});
Generates text with tool calling capabilities.
const response = await session.generateWithTools({
prompt: "What's the weather like?",
});
Resets the session state.
await session.reset();
Cleans up resources and event listeners.
session.dispose();
Checks if Foundation Models (Apple Intelligence) are enabled and available on the device.
Returns:
"available"
- Apple Intelligence is ready to use"appleIntelligenceNotEnabled"
- User needs to enable Apple Intelligence in Settings"modelNotReady"
- Model is downloading or preparing (or mysterious system issues)"unavailable"
- Device doesn't support Apple Intelligence
const status = await isFoundationModelsEnabled();
if (status === "available") {
// Proceed with LLM operations
}
Deprecated: These functions are maintained for backward compatibility but are deprecated. Use the
AppleLLMSession
class instead for better session management.
Deprecated: Use AppleLLMSession.configure()
instead.
Configures the LLM session with system instructions and behavior.
// Deprecated
await configureSession({
instructions: "You are an expert React Native developer.",
});
// Recommended
const session = new AppleLLMSession();
await session.configure({
instructions: "You are an expert React Native developer.",
});
Deprecated: Use AppleLLMSession.generateStructuredOutput()
instead.
// Deprecated
const userInfo = await generateStructuredOutput({
structure: {
name: { type: "string", description: "User's full name" },
age: { type: "number", description: "User's age" },
},
prompt: "Extract user information: John is 25 years old",
});
// Recommended
const session = new AppleLLMSession();
await session.configure({ instructions: "Extract user data." });
const userInfo = await session.generateStructuredOutput({
structure: {
name: { type: "string", description: "User's full name" },
age: { type: "number", description: "User's age" },
},
prompt: "Extract user information: John is 25 years old",
});
Deprecated: Use AppleLLMSession.generateText()
instead.
// Deprecated
const explanation = await generateText({
prompt: "Explain the benefits of on-device AI processing",
});
// Recommended
const session = new AppleLLMSession();
await session.configure({ instructions: "Be helpful and informative." });
const explanation = await session.generateText({
prompt: "Explain the benefits of on-device AI processing",
});
Deprecated: Use AppleLLMSession.reset()
instead.
// Deprecated
await resetSession();
// Recommended
await session.reset();
Defines a property in your JSON schema:
interface StructureProperty {
type?: "string" | "integer" | "number" | "boolean" | "object";
description?: string;
enum?: string[];
properties?: StructureSchema;
}
A key-value mapping for defining structured output:
type StructureSchema = {
[key: string]: StructureProperty;
};
interface LLMConfigOptions {
instructions?: string;
}
interface LLMGenerateOptions {
structure: StructureSchema;
prompt: string;
}
interface LLMGenerateTextOptions {
prompt: string;
}
interface LLMGenerateWithToolsOptions {
prompt: string;
maxTokens?: number;
temperature?: number;
toolTimeout?: number; // in milliseconds
}
interface ToolSchema {
name: string;
description: string;
parameters: { [key: string]: ToolParameter };
}
interface ToolDefinition {
handler: (parameters: any) => Promise<any>; // parameter should always look like a json
schema: ToolSchema;
}
Apple Intelligence not available:
const status = await isFoundationModelsEnabled();
if (status === "appleIntelligenceNotEnabled") {
// Guide user to enable Apple Intelligence in Settings > Apple Intelligence & Siri
}
Model not ready:
if (status === "modelNotReady") {
// Apple Intelligence is downloading. Ask user to wait and try again. Or double check the device is properly configured
}
Device not supported:
if (status === "unavailable") {
// Device doesn't support Apple Intelligence. Consider fallback options.
}
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Clone the repository
- Install dependencies:
yarn install
- Build the project:
yarn build
- Link the library:
npm link
- Get the example project found here.
- Add the library
npm link react-native-apple-llm
MIT License - see LICENSE.md for details.
Star this repo if you find it helpful!
Created by Ahmed Kasem, Erik, and future contributors!