langchain-apple-foundation-models
Use Apple's on-device Foundation Models as a drop-in LangChain chat model. Runs fully offline on macOS 26+ Apple Silicon -- no API key, no network call, no per-token cost.
from langchain_apple_foundation_models import ChatAppleFoundationModels
llm = ChatAppleFoundationModels()
llm.invoke("What is the capital of France?")
Install
pip install langchain-apple-foundation-models
Requires macOS 26+ with Apple Intelligence enabled and Apple Silicon.
Why
Apple shipped a Python SDK for its on-device model this year (apple-foundation-models), but there was no LangChain provider for it -- meaning none of LangChain's chains, agents, or tool-calling abstractions could target Apple's on-device model. This closes that gap.
Features
- Tool calling: pass LangChain
@tool-decorated functions via.bind_tools([...]), same as any other LangChain chat model. - Structured output:
.with_structured_output(schema)for JSON-schema or Pydantic-constrained generation. - Streaming:
.stream(...)yields tokens as they're generated. - Zero network calls -- generation happens entirely on-device via Apple's Neural Engine.
Architecture
flowchart LR
App["Your LangChain code<br/>chains / agents / tools"] -->|".invoke() .stream() .bind_tools()"| Provider["ChatAppleFoundationModels"]
Provider --> SDK["apple-foundation-models<br/>(Python SDK)"]
SDK --> FM["Foundation Models framework<br/>on-device, Apple Silicon, Neural Engine"]
FM -.->|"no network call, ever"| SDK
ChatAppleFoundationModels implements LangChain's standard chat model interface, so it drops into any existing chain, agent, or tool-calling setup as a swap-in for a cloud provider -- the only difference is generation happens on-device.
Example: tool calling
from langchain_core.tools import tool
from langchain_apple_foundation_models import ChatAppleFoundationModels
@tool
def get_weather(city: str) -> str:
"""Get the current weather for a city."""
return f"The weather in {city} is sunny and 72F."
llm = ChatAppleFoundationModels().bind_tools([get_weather])
llm.invoke("What's the weather in Austin?")
Known limitations
- Multi-turn history is owned by the underlying
Session, not LangChain's message list. EachChatAppleFoundationModelsinstance lazily creates one on-deviceSessionand reuses it across calls; if you pass a message list that diverges from what the session itself has tracked, the two can get out of sync. Fresh chains work naturally; manually-edited history does not yet. - Built on the
apple-foundation-modelsunofficial Python bindings (alpha), which itself wraps Apple's Foundation Models framework -- both inherit Apple's current 4,096-token context window. - No support (yet) for Apple's newer multi-model / Private Cloud Compute routing announced at WWDC26 -- that requires an OS/SDK combination not yet stable enough to depend on. See the repo issues for status.
License
MIT
Metadata
Release files for langchain-apple-foundation-models 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| langchain_apple_foundation_models-0.2.0.tar.gz | 79.4 kB | Without provenance | Details for langchain_apple_foundation_models-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| langchain_apple_foundation_models-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for langchain_apple_foundation_models-0.2.0-py3-none-any.whl |
Total release size: 86.7 kB
Release files / langchain_apple_foundation_models-0.2.0.tar.gz
| Download URL | langchain_apple_foundation_models-0.2.0.tar.gz |
|---|---|
| Size | 79.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f081c5222eda47653f85883ccdbad8fc768ba74278d9fca076f7e700f692b151
|
|
BLAKE2b-256 checksum How to use checksums |
e2231a96b89156bcc5eec08e73047e0497a443fbdc02f0582fd12a94ea4f561e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Release files / langchain_apple_foundation_models-0.2.0-py3-none-any.whl
| Download URL | langchain_apple_foundation_models-0.2.0-py3-none-any.whl |
|---|---|
| Size | 7.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a5a3283aa32863684164917af76a1a584f73dc36d68d43508927fd57c69d84c5
|
|
BLAKE2b-256 checksum How to use checksums |
d28396117b7725eb7e2b01db074ec46f21d27a07cf0084723c75fc0d35173104
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Security for langchain-apple-foundation-models 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.