Apple Foundation Models: A Unified AI Framework for On-Device, Cloud, and Custom Models
Apple finally gives third-party developers a first-class, unified AI interface that respects the platform's privacy and execution model, eliminating the need to bolt on separate SDKs for on-device vs. cloud inference. For iOS and macOS developers, this means AI features can be built once and run anywhere Apple's models run, with the app still owning all security decisions.
Apple Foundation Models is Apple's generative AI development framework, officially available for building AI features into apps. It unifies access to three model sources: SystemLanguageModel running locally on iOS and macOS, PrivateCloudComputeLanguageModel running on Apple's own data centers, and custom models plugged in through a protocol. One LanguageModelSession API handles prompts, history, tools, and structured output, so switching between on-device and cloud models requires no rewrite of the calling code.
The framework's five core objects separate concerns cleanly: LanguageModel decides where inference runs, LanguageModelSession manages the conversation and tool invocation, @Generable converts model output into typed Swift structures, Tool lets the model request app actions while the app retains execution control, and DynamicProfile switches session configuration (instructions, model, temperature) based on app state. A historyTransform hook lets developers compress the transcript fed to the model without touching the original history.
Beyond Swift, Apple ships a command-line tool `fm` and a Python SDK (`pip install apple_fm_sdk`) that mirror the Swift API, with @fm.generable for structured output. A built-in SpotlightSearchTool lets models query content the app has indexed in Spotlight. Custom models require implementing LanguageModel and LanguageModelExecutor, mapping four things: history messages, generation parameters, streaming output, and errors.
The framework's central design keeps execution authority in the app, not the model, which aligns with Apple's privacy stance but also means tool calling is inherently more constrained than in agentic frameworks that let the model run code directly.
The availability of a Python SDK and CLI signals that Apple targets not just app developers but also automation and server-side workflows that need the same model backend.
DynamicProfile plus historyTransform gives developers a structured way to manage context windows and model routing, addressing the practical cost and latency issues of always using the largest cloud model.
The requirement to implement four mappings for custom models (history, generation parameters, streaming, errors) is a concrete, non-trivial integration surface that will likely be the main friction point for teams adopting non-Apple backends.