how could developers leverage the foundation models in their apps

Asked on 06/11/2025

1 search

Developers can leverage the Foundation Models framework in their apps to create intelligent features that run on-device, ensuring privacy and offline availability. Here are some ways developers can utilize this framework:

  1. Prompt Engineering: Developers can start by crafting effective prompts to interact with the model. This involves using Xcode's Playground to test and refine prompts, allowing the model to generate desired outputs, such as itineraries or personalized content. For more details, you can refer to the Code-along: Bring on-device AI to your app using the Foundation Models framework session.

  2. Tool Calling: The framework supports tool calling, which allows the model to autonomously execute code defined in your app. This can be used to fetch up-to-date content or perform actions like creating a journal entry. This feature enhances the model's capabilities by integrating it with app-specific functions. More information can be found in the Deep dive into the Foundation Models framework session.

  3. Structured Output: Developers can use guided generation to produce structured data, making it easier to integrate model outputs into app views. This involves marking existing types in your app as generable and using natural language guides to control generated values.

  4. Safety and Guardrails: The framework includes built-in guardrails to ensure safe content generation. Developers are encouraged to design their apps with additional safety measures to handle user input responsibly and avoid generating inappropriate content. For more on this, see the Explore prompt design & safety for on-device foundation models session.

  5. Performance Optimization: The framework is optimized for performance using state-of-the-art techniques like quantization and speculative decoding. Developers can profile and optimize their app's use of the model using tools like the Instruments App Profiling template.

By leveraging these capabilities, developers can create powerful, private, and performant features across Apple's platforms, enhancing user experiences with intelligent, on-device AI.