foundation-models
Safe, idiomatic Rust bindings for Apple's FoundationModels framework — the on-device large language model that ships with Apple Intelligence on macOS 26.0+.
Status: experimental. API surface will change as more of FoundationModels is wrapped (tools, structured generation, transcripts).
Features
- On-device LLM — runs entirely locally on Apple Silicon
- Streaming generation — token-by-token deltas via callback
- Custom instructions — system-prompt style guidance
- Generation options — temperature, max tokens, sampling modes
- Zero dependencies — no
objc2, nocore-foundation, no procedural macros - Async optional — opt-in
asyncfeature for runtime-agnostic awaiting
Requirements
- macOS 26.0 or newer (build host and runtime)
- Xcode 26 SDK (the crate's
build.rsdetects this viaxcrun --sdk macosx --show-sdk-version) - Apple Intelligence enabled in System Settings
- Apple Silicon (Intel Macs are not eligible)
Installation
[]
= { = "0.1", = ["macos_26_0"] }
Quick start
use *;
Streaming
use *;
use Write;
Generation options
use *;
#
Architecture
This crate uses the same Swift-bridge pattern as screencapturekit-rs:
┌────────────────────────────────────────────────────────────┐
│ Safe Rust API (LanguageModelSession, GenerationOptions) │
├────────────────────────────────────────────────────────────┤
│ extern "C" FFI declarations (src/ffi/mod.rs) │
├────────────────────────────────────────────────────────────┤
│ Swift @_cdecl bridge (swift-bridge/Sources/...) │
├────────────────────────────────────────────────────────────┤
│ Apple FoundationModels.framework (Swift, async throws) │
└────────────────────────────────────────────────────────────┘
The Swift layer hides the async throws surface behind callback-based C functions, so the Rust side stays dependency-free.
Roadmap
-
Toolprotocol bridging (function calling) - Structured generation via
Generable(currently Swift-macro-only) -
Transcriptinspection (per-turn token counts, attachments) - Adapter support
- Vision-modality input once Apple ships it
License
Licensed under either of Apache-2.0 or MIT at your option.