iOS 27 opens the Foundation Models framework to third-party and server-based LLMs via a new public LanguageModel protocol. Any developer or company can package their own model (local or cloud-based) so it integrates seamlessly with the same session API used for Apple's on-device model.
⢠Swap between Apple on-device, Private Cloud Compute, Core AI, MLX, or your own model with a single line change ā all through the same LanguageModelSession API
⢠Model providers like Anthropic and Google can ship Swift packages (Claude, Gemini) that plug directly into Foundation Models, giving developers access to frontier models with no new integration work
⢠The protocol handles session lifecycle automatically ā EXECutor teardown, weight unloading, and connection cleanup happen when the session deallocates, eliminating manual resource management
Implements a minimal custom LanguageModel and LanguageModelExecutor that streams a reversed-echo response, demonstrating the full provider protocol surface area a real model package would implement.
import FoundationModels
// MARK: - Configuration (the cache key)
struct EchoModelConfiguration: LanguageModelConfiguration, Hashable {
let modelID: String
let maxTokens: Int
}
// MARK: - Executor (does the real work)
final class EchoModelExecutor: LanguageModelExecutor {
typealias Configuration = EchoModelConfiguration
private let configuration: EchoModelConfiguration
required init(configuration: EchoModelConfiguration) {
self.configuration = configuration
}
func prewarm() async {
// No-op for this echo model; a real model would load weights here
}
func respond(
to request: LanguageModelRequest,
model: any LanguageModel,
channel: LanguageModelResponseChannel
) async throws {
// 1. Send metadata upfront so callers can log request IDs immediately
await channel.send(.metadataUpdate(
LanguageModelResponseMetadata(
modelID: configuration.modelID,
requestID: UUID().uuidString
)
))
// 2. Extract the last user prompt from the transcript
let lastPromptText = request.transcript
.compactMap { entry -> String? in
if case .prompt(let content) = entry {
return content.text
}
return nil
}
.last ?? "(no prompt)"
// 3. Stream a fake "reversed echo" response token-by-token
let words = lastPromptText.split(separator: " ").map(String.init).reversed()
for word in words {
await channel.send(.textDelta(word + " "))
try await Task.sleep(for: .milliseconds(40))
}
}
}
// MARK: - LanguageModel (lightweight descriptor)
struct EchoLanguageModel: LanguageModel {
typealias Executor = EchoModelExecutor
var capabilities: LanguageModelCapabilities {
LanguageModelCapabilities(supportsTools: false, supportsImages: false)
}
func makeConfiguration() -> EchoModelConfiguration {
EchoModelConfiguration(modelID: "echo-v1", maxTokens: 512)
}
}
// MARK: - Usage
struct ContentView: View {
@State private var response = "Tap to run"
var body: some View {
VStack(spacing: 16) {
Text(response).padding()
Button("Ask Echo Model") {
Task { await runEchoModel() }
}
}
}
func runEchoModel() async {
let model = EchoLanguageModel()
let session = LanguageModelSession(model: model)
do {
let result = try await session.respond(to: "Hello from Foundation Models")
response = result.content
} catch {
response = "Error: \(error)"
}
}
}Foundation Models framework is newly open-source; third-party packages (Anthropic, Google) were announced but may not be publicly released at initial iOS 27 GM. Configuration hashability is critical ā incorrect Hashable implementations will cause executor reuse bugs or excessive resource allocation. prewarm() is not guaranteed to be called before the first request.
Server-backed models require network access; local models (Core AI, MLX) require sufficient device RAM for weight loading. Private Cloud Compute requires Apple Intelligence-compatible hardware.
More iOS 27 APIs land every week.
Get notified when new capabilities are published ā no noise, just signal.