foundation-models-on-device

Generate on-device LLM text with FoundationModels LanguageModelSession APIs.

1|Updated Mar 6, 2026
One-click install
npx skills add https://github.com/khetansarvesh/ai_skills_repo --skill foundation-models-on-device-khetansarvesh
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: foundation-models-on-device
Source: https://github.com/khetansarvesh/ai_skills_repo/tree/main/skills/foundation-models-on-device
Command: npx skills add https://github.com/khetansarvesh/ai_skills_repo --skill foundation-models-on-device-khetansarvesh

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It solves the problem of building LLM-powered features that must run privately and reliably without sending user data to the cloud, including the need to generate structured outputs and stream results into an app UI.

Core Features & Use Cases

  • On-device text generation: Generate responses fully on-device for offline and privacy-preserving apps, using Apple’s FoundationModels framework.
  • Structured output with @Generable: Produce strongly-typed, schema-guided results for tasks like extracting fields from user input (e.g., form-like answers) instead of parsing raw text.
  • Custom tool calling: Enable the model to invoke app-specific logic (e.g., search, lookup, compute) by defining tools with typed arguments.
  • Snapshot streaming for UI: Stream partially generated structured results to progressively update SwiftUI views in real time.

Quick Start

Use the foundation-models-on-device skill to generate a typed, streaming summary of user-provided notes on a supported iOS device by first checking model availability and then calling a LanguageModelSession with @Generable.

Frequently Asked Questions about foundation-models-on-device

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run an LLM on-device with iOS for privacy-preserving text generation?

You can run an LLM on-device with iOS by using Apple's FoundationModels framework and LanguageModelSession APIs to generate text fully offline without sending user data to the cloud.

How do I stream partial LLM output to a SwiftUI view in real time?

Stream partial LLM output to SwiftUI by using snapshot streaming with LanguageModelSession, which progressively updates UI views as structured generation results are produced.

How do I extract structured data from user input using the iOS FoundationModels framework?

Extract structured data from user input by applying the @Generable attribute to define schema-guided types, allowing the on-device LLM to return strongly-typed results instead of raw text.

Can I enable custom tool calling with typed arguments in an on-device iOS LLM?

Yes, you can enable custom tool calling in an on-device iOS LLM by defining tools with typed arguments, allowing the FoundationModels framework to invoke app-specific logic like search or compute.

How do I handle model availability checks before starting a LanguageModelSession on iOS?

Handle model availability by enforcing eligibility and unavailability checks before initializing a LanguageModelSession, ensuring your iOS 26+ app safely manages multi-turn sessions when the on-device model is inaccessible.

What are the limitations of using on-device LLMs for iOS app features?

Limitations of on-device LLMs on iOS include strict platform requirements, as the FoundationModels framework requires iOS 26+, and the necessity to handle model unavailability scenarios when device eligibility checks fail.