foundation-models
Foundation Models
Apple's on-device LLM that powers Apple Intelligence, accessed through the FoundationModels framework (iOS 26+). The deep API reference — availability, text generation, guided generation, the @Generable/@Guide macros, tool calling, streaming, sessions, error handling, guardrails, SwiftUI integration — lives in references/guide.md. This file is the decision and discipline layer: read it first, open the guide for specifics.
Dials
Set these explicitly at the start; they change what "correct" means.
OUTPUT—freeform(default;respond(to:)returns aStringfor chat/prose) ·guided-@Generable(passgenerating: T.self; model emits a type-safe Swift struct/enum — use this for anything your code parses).STREAMING—off(default; oneawaitfor the full result) ·on(streamResponse(...)yields partials as they generate — use for any response long enough that a user would wait).TOOLS—none(default; model answers from its own knowledge) ·tool-calling(passtools:so the model can call your code for live/private data it can't know).
When to use
Building or reviewing any feature that runs Apple's on-device model: chat, summarization, classification, structured extraction, or tool-augmented generation. Use this when the work is local/private/offline inference with no server. For server-class models (large context, complex multi-step reasoning, latest world knowledge) Foundation Models is the wrong tool — route to a hosted API instead.