What does this skill do?

The Apple FoundationModels Skill for On-Device AI provides proven patterns for integrating Apple's on-device language model into iOS 26+ apps using the FoundationModels framework. It covers text generation, structured output with @Generable, invoking custom tools, and snapshot streaming—all running on-device for maximum privacy and offline support.

Local Text Generation
Create multi-turn sessions with role and style instructions to generate text responses without relying on the cloud.
Structured output with @Generable
Extracts typed data from natural language using structs annotated with @Generable and @Guide for semantic constraints.
Custom Tool Calling
Implement tools by defining the Tool protocol with @Generable annotations for domain-specific AI actions.
Streaming Snapshots in SwiftUI
Render a progressive UI in real time with PartiallyGenerated, without having to manage manual deltas.

Usage examples

💬 Multi-shift session
Create a LanguageModelSession for a cooking assistant that suggests recipes based on available ingredients.
🏗️ Struct @Generable
Define a `PerfilGato` struct with `@Generable` and `@Guide` for name, age (0–20), and personality profile.
🔧 Tool calling
Implement a `BuscarReceta` tool that conforms to the `Tool` protocol with the arguments `termino` and `cantidad`.
📡 Streaming in SwiftUI
Generate the code to stream a structured IdeasViaje response in SwiftUI using PartiallyGenerated.

Features

Check Availability Check SystemLanguageModel.default.availability before creating sessions, and handle cases where the device is ineligible, Apple Intelligence is inactive, or the model is downloading.
Priority Instructions Define the role, task, style, and security measures using the `instructions` parameter, which takes precedence over the prompt.
Three Generation Patterns Use `respond(to:)` for plain text, `respond(to:generating:)` for structured output with `@Generable`, or `streamResponse` for real-time streaming.
Automatic PartiallyGenerated The compiler generates the `PartiallyGenerated` type for streaming, where each snapshot is a complete partial state with optional properties.
Error and Limit Handling Handle ToolCallError using .tool.name and .underlyingError; adhere to the limit of 4,096 tokens and one request per session using isResponding.

Frequently asked questions

iOS 26 or later, with Apple Intelligence enabled and an eligible device. The skill checks SystemLanguageModel.default.availability before running.
Yes. The entire model runs on the device, so it does not require a connection to the cloud once the Apple Intelligence model has been downloaded.
Always use `response.content`, never `.output`. For plain text, it returns a String; for `@Generable`, it returns the structured type with its typed properties.
Yes, using GenerationOptions(temperature:). Keep in mind the limit of 4,096 tokens in total (instructions + prompt + output).
Apple FoundationModels On-Device AI — Local LLM on iOS with Claude AI

¿Prefieres escuchar el contenido? Genera la narración de audio con un clic.