Core AI is a new iOS 27 framework that lets developers bring their own on-device AI models (vision transformers, LLMs, etc.) directly into apps, using the familiar FoundationModels session API. Models run entirely on-device with no cloud dependency, no per-token cost, and no data leaving the device.
⢠Bring custom open-source models (e.g. Qwen, SAM 3) into your app with zero server infrastructure ā users' data never leaves the device
⢠Reuse the existing FoundationModels session API (LanguageModelSession, @Generable, streaming) with your own model bundle, so adoption is ergonomic for anyone already using Apple Intelligence APIs
⢠Ship multiple specialized models side-by-side (vision + LLM) with independent upgrade paths, keeping individual sizes manageable for on-device deployment
Shows how to load a custom Core AI language model bundle and use the standard FoundationModels LanguageModelSession to generate structured vocabulary card data ā same API as Apple Intelligence, but powered by your own model.
import SwiftUI
import FoundationModels
import CoreAILM
// Define structured output with @Generable ā same as Foundation Models
@Generable
struct VocabCard {
@Guide(description: "The word in the target language")
var word: String
@Guide(description: "Romanized pronunciation")
var pronunciation: String
@Guide(description: "English translation")
var translation: String
@Guide(description: "Example sentence in the target language")
var exampleSentence: String
@Guide(description: "English meaning of the example sentence")
var exampleMeaning: String
}
@MainActor
class VocabCardViewModel: ObservableObject {
@Published var card: VocabCard?
@Published var isLoading = false
@Published var errorMessage: String?
// Load a custom Core AI LLM from the app bundle (e.g. Qwen 0.6B)
private var languageModel: CoreAILanguageModel = {
guard let modelURL = Bundle.main.url(
forResource: "Qwen-0.6B",
withExtension: "aimodel"
) else {
fatalError("Qwen model bundle not found in app resources")
}
return CoreAILanguageModel(modelURL: modelURL)
}()
func generateCard(for englishLabel: String, targetLanguage: String) async {
isLoading = true
card = nil
errorMessage = nil
do {
// Pass your custom model to LanguageModelSession ā same API as Apple Intelligence
let session = LanguageModelSession(model: languageModel)
let prompt = "Generate a \(targetLanguage) vocabulary card for the English word: \(englishLabel)"
// Structured output generation using @Generable ā identical to Foundation Models usage
let response = try await session.respond(
to: Prompt(prompt),
generating: VocabCard.self
)
card = response.content
} catch {
errorMessage = error.localizedDescription
}
isLoading = false
}
}
struct VocabCardView: View {
@StateObject private var viewModel = VocabCardViewModel()
let detectedLabel: String = "hummingbird"
var body: some View {
VStack(spacing: 16) {
if viewModel.isLoading {
ProgressView("Generating vocab card...")
} else if let card = viewModel.card {
VStack(alignment: .leading, spacing: 8) {
Text(card.word).font(.largeTitle.bold())
Text(card.pronunciation).font(.subheadline).foregroundStyle(.secondary)
Text(card.translation).font(.title3)
Divider()
Text(card.exampleSentence).italic()
Text(card.exampleMeaning).font(.caption).foregroundStyle(.secondary)
}
.padding()
.background(.regularMaterial, in: RoundedRectangle(cornerRadius: 16))
} else if let error = viewModel.errorMessage {
Text("Error: \(error)").foregroundStyle(.red)
}
Button("Generate Card for '\(detectedLabel)'") {
Task {
await viewModel.generateCard(for: detectedLabel, targetLanguage: "Mandarin Chinese")
}
}
.buttonStyle(.borderedProminent)
}
.padding()
}
}Foundation Models is a new Apple framework introduced in iOS 27 that gives developers on-device access to the same Apple Intelligence language model powering system features, enabling text generation, structured output, and tool-calling entirely on-device without a network connection.
iOS 27 opens the Foundation Models framework to third-party LLM providers via a new public LanguageModel protocol, enabling anyone to integrate custom, server-based, or open-source models using the same Swift API as Apple's on-device system model.
App Schemas let developers describe their app's content and actions using pre-defined domain schemas (like the Calendar domain) so Siri can understand, search, and act on app data without custom NLP. Entities conforming to IndexedEntity are donated to Spotlight's semantic index, enabling natural-language queries over app content.
In-depth guide
iOS 27 On-Device AI & Apple Intelligence ā⢠First-time model load triggers 'specialization' (on-device compilation/caching) which can be very slow ā instrument with Core AI Instruments and move this out of the interactive flow ⢠Bundling models inflates app download size significantly (>1 GB for two models); use Background Assets to defer download until the user opts into the feature ⢠CoreAILM and CoreAISegmentation come from the open-source coreai-models Swift Package (GitHub), not a built-in Apple framework ā you must add this SPM dependency manually ⢠The .aimodel format is produced by Core AI Python conversion/optimization tools; you cannot use raw PyTorch weights directly
Requires Apple Silicon or A-series devices capable of running on-device ML; model specialization (compilation/caching) happens on first load and can take significant time for large models ā plan a first-run UX accordingly. Total model footprint depends on chosen model variants (e.g. SAM 3 ~623 MB + LLM).
Visual Intelligence brings iOS 17's Visual Look Up capabilities to a new developer-facing API surface in iOS 27, letting apps pipe live camera frames or static images through on-device scene understanding to extract subjects, text, barcodes, and rich semantic labels without any cloud round-trip.