What's the easiest way to call the on-device LLM?

Asked on 06/11/2025

32 searches

The easiest way to call the on-device large language model (LLM) using Apple's Foundation Models framework is by following a simple process that involves just a few lines of code. Here's a brief overview:

  1. Import the Framework: Start by importing the Foundation Models framework into your project.

  2. Create a Session: Set up a session with the on-device LLM. This session will handle the interaction with the model.

  3. Send Your Prompt: Send your prompt to the model. The prompt can be a string variable, such as "generate a bedtime story about a fox," and it can be written in any language supported by Apple Intelligence.

This process is highlighted in the session Discover machine learning & AI frameworks on Apple platforms, where it is mentioned that prompting the model is as easy as three lines of code. The framework is designed to work offline, ensuring user data privacy without the need for API keys or accounts.

What's the easiest way to call the on-device LLM? | Ask WWDC