Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ receiving the current app's telemetry stream.
Native integration with Apple's on-device AI capabilities. **Built-in** - no model downloads required, uses system models.

- **Text Generation** - Apple Foundation Models for chat and completion
- **Private Cloud Compute** - Opt-in server model for larger context and reasoning on iOS 27+
- **Embeddings** - NLContextualEmbedding for 512-dimensional semantic vectors
- **Transcription** - SpeechAnalyzer for fast, accurate speech-to-text
- **Speech Synthesis** - AVSpeechSynthesizer for natural text-to-speech with system voices
Expand Down Expand Up @@ -87,6 +88,17 @@ const { text } = await generateText({
prompt: 'Explain quantum computing',
})

// Private Cloud Compute on iOS 27+
const pcc = await generateText({
model: apple('private-cloud-compute'),
prompt: 'Analyze this long document',
providerOptions: {
apple: {
reasoningLevel: 'moderate',
},
},
})

// Generate embeddings
const { embedding } = await embed({
model: apple.textEmbeddingModel(),
Expand All @@ -108,12 +120,13 @@ const { audio } = await speech({

#### Availability

| Feature | iOS Version | Additional Requirements |
| ---------------- | ----------- | -------------------------- |
| Text Generation | iOS 26+ | Apple Intelligence device |
| Embeddings | iOS 17+ | - |
| Transcription | iOS 26+ | - |
| Speech Synthesis | iOS 13+ | iOS 17+ for Personal Voice |
| Feature | iOS Version | Additional Requirements |
| --------------------- | ----------- | ------------------------------------------------------------ |
| Text Generation | iOS 26+ | Apple Intelligence device |
| Private Cloud Compute | iOS 27+ | iOS 27 SDK build, Apple Intelligence device, managed entitlement |
| Embeddings | iOS 17+ | - |
| Transcription | iOS 26+ | - |
| Speech Synthesis | iOS 13+ | iOS 17+ for Personal Voice |

See the [Apple documentation](https://react-native-ai.dev/docs/apple/getting-started) for detailed setup and usage guides.

Expand Down
18 changes: 17 additions & 1 deletion packages/apple-llm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ A Vercel AI SDK provider for Apple Foundation Models, enabling access to Apple I
**Requirements:**
- iOS 26+
- Apple Intelligence enabled device
- Vercel AI SDK v5
- Vercel AI SDK v6
- React Native New Architecture

```ts
Expand All @@ -18,9 +18,25 @@ const answer = await generateText({
})
```

Use the Private Cloud Compute model with an iOS 27 SDK build when you need a
larger context window or reasoning:

```ts
const answer = await generateText({
model: apple('private-cloud-compute'),
prompt: 'Analyze this long document',
providerOptions: {
apple: {
reasoningLevel: 'moderate',
},
},
})
```

## Features

- ✅ Text generation with Apple Foundation Models
- ✅ Private Cloud Compute model selection
- ✅ Structured outputs
- ✅ Tool calling
- ✅ Streaming
Expand Down
4 changes: 4 additions & 0 deletions packages/apple-llm/ios/AppleLLM.mm
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,12 @@ - (void)generateText:(nonnull NSArray *)messages
resolve:(nonnull RCTPromiseResolveBlock)resolve
reject:(nonnull RCTPromiseRejectBlock)reject {
NSDictionary *opts = @{
@"model": options.model() ?: [NSNull null],
@"temperature": options.temperature().has_value() ? @(options.temperature().value()) : [NSNull null],
@"maxTokens": options.maxTokens().has_value() ? @(options.maxTokens().value()) : [NSNull null],
@"topP": options.topP().has_value() ? @(options.topP().value()) : [NSNull null],
@"topK": options.topK().has_value() ? @(options.topK().value()) : [NSNull null],
@"reasoningLevel": options.reasoningLevel() ?: [NSNull null],
@"schema": options.schema() ?: [NSNull null],
@"tools": options.tools() ?: [NSNull null]
};
Expand All @@ -138,10 +140,12 @@ - (void)cancelStream:(nonnull NSString *)streamId {

- (void)generateStream:(nonnull NSString *)streamId messages:(nonnull NSArray *)messages options:(JS::NativeAppleLLM::AppleGenerationOptions &)options {
NSDictionary *opts = @{
@"model": options.model() ?: [NSNull null],
@"temperature": options.temperature().has_value() ? @(options.temperature().value()) : [NSNull null],
@"maxTokens": options.maxTokens().has_value() ? @(options.maxTokens().value()) : [NSNull null],
@"topP": options.topP().has_value() ? @(options.topP().value()) : [NSNull null],
@"topK": options.topK().has_value() ? @(options.topK().value()) : [NSNull null],
@"reasoningLevel": options.reasoningLevel() ?: [NSNull null],
@"schema": options.schema() ?: [NSNull null],
@"tools": options.tools() ?: [NSNull null],
};
Expand Down
6 changes: 6 additions & 0 deletions packages/apple-llm/ios/AppleLLMError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ enum AppleLLMError: Error, LocalizedError {
case toolCallError(Error)
case unknownToolCallError
case contextWindowExceeded
case rateLimited

var errorDescription: String? {
switch self {
Expand All @@ -41,6 +42,8 @@ enum AppleLLMError: Error, LocalizedError {
return "Unknown tool call error"
case .contextWindowExceeded:
return "Context window exceeded"
case .rateLimited:
return "Apple Intelligence request limit reached"
}

}
Expand All @@ -65,6 +68,8 @@ enum AppleLLMError: Error, LocalizedError {
return "UNKNOWN_TOOL_CALL_ERROR"
case .contextWindowExceeded:
return "CONTEXT_WINDOW_EXCEEDED"
case .rateLimited:
return "RATE_LIMITED"
case .streamNotFound:
return nil
}
Expand All @@ -82,6 +87,7 @@ enum AppleLLMError: Error, LocalizedError {
case .unknownToolCallError: return 8
case .toolCallError: return 9
case .contextWindowExceeded: return 10
case .rateLimited: return 11
}
}
}
Loading
Loading