tsfm-sdk
v0.4.0
Published
Unofficial TypeScript bindings for Apple Foundation Models framework (Apple Intelligence on-device LLM)
Readme
- On-device inference — your data never leaves the machine
- Streaming text generation
- Structured output with typed schemas and generation guides
- Tool calling
- Transcript persistence
- Chat-style and Responses-style APIs via
tsfm-sdk/chat
Quick Start
npm install tsfm-sdkimport { SystemLanguageModel, LanguageModelSession } from "tsfm-sdk";
const model = new SystemLanguageModel();
const { available } = await model.waitUntilAvailable();
if (!available) process.exit(1);
const session = new LanguageModelSession({
instructions: "You are a concise assistant.",
});
const reply = await session.respond("What is the capital of France?");
console.log(reply); // "The capital of France is Paris."
session.dispose();
model.dispose();Documentation
- Getting Started — installation, requirements, first steps
- Sessions — text generation, concurrency, cancellation
- Streaming — token-by-token response streaming
- Structured Output — typed schemas with generation guides
- Tools — function calling
- Chat & Responses APIs — familiar Chat-style and Responses-style interfaces
- API Reference — complete API docs
- Examples — runnable code for every feature
Requirements
- Apple Silicon (M-Series) Mac running macOS 26 or later
- Apple Intelligence enabled in System Settings
- Node.js 24+
Unless you are building from source, Xcode is not required.
Development
npm run build # build native dylib + compile TypeScript
npm test # run all tests
npm run test:unit # unit tests only (works on any machine)
npm run test:integration # integration tests (requires macOS 26 + Apple Intelligence)Contributing
Issues and PRs welcome. If something doesn't work on your machine or you find a missing API, open an issue.
License
© 2026 Cody Bromley and contributors.
tsfm is licensed under the Apache 2.0 license. For complete licensing information, see this project's LICENSE file.
The tsfm-sdk package available from NPM contains precompiled C bindings and libraries for working with macOS 26 Foundation Models adapted from python-apple-fm-sdk which is Copyright Apple Inc. and licensed under the Apache 2.0 license.
This project is unaffiliated with Apple, Inc. The terms "Apple" and "Apple Intelligence" are trademarks of Apple Inc., registered in the U.S. and other countries and regions.
