Foundation Models Framework - Appleās Swift Gateway to On-Device AI
With the Foundation Models Framework, developers can tap into Appleās compact, high-performance on-device LLMs using familiar Swift code, intuitive tools, and ironclad privacy.

Introduction
Until recently, building generative AI apps required deep ML expertise and access to large cloud infrastructures. But Apple is changing that narrative. With the Foundation Models Framework, developers can tap into Appleās compact, high-performance on-device LLMs using familiar Swift code, intuitive tools, and ironclad privacy.
This isnāt just an API wrapper. Itās a full-stack integration between the model, the OS, and the developer toolkit - giving Apple developers an unfair advantage when creating intelligent apps that run fast, stay private, and work offline.
Developer-Centric Capabilities
- Guided Generation with Swift Macros: Developers can annotate structs and enums in Swift with
@Generable, turning them into templates for LLM output. This removes the guesswork and fragility of prompt engineering. You define a format, the model fills it reliably. - Constrained Decoding Built-In: The framework uses a decoding engine that enforces structural correctness. Developers never need to validate or parse malformed model outputs again. This enables confident integration with downstream features like autofill, voice commands, or personalized summaries.
- Streaming Output via Sessions: The
LanguageModelSessionAPI gives you fine-grained control over inference sessions. Not only does it persist the modelās memory through a KV cache, but it also allows you to stream responses as theyāre being generated. Great for chat interfaces, live suggestions, and editing tools. - Optimized Performance Under the Hood: Appleās Foundation Models Framework optimizes for Swiftās concurrency model, meaning you get low-latency, high-throughput generation by default. It manages token caching, speculative decoding, and resource prioritization without manual setup.
Tool Calling - Structured, Safe, and Powerful
Tool calling is where Appleās design ethos truly shines:
- Developers define tools as Swift types conforming to a simple protocol. No YAML schemas or brittle API strings.
- The framework ensures tools are only invoked with valid arguments. This means the model wonāt hallucinate function names or pass malformed inputs.
- Tool calls can be batched, chained, or composed into graphs - enabling rich automation workflows, such as querying reminders, updating contacts, and composing emails - all in one interaction.
This kind of compositional reasoning and tool invocation is a cornerstone for building AI-native apps that do things for users - not just talk back to them.
LoRA Adapter Fine-Tuning
Some apps need more than general-purpose intelligence. For those cases, the Foundation Models Framework provides a complete adapter training pipeline:
- Rank-32 LoRA Adapters: Fine-tune adapters on your own data (e.g., customer support transcripts, legal clauses, educational material).
- Integrated with Background Assets: Adapters are version-locked to specific base models and downloaded dynamically to the userās device.
- Speculative Decoding Support: You can also train a compact draft model to accelerate generation with minimal latency.
This lets developers teach the model new tricks - without ever touching the base weights or sending user data to a server.
ļø Developer Tools & Ecosystem
Apple has made sure that using the Foundation Models Framework fits right into your workflow:
- Xcode Playground: A visual playground to prototype and refine prompts directly in Swift.
- Performance Profiler: Monitor token generation time, memory footprint, and decoding paths.
- Simulator Support: Test your LLM features in iOS and visionOS simulators before deploying to actual devices.
The framework also aligns with Appleās commitment to performance: all of this runs efficiently on Apple silicon, leveraging its custom ML accelerators and cache hierarchies.
ļø Safety and Responsible AI by Default
Apple has embedded Responsible AI practices deep into this framework:
- Prompts and tool schemas are screened by default for safety.
- Cultural sensitivity and locale-specific nuances are respected via region-tuned adapters.
- Guardrails prevent unsafe generations or toxic outputs from ever reaching the user.
Whatās more, Apple provides documentation, best practices, and human interface guidelines to ensure developers donāt just build cool apps - but build ethical, inclusive, and high-quality ones.
Ideal Use Cases
- Education: Personalized learning assistants that summarize lessons, quiz students, and adjust explanations dynamically.
- Productivity: Smart notetaking, context-aware task creation, meeting transcription summarization.
- Accessibility: Real-time voice captioning, visual scene interpretation, screen content description.
- Enterprise Tools: Document classification, secure summarization, contract generation - run locally without compromising privacy.
CTA
The Foundation Models Framework is more than an API - itās a bridge between Appleās LLM innovation and developer creativity. With native Swift integration, real-time streaming, built-in safety, and full control over inference, it opens up a new frontier in intelligent app development.
Whether you're a solo app developer or an enterprise building AI-first tools, this framework brings the power of generative AI directly to your users - safely, privately, and beautifully.
Start building the future of on-device AI today.
The 𤫠hussh magazine
Written by Manish Sainani, and built to read beautifully here ā and to travel to 𤫠One on your phone, your glasses, and visionOS, as one immersive magazine you own.