What problem does it solve?
Enable iOS applications to run language model generation and structured output entirely on device to protect user privacy, support offline scenarios, and avoid cloud dependency while providing predictable integration patterns.
Core Features & Use Cases
- Availability checks: Verify device eligibility and model readiness before creating sessions to avoid runtime errors and poor UX.
- Session patterns: Single-turn and multi-turn session management with guidance on instructions, isResponding checks, and lifecycle decisions.
- Structured generation with @Generable: Define Swift types for reliable, typed outputs and use generated PartiallyGenerated types for streaming updates.
- Tool invocation: Expose custom tools for domain-specific actions, handle tool call errors, and integrate tool results into responses.
- Snapshot streaming for UI: Stream partially generated structured snapshots to SwiftUI for progressive rendering and responsive interfaces.
- Best practices & constraints: Guidance on token limits, generation options, avoiding concurrent requests, and monitoring with Instruments.
Quick Start
Write Swift code that checks FoundationModels availability, creates a LanguageModelSession with a custom tool, and generates a TripIdeas @Generable stream for SwiftUI to consume.