@orqo/foundationmodels-ai-sdk
v1.0.0
Published
Vercel AI SDK provider adapter for Apple Foundation Models via @orqo/foundationmodels.
Maintainers
Readme
@orqo/foundationmodels-ai-sdk
Vercel AI SDK provider adapter for Apple Foundation Models via @orqo/foundationmodels.
Install
pnpm add @orqo/foundationmodels-ai-sdk @ai-sdk/provider aiUsage
import { createAppleFoundationModelsProvider } from "@orqo/foundationmodels-ai-sdk";
import { generateText, streamText } from "ai";
// Create the provider (connects to the local Foundation Models daemon).
const apple = createAppleFoundationModelsProvider();
// Non-streaming generation — uses the default "apple.system" model.
const { text } = await generateText({
model: apple("apple.system"),
prompt: "Explain on-device AI in one sentence.",
});
console.log(text);
// Streaming generation.
const { textStream } = await streamText({
model: apple("apple.system"),
system: "You are a concise assistant.",
prompt: "List three benefits of on-device AI.",
});
for await (const chunk of textStream) {
process.stdout.write(chunk);
}
// Access the language model instance directly.
const languageModel = apple.languageModel("apple.system");The provider exposes languageModel(modelId) and is callable as a function apple(modelId), both returning an AppleFoundationModelsLanguageModel compatible with the Vercel AI SDK ProviderV3 interface. Embedding, image, transcription, speech, and reranking models are not supported.
