Getting started with Apple's Foundation Models framework
Learn what Apple's Foundation Models framework is, how it works, and when to use it.
22 Jun 2026 · 5 min read
Apple's Foundation Models framework gives us access to language models directly through a native Swift API. In this article, we'll answer some of the questions that naturally come up when using it for the first time.
Let's jump in.

Getting started is surprisingly simple:
import FoundationModelslet model = SystemLanguageModel.defaultguard case .available = model.availability else {print("Apple Intelligence not available on this device")return}do {let session = LanguageModelSession()let response = try await session.respond(to: "Suggest a name for a hiking app.")print(response.content)} catch {print(error.localizedDescription)}
That's all it takes to get a response.
Foundation Models requires an Apple Intelligence-capable device. This includes iPhone 15 Pro and newer, M-series iPads, and Apple Silicon Macs.
LanguageModelSession maintains conversation history across multiple calls, so we can build multi-turn interactions by reusing the same session instance.
Structured output
One area where Foundation Models becomes especially interesting is structured output. Using the @Generable macro, we can define the exact Swift type we expect and have the model generate instances of that type directly.
For example:
@Generablestruct AppNameSuggestion {let name: Stringlet tagline: String}let session = LanguageModelSession()let response = try await session.respond(to: "Suggest a name for a hiking app.",generating: AppNameSuggestion.self)print(response.content.name) // e.g. "TrailQuest"print(response.content.tagline) // e.g. "Every path, perfectly planned."
The model generates a valid instance of AppNameSuggestion directly, with no JSON parsing or string extraction involved.
Where does the model run?
By default, Foundation Models uses Apple's on-device model. Nothing is sent to a server and the framework continues to work without an internet connection. This makes it a particularly interesting option for privacy-sensitive features.
In iOS 27, Apple expanded Foundation Models with support for Apple's server-side Private Cloud Compute (PCC) models, accessible through the same API. PCC offers a larger context window and reasoning support, but requires an internet connection and has a daily usage limit. It is currently only available to apps enrolled in the App Store Small Business Program with fewer than 2 million total first-time downloads.
Can we use third-party models through the same API?
With iOS 27, Foundation Models can work with third-party model providers. Providers can ship Swift packages that conform to the LanguageModel protocol. Once a model is created, we can pass it into LanguageModelSession and continue using the same session API.
The exact setup depends on the provider. For example, a cloud model usually still requires provider-specific configuration such as an API key, model identifier, or account setup. The benefit is that the rest of the app can continue to work with LanguageModelSession instead of being tightly coupled to one provider.
A third-party model might be configured as follows:
import FoundationModelsimport ClaudeForFoundationModelslet model = ClaudeLanguageModel(name: .sonnet4_6, auth: .apiKey(...))let session = LanguageModelSession(model: model)let response = try await session.respond(to: "...")print(response.content)
How good are the responses?
It depends on the task. The on-device model is significantly smaller than models like GPT-4 or Claude. For focused, well-scoped tasks it performs well for example for summarizing short text, classifying or tagging content, extracting structured data or generating short suggestions.
For broader reasoning, general world knowledge, or nuanced writing, it will fall short of larger cloud models. The model is not designed to compete with those larger models, it's designed to be fast, private, and always available.
Conclusion
Foundation Models makes it easy to add AI-powered features without signing up for a third-party API, managing keys, or sending user data to a server.
For complex reasoning or broad world knowledge, a larger cloud model is still the better choice. But for focused tasks where privacy and offline support matter, it's one of the most practical options iOS developers currently have.



Newsletter
Like to support my work?
Say hi
Related tags
Articles with related topics
Latest articles and tips



