explaingit

john-rocky/privatefoundationmodels

Analysis updated 2026-05-18

4SwiftAudience · developerComplexity · 3/5LicenseSetup · moderate

TLDR

A Swift library that lets iOS and macOS apps use Apple's on-device AI model style of code on older OS versions, by falling back to CoreML or MLX runtimes.

Mindmap

mindmap
  root((repo))
    What it does
      Same call site
      Runs on iOS 17 to 26
      Falls back to CoreML or MLX
    Tech stack
      Swift
      CoreML
      MLX
    Use cases
      Ship on-device AI on older iOS
      Bring your own open model
      Expose model over HTTP API
    Audience
      iOS developers
      macOS developers
    Backends
      Apple FoundationModels
      CoreML Neural Engine
      MLX GPU

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Add on-device AI chat features to an iOS app that also needs to support iOS 18.

USE CASE 2

Swap in a custom open-source model from the mlx-community catalogue instead of Apple's built-in model.

USE CASE 3

Expose an on-device Apple model as an OpenAI-compatible HTTP API for non-Swift clients.

USE CASE 4

Write AI features once in Apple's FoundationModels style and stay compatible when dropping older OS support later.

What is it built with?

SwiftCoreMLMLX

How does it compare?

john-rocky/privatefoundationmodelsaydahnizzy/calendar-drag-interactiondizzpy/boo
Stars444
LanguageSwiftSwiftSwift
Setup difficultymoderateeasyeasy
Complexity3/52/52/5
Audiencedeveloperdevelopergeneral

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

Different backends need different minimum OS versions (iOS 17 for MLX, iOS 18 for CoreML, iOS 26 for native Apple passthrough).

MIT lets you use, copy, modify, and distribute this code for any purpose, including commercial products, with only a copyright notice required.

In plain English

PrivateFoundationModels is a Swift library for iOS and macOS developers who want to add on-device AI language model features to their apps, but need those features to work across a wider range of devices and operating system versions than Apple's own framework currently allows. Apple introduced its FoundationModels framework with iOS 26, giving apps access to an on-device AI model that runs privately on the device, with no data sent to a server. The catch is that it only works on iOS 26 and later. PrivateFoundationModels acts as a compatibility layer: you write your code using the same call style as Apple's FoundationModels API, and the library figures out which AI backend to use based on what the device supports. On iOS 26 it passes through to Apple's own framework and on-device model. On iOS 18, it routes to CoreML and the Apple Neural Engine instead. On iOS 17 and above it can also use MLX, a GPU based runtime that can run a wide variety of open models from the mlx-community catalogue. The key benefit is that you write your app code once and it runs correctly on all supported devices without branching logic. When you eventually drop support for older OS versions, switching to Apple's native framework is a simple find and replace of the import name. The library also includes an optional local HTTP server that exposes any of the supported backends using the OpenAI-compatible API format, making it possible for Python or other non-Swift programs to send requests to an on-device Apple model as if they were calling a standard API. It is written in Swift, available as a Swift Package Manager package, and the license is MIT. The full README is longer than what was shown.

Copy-paste prompts

Prompt 1
Show me how to add PrivateFoundationModels to my Swift Package Manager project.
Prompt 2
Explain how PrivateFoundationModels decides which backend, Apple, CoreML, or MLX, to use on a given device.
Prompt 3
Help me set up the OpenAI-compatible local HTTP server from this repo and call it from Python.
Prompt 4
Walk me through migrating my code from PrivateFoundationModels to Apple's native FoundationModels framework.

Frequently asked questions

What is privatefoundationmodels?

A Swift library that lets iOS and macOS apps use Apple's on-device AI model style of code on older OS versions, by falling back to CoreML or MLX runtimes.

What language is privatefoundationmodels written in?

Mainly Swift. The stack also includes Swift, CoreML, MLX.

What license does privatefoundationmodels use?

MIT lets you use, copy, modify, and distribute this code for any purpose, including commercial products, with only a copyright notice required.

How hard is privatefoundationmodels to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is privatefoundationmodels for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.