@orqo/foundationmodels
v2.0.0
Published
TypeScript runtime for Apple Foundation Models — classify, extract, rank, summarize, stream, and agent loops on-device.
Maintainers
Readme
@orqo/foundationmodels
TypeScript runtime for Apple Foundation Models — classify, extract, rank, summarize, stream, and agent loops on-device.
Install
pnpm add @orqo/foundationmodelsUsage
import { createFoundationModels } from "@orqo/foundationmodels";
// Create the runtime (connects to the local Foundation Models daemon).
const fm = await createFoundationModels();
// Single-turn text generation.
const result = await fm.respond({
instructions: "You are a helpful assistant.",
input: "What is the capital of France?",
});
console.log(result.content); // "Paris"
// Structured extraction with a Zod schema.
import { z } from "zod";
const schema = z.object({ city: z.string(), country: z.string() });
const extracted = await fm.extract({ input: "Paris is in France.", schema });
console.log(extracted.object); // { city: "Paris", country: "France" }
// Streaming.
for await (const event of fm.stream({ input: "Tell me a story." })) {
if (event.type === "text_delta") process.stdout.write(event.delta);
}
// Classify text into labels.
const cls = await fm.classify({ input: "I love this product!", labels: ["positive", "negative"] });
console.log(cls.labels); // [{ id: "positive", confidence: 0.97 }, ...] ClassificationLabel[]
// Check model availability.
const report = await fm.availability();
console.log(report.models.map((m) => m.id));See @orqo/foundationmodels-ai-sdk for Vercel AI SDK integration and @orqo/foundationmodels-server for an OpenAI-compatible HTTP server.
Author
Cristiano Aredes — sole author and maintainer.
- GitHub: @cristianoaredes
- X: @CristianoAredes
- LinkedIn: Cristiano Aredes
Part of FoundationModels JS.
License
AGPL-3.0-only — see LICENSE. Copyright © 2026 Cristiano Aredes.
Network clause (AGPL §13): modified versions offered as a network service must provide Corresponding Source to users of that service.
