Python bindings for access to the on-device model at the core of Apple Intelligence through the Foundation Models framework
1,229
stars
10
commits
Python
primary language
Jul 7, 2026
updated
Python bindings for Apple's Foundation Models framework, providing access to the on-device foundation model at the core of Apple Intelligence on macOS.
The Foundation Models SDK for Python provides a Pythonic interface to Apple's Foundation Models framework.
You can:
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.
This project is not yet taking contributions. Stay tuned!
pip install apple-fm-sdk
Alternatively, you can use the development install instructions below.
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())
You can also use guided generation to ask the model to generate an
object from a specific Python class marked with the generable decorator:
import apple_fm_sdk as fm
@fm.generable # This decorator signals this type be generated by a model
class Cat:
name: str
age:int = fm.guide("Age in years", range=(0, 20))
async def generate_cat():
# 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 of the type Cat
cat = await session.respond("Generate an adorable rescue cat", generating=Cat)
print(f"Model response: {cat}")
else:
print(f"Foundation Models not available: {reason}")
If you need to modify the SDK or install from source:
git clone https://github.com/apple/python-apple-fm-sdk
cd python-apple-fm-sdk
uv venv
source .venv/bin/activate
uv sync
uv pip install -e .
pytest
For licensing see accompanying LICENSE file. Copyright (C) 2026 Apple Inc. All Rights Reserved.
Python
84.4%
Swift
11.4%
Shell
2.4%
C
1.8%
Python bindings for access to the on-device model at the core of Apple Intelligence through the Foundation Models framework
1,229
stars
10
commits
Python
primary language
Jul 7, 2026
updated
Python bindings for Apple's Foundation Models framework, providing access to the on-device foundation model at the core of Apple Intelligence on macOS.
The Foundation Models SDK for Python provides a Pythonic interface to Apple's Foundation Models framework.
You can:
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.
This project is not yet taking contributions. Stay tuned!
pip install apple-fm-sdk
Alternatively, you can use the development install instructions below.
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())
You can also use guided generation to ask the model to generate an
object from a specific Python class marked with the generable decorator:
import apple_fm_sdk as fm
@fm.generable # This decorator signals this type be generated by a model
class Cat:
name: str
age:int = fm.guide("Age in years", range=(0, 20))
async def generate_cat():
# 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 of the type Cat
cat = await session.respond("Generate an adorable rescue cat", generating=Cat)
print(f"Model response: {cat}")
else:
print(f"Foundation Models not available: {reason}")
If you need to modify the SDK or install from source:
git clone https://github.com/apple/python-apple-fm-sdk
cd python-apple-fm-sdk
uv venv
source .venv/bin/activate
uv sync
uv pip install -e .
pytest
For licensing see accompanying LICENSE file. Copyright (C) 2026 Apple Inc. All Rights Reserved.
Python
84.4%
Swift
11.4%
Shell
2.4%
C
1.8%