Skip to main content

Python bindings for Apple's Foundation Models Swift framework

Project description

Foundation Models SDK for Python

Python bindings for Apple's Foundation Models framework, providing access to the on-device foundation model at the core of Apple Intelligence on macOS.

Overview

The Foundation Models SDK for Python provides a Pythonic interface to Apple's Foundation Models framework.

You can:

  • Evaluate Swift Foundation Models app features by running batch inference and analyzing results from Python
  • Perform on-device inference with the system foundation model
  • Stream real-time text generation responses
  • Use guided generation with structured output schemas and constraints
  • Get type-safe responses using Python decorators for guided generation
  • Configure custom model settings for different model options
  • Process transcripts exported from Swift apps for quality analysis

Keep in mind that it's your responsibility to design AI experiences with care. To learn about practical strategies you can implement in code, check out: Improving the safety of generative model output and Apple's Human Interface Guidelines on Generative AI.

Requirements

Contributing

This project is not yet taking contributions. Stay tuned!

Installation

pip install apple-fm-sdk

Alternatively, you can use the development install instructions below.

Documentation

Basic usage

import apple_fm_sdk as fm
import asyncio

async def main():
    # Get the default system foundation model
    model = fm.SystemLanguageModel()

    # Check if the model is available
    is_available, reason = model.is_available()
    if is_available:
        # Create a session
        session = fm.LanguageModelSession()

        # Generate a response
        response = await session.respond("Hello, how are you?")
        print(f"Model response: {response}")
    else:
        print(f"Foundation Models not available: {reason}")

# Run async function
asyncio.run(main())

Development Installation

If you need to modify the SDK or install from source:

  1. Get the code
git clone https://github.com/apple/python-apple-fm-sdk
cd python-apple-fm-sdk
  1. (Optional but recommended) Make a virtual environment. Install uv (or your package manager of choice) then:
uv venv
source .venv/bin/activate
  1. Install the package locally in editable mode:
uv sync
  1. After making any change, be sure to build the project again and test:
uv pip install -e .
pytest

For licensing see accompanying LICENSE file. Copyright (C) 2026 Apple Inc. All Rights Reserved.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

apple_fm_sdk-0.1.0.tar.gz (83.4 kB view details)

Uploaded Source

File details

Details for the file apple_fm_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: apple_fm_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 83.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for apple_fm_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6ea94d27a3fb0c3c97cbae1743c151f5f9239267ddd6dc713d545382d8b70110
MD5 f40764861f0a9a5128adeb8686b41323
BLAKE2b-256 ec9cebdffc045b20719c20a07a7517256c37e146adc11f6a2111d920897c4f81

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page