foundation-models-on-device

Installation
Summary

On-device LLM integration for iOS 18+ using Apple's FoundationModels framework with privacy-first text generation and structured output.

  • Covers text generation, structured output via @Generable macro, custom tool calling, and snapshot streaming—all running locally without cloud dependency
  • Requires availability checks before session creation; supports single-turn and multi-turn conversations with optional system instructions
  • Guided generation with @Guide constraints (numeric ranges, array counts, semantic hints) produces strongly-typed Swift structs instead of raw strings
  • Tool calling lets models invoke custom functions for domain-specific tasks; streaming mode progressively yields partial results for real-time UI updates
  • 4,096 token context limit applies across instructions, prompt, and output combined; single request per session enforced via isResponding flag
SKILL.md

FoundationModels: On-Device LLM (iOS 26)

Patterns for integrating Apple's on-device language model into apps using the FoundationModels framework. Covers text generation, structured output with @Generable, custom tool calling, and snapshot streaming — all running on-device for privacy and offline support.

When to Activate

  • Building AI-powered features using Apple Intelligence on-device
  • Generating or summarizing text without cloud dependency
  • Extracting structured data from natural language input
  • Implementing custom tool calling for domain-specific AI actions
  • Streaming structured responses for real-time UI updates
  • Need privacy-preserving AI (no data leaves the device)

Core Pattern — Availability Check

Always check model availability before creating a session:

struct GenerativeView: View {
Related skills
Installs
3.3K
GitHub Stars
180.7K
First Seen
Feb 24, 2026