foundation-models-on-device

Generate on-device text and structured outputs with Apple FoundationModels for iOS apps.

Updated May 27, 2025
One-click install
npx skills add https://github.com/vinwang/tools --skill foundation-models-on-device
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: foundation-models-on-device
Source: https://github.com/vinwang/tools/tree/main/iflow/skills/foundation-models-on-device
Command: npx skills add https://github.com/vinwang/tools --skill foundation-models-on-device

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Apple’s FoundationModels enable on-device LLM integration, allowing private, offline generation without data leaving the device.

Core Features & Use Cases

  • On-device text generation with FoundationModels
  • Structured output using @Generable, tool calling, and streaming
  • Privacy-first, offline-capable AI for iOS apps

Quick Start

Create a simple on-device session to generate a short text using the FoundationModels framework.

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 use FoundationModels for on-device text generation in my iOS app?

On-device text generation with FoundationModels is enabled by creating a session within the framework to generate text locally. This approach ensures privacy-first processing and offline capabilities without sending data to external servers.

Can I get structured output from an on-device LLM using @Generable?

Yes, structured output is supported using the @Generable macro for on-device LLM generation. This allows you to define specific data structures and receive formatted responses directly from the FoundationModels framework.

Does FoundationModels support streaming and tool calling for iOS development?

FoundationModels supports both streaming and tool calling for iOS development. These features allow real-time token generation and interaction with external functions, enabling complex generable structures and dynamic app workflows.

What are the limitations of on-device LLMs regarding token windows and availability?

On-device LLM limitations include token window size constraints and the need to satisfy device availability checks. You must verify the device supports FoundationModels and manage context length to ensure successful local generation.

How do I check if an iOS device supports on-device AI before starting a session?

You must perform on-device availability checks to verify FoundationModels support before starting a session. This ensures the iOS device has the necessary hardware and software capabilities for local LLM generation.

Is there a privacy-first way to run generative AI offline in an iOS application?

Using FoundationModels provides a privacy-first method for offline generative AI in iOS applications. Data never leaves the device during generation, ensuring user privacy while supporting structured outputs and streaming.