Hugging FaceMatttAnnouncement
AnyLanguageModel 1.0: One Year of Local Models on Apple Platforms
Summary
AnyLanguageModel 1.0, alongside swift-huggingface 1.0 and swift-xet 1.0, marks a year of development on a drop-in replacement for Apple’s Foundation Models framework that lets developers choose the model and provider. It provides a unified API for switching between local models (llama.cpp, MLX, Core ML) and hosted providers (OpenAI, Anthropic, Google Gemini, Ollama, Hugging Face). The update adds tool calling and guided generation support for all providers, image input using Foundation Models’ syntax on OS 27, and reasoning that appears in transcripts. API keys are supplied through closures instead of strings, enabling apps to fetch short-lived tokens from their own server. Local open-weight models such as Gemma 4 E2B and LFM2.5 2.6B fit on an iPhone, while Qwen3.8 27B runs on a Mac with 32 GB of memory, all loadable with a single line of code.
Context
A year after introducing AnyLanguageModel as a drop-in replacement for Apple’s Foundation Models framework, the team is releasing version 1.0 alongside swift-huggingface 1.0 and swift-xet 1.0.
Approach / What changed
AnyLanguageModel provides a unified Swift API that works with Apple’s Foundation Models, local inference engines (llama.cpp, MLX, Core ML), and hosted providers (OpenAI, Anthropic, Gemini, etc.). Key features include tool calling, guided generation, image input, reasoning in transcripts, and secure API key management via closures. The library also runs on Linux.
Takeaways
AnyLanguageModel 1.0 provides a drop-in replacement for Apple’s Foundation Models framework, requiring only a change of import statement to switch models.
Tool calling and guided generation are supported across all providers, including local models via llama.cpp, MLX, Core ML, and hosted providers like OpenAI and Anthropic.
API keys are supplied through closures instead of strings, allowing apps to fetch short-lived tokens from a server for better security.
FAQ
How do I integrate AnyLanguageModel into my app?
Change your import statement from `import FoundationModels` to `import AnyLanguageModel`. The same session code then works with system models, open-weight models through llama.cpp, MLX, and Core ML, and with hosted providers.
Which hosted providers are supported?
OpenAI's Chat Completions and Responses APIs, Anthropic's Messages API, Google's Gemini API, Ollama, Private Cloud Compute on OS 27, Hugging Face Inference Providers, and OpenAI-compatible endpoints like OpenRouter.
How does API key management work?
API keys are provided via closures instead of strings, enabling apps to fetch short-lived tokens from their own server. The README explains when to let people bring their own keys and when to route requests through a proxy.
Source and freshness
- Source
- huggingface.co
- Published
- Added to Yomu
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.