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.
⢠Any LLM ā local, cloud, or open-source ā can now be used through the same FoundationModels session API, meaning app code never changes when swapping providers
⢠First-party packages from Anthropic and Google will expose Claude and Gemini through this protocol, giving Swift developers access to frontier models with minimal integration effort
⢠The executor lifecycle (prewarm, respond, automatic teardown) is managed by the framework, so providers don't need to write resource-management boilerplate
Implements a minimal custom LanguageModel and LanguageModelExecutor conformance that echoes the user's prompt back, demonstrating the full provider contract: configuration, prewarm, and streaming respond.
import FoundationModels
import Foundation
// MARK: - Configuration (the cache key)
struct EchoModelConfiguration: LanguageModelExecutorConfiguration {
let prefix: String
// Hashable conformance drives executor reuse
func hash(into hasher: inout Hasher) {
hasher.combine(prefix)
}
static func == (lhs: EchoModelConfiguration, rhs: EchoModelConfiguration) -> Bool {
lhs.prefix == rhs.prefix
}
}
// MARK: - Executor (does the real work)
final class EchoModelExecutor: LanguageModelExecutor {
typealias Configuration = EchoModelConfiguration
private let configuration: Configuration
required init(configuration: Configuration) {
self.configuration = configuration
}
func prewarm() async {
// No expensive setup for this echo model
}
func respond(
to request: LanguageModelRequest,
channel: LanguageModelResponseChannel
) async throws {
// 1. Send metadata upfront
await channel.send(.metadataUpdate(
LanguageModelResponseMetadata(modelID: "echo-v1", requestID: UUID().uuidString)
))
// 2. Extract the last user prompt from the transcript
let lastPrompt = request.transcript.entries.compactMap { entry -> String? in
if case .prompt(let content) = entry { return content.text }
return nil
}.last ?? ""
let reply = "\(configuration.prefix): \(lastPrompt)"
// 3. Stream token deltas
for word in reply.split(separator: " ") {
await channel.send(.textDelta(String(word) + " "))
try await Task.sleep(for: .milliseconds(40)) // simulate streaming
}
}
}
// MARK: - LanguageModel (describes capabilities)
struct EchoLanguageModel: LanguageModel {
typealias Executor = EchoModelExecutor
var capabilities: LanguageModelCapabilities {
LanguageModelCapabilities()
}
func makeConfiguration() -> EchoModelConfiguration {
EchoModelConfiguration(prefix: "Echo")
}
}
// MARK: - Usage in an app
struct EchoViewModel {
private let session: LanguageModelSession<EchoLanguageModel>
init() {
session = LanguageModelSession(model: EchoLanguageModel())
}
func ask(_ question: String) async throws -> String {
let response = try await session.respond(to: question)
return response.content
}
}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.
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.
iOS 27 introduces GenerateIterativeSegmentationRequest in the Vision framework, letting users interactively isolate any object in an image by providing a point, bounding box, lasso, or scribble as a seed, then iteratively refine the resulting mask.
In-depth guide
iOS 27 On-Device AI & Apple Intelligence āThe LanguageModelExecutor is cached per Configuration (Hashable), not per model instance ā ensure your Configuration equality/hashing reflects all meaningful identity so executors are reused correctly. prewarm() is not guaranteed to be called before respond(). The framework is being released as open source and Linux support is possible for server-side Swift deployments.
Server-based providers (e.g. Claude, Gemini) require network access; on-device providers (CoreAI, MLX) require compatible Apple Silicon hardware. Apple Intelligence device required only for the System Language Model and PCC.
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.