Titanium SDK module for integration with Apple Foundation Models. A local 3B generative AI on iOS 26+.
- Titanium SDK module for Googles ML Kit GenAI https://github.com/m1ga/ti.genai
This module enables the use of the Apple Foundation Models framework in Titanium SDK apps, bringing fully local (on-device) generative AI to your iOS applications.
- Text generation with real-time streaming
- Structured analysis using @Generable types
- Data extraction (contacts, keywords, entities)
- Text classification into custom categories
- Dynamic schemas for flexible data structures
- 100% private - local device processing
- Zero network latency - no internet required
- Text summarization
- Structured information extraction
- Classification and categorization
- Sentiment analysis
- Short/medium text generation
- Entity extraction
- General world knowledge (uses server model)
- Complex mathematical reasoning
- Code generation
- Long responses (~4096 token limit)
| Requirement | Specification |
|---|---|
| iPhone | 15 Pro, 15 Pro Max, 16, 16 Pro, 16 Pro Max |
| iPad | Models with M1 chip or later |
| Storage | Minimum 7 GB free space (model uses ~3 GB) |
| Requirement | Version |
|---|---|
| iOS | 26.0 Beta or later |
| Titanium SDK | 12.0.0+ |
| Xcode | Version compatible with iOS 26 Beta |
| Swift | 5.9+ |
- Apple Intelligence ENABLED in Settings
- Siri Language: English (US) or other supported
- Model fully downloaded (~3 GB)
# Copy the compiled module to:
{YOUR_PROJECT}/modules/iphone/<modules>
<module platform="iphone">ti.apple.intelligence</module>
</modules>Edit your tiapp.xml and adapt for your project.
REQUIRED sections:
<ios>
<!-- Entitlements -->
<entitlements>
<dict>
<key>com.apple.developer.foundation-models.access</key>
<string>$(AppIdentifierPrefix)$(CFBundleIdentifier)</string>
<key>com.apple.developer.foundation-models.on-device</key>
<true/>
</dict>
</entitlements>
<!-- Info.plist -->
<plist>
<dict>
<key>NSAppleIntelligenceUsageDescription</key>
<string>This app uses Apple Intelligence to process text locally.</string>
<key>NSSupportsFoundationModels</key>
<true/>
<key>MinimumOSVersion</key>
<string>26.0</string>
</dict>
</plist>
</ios>- Open Settings > Apple Intelligence & Siri
- Enable Apple Intelligence
- Wait for model download to complete
- Check available storage (needs 7+ GB)
const AppleAI = require('ti.apple.intelligence');
// 1. Check availability (property, no parentheses!)
if (!AppleAI.isAvailable) {
alert('Apple Intelligence not available');
return;
}
// 2. Wait for model to be ready (IMPORTANT!)
AppleAI.waitForModel({
maxAttempts: 15,
delay: 2.0,
callback: (result) => {
if (result.ready) {
// 3. Now you can use it!
generateText();
} else {
alert('Model not ready: ' + result.error);
}
}
});
function generateText() {
AppleAI.generateText({
prompt: 'Explain AI in 2 sentences.',
callback: (result) => {
if (result.success) {
console.log('Response:', result.text);
} else {
console.error('Error:', result.error);
}
}
});
}// Article analysis with structured data
AppleAI.analyzeArticle({
text: myText,
callback: (result) => {
if (result.success) {
console.log('Title:', result.data.titulo);
console.log('Summary:', result.data.resumo);
console.log('Sentiment:', result.data.sentimento);
console.log('Key Points:', result.data.pontosChave);
console.log('Topics:', result.data.topicos);
}
}
});// Flexible schema for specific cases
const schema = {
rating: {
type: 'number',
description: 'Rating from 0 to 10',
required: true
},
recommends: {
type: 'boolean',
description: 'Whether it recommends',
required: true
},
aspects: {
type: 'array',
items: 'string',
description: 'Positive aspects'
}
};
AppleAI.generateWithSchema({
prompt: `Analyze this review: "${review}"`,
schema: schema,
callback: (result) => {
if (result.success) {
console.log('Rating:', result.data.rating);
console.log('Recommends:', result.data.recommends);
}
}
});This is the most common error. It means the model is not actually ready.
Solution: Read the complete guide TROUBLESHOOTING-ERROR-1.md
Quick Fix:
- Check if entitlements are in tiapp.xml
- Check if Info.plist has required permissions
- Use
waitForModel()before any operation - Confirm Apple Intelligence is enabled on your iPhone or Mac
Problem: Methods without parameters are properties in Titanium.
Solution: Use without parentheses:
// ❌ WRONG
const status = AppleAI.getAvailabilityStatus();
// ✅ CORRECT
const status = AppleAI.availabilityStatus;Read: TITANIUM-PROPERTIES-VS-METHODS.md
Possible solutions:
- Restart the device
- Disable and re-enable Apple Intelligence
- Check if download completed (Settings > Storage)
- Free up more space (7+ GB needed)
- Wait longer (model may still be preparing)
Use the diagnostics method to investigate:
const diag = AppleAI.diagnostics();
console.log(JSON.stringify(diag, null, 2));
// Returns detailed information:
// - iOS version
// - Device model
// - Model status
// - Free space
// - Unavailability reason (if any)| File | Description |
|---|---|
STRUCTURED-GENERATION-GUIDE.md |
Complete schema guide |
TITANIUM-PROPERTIES-VS-METHODS.md |
Understanding Titanium conventions |
TROUBLESHOOTING-ERROR-1.md |
Solving GenerationError -1 |
AppleAI.isAvailable // Bool - If available
AppleAI.availabilityStatus // Object - Detailed statusAppleAI.checkAvailability() // Alternative check
AppleAI.diagnostics() // Complete diagnostics
AppleAI.waitForModel({...}) // Wait for model to be ready
AppleAI.createSession({...}) // Create session with instructions
AppleAI.generateText({...}) // Generate text
AppleAI.streamText({...}) // Real-time streaming
AppleAI.summarize({...}) // Summarize textAppleAI.analyzeArticle({...}) // Structured analysis
AppleAI.extractContacts({...}) // Contact extraction
AppleAI.classifyText({...}) // Classification
AppleAI.extractKeywords({...}) // Keywords
AppleAI.generateWithSchema({...}) // Dynamic schemaUse example-robust-verification.js as base:
const helpers = require('example-robust-verification');
helpers.checkModelReady((status) => {
if (status.ready) {
// Model ready, can use!
AppleAI.generateText({...});
} else {
alert(status.error);
}
});AppleAI.classifyText({
text: userFeedback,
categories: ['positive', 'negative', 'bug', 'suggestion'],
callback: (result) => {
if (result.success) {
// Take action based on category
processFeedback(result.categoria, result.confianca);
}
}
});AppleAI.extractContacts({
text: emailText,
callback: (result) => {
if (result.success) {
// Save contacts to database
result.contatos.forEach(contact => {
saveContact(contact);
});
}
}
});Before starting, verify:
- iOS 26+ installed on device
- Compatible hardware (iPhone 15 Pro+ or iPad M1+)
- Apple Intelligence enabled on device
- Model fully downloaded
- 7+ GB free space
- tiapp.xml configured with entitlements
- Info.plist with required permissions
- Module installed in project
- Using
waitForModel()before operations
- Always use
waitForModel()before operations - Always check
isAvailablefirst - Always handle errors in callbacks
- Use pre-defined @Generable types when possible
- Test on real physical device if possible
- Keep prompts clear and concise
- Use streaming for responsive UIs
- Release sessions when no longer needed
- Don't rely only on
isAvailable(usewaitForModel) - Don't use on simulator (doesn't work)
- Don't make multiple simultaneous requests
- Don't create overly complex/nested schemas
- Don't expect general world knowledge
- Don't send texts larger than ~3000 words
- Don't ignore callback errors
- Don't forget to check
result.success
- Read
TROUBLESHOOTING-ERROR-1.mdfirst - Run diagnostics script:
AppleAI.diagnostics() - Check logs with
console.log - Test complete example:
example-robust-verification.js
Q: Does it work on Simulator?
A: ✅ Yes. But Apple Intelligence must be ON on your Mac.
Q: Does it need internet?
A: ❌ No. 100% local processing.
Q: Can I use it offline?
A: ✅ Yes! Works 100% offline after model download.
Q: How much space does it use?
A: ~3 GB for model, 7+ GB free recommended.
Q: Which languages does it support?
A: English, Portuguese, Spanish, French, German, among others.
Q: Does the model learn from my usage?
A: ❌ No. The model is fixed and doesn't change.
Version: 1.0.0
Last Updated: December 2025
Compatibility: iOS 26.0+, Titanium SDK 13.0.1+