Hugging Face ships AnyLanguageModel 1.0, a Swift drop-in for Apple's Foundation Models

Hugging Face ships AnyLanguageModel 1.0, a Swift drop-in for Apple's Foundation Models

Hugging Face announced AnyLanguageModel 1.0 about a year after it first introduced the library on its blog. It is released together with swift-huggingface 1.0 and swift-xet 1.0, and the post says it comes "a year and dozens of releases" after the first version.

The library started as a drop-in replacement for Apple's Foundation Models framework that lets an app choose which model and provider it uses. Hugging Face says it grew out of feedback from app developers who were curious about local models but unsure how to start, and who wanted to avoid the complexity of supporting several inference providers. The company's argument is that local and hosted inference each have strengths, and a shared API makes it easier to pick the right model for each task.

The core idea is unchanged: use the Foundation Models API with whichever model fits the app. Getting started means replacing import FoundationModels with import AnyLanguageModel. The same session code then works with the system model, with open-weight models through llama.cpp, MLX and Core ML, and with hosted providers.

The major features added over the year: tool calling works with every provider; guided generation works with every provider too, including nested @Generable types and arrays of them; and image support lets developers attach images to prompts using Foundation Models 27's syntax, including with the system model on iOS, macOS and visionOS 27. On OS 27, the library also works with any model that conforms to Foundation Models' LanguageModel protocol, including Core AI models. Alongside it, swift-huggingface and swift-xet were built out to bring accelerated model downloads from the Hub to Swift apps.

Hosted-model support expanded as well. The library now supports OpenAI's Chat Completions and Responses APIs, Open Responses (for any provider with a compatible endpoint), Anthropic's Messages API (with adaptive thinking and effort options), Google's Gemini API, Ollama, Private Cloud Compute on OS 27, and Hugging Face Inference Providers plus other OpenAI-compatible endpoints such as OpenRouter through a custom base URL. The post shows Inference Providers being used for open-weight models too big for a device, for example openai/gpt-oss-120b, via an OpenAILanguageModel pointed at router.huggingface.co with the chatCompletions variant. Hosted providers get the same features as local models: guided generation, tool calling with streaming, and token usage on responses.

Two details matter for apps that switch providers or ship to users. Reasoning is now part of the transcript, and when you switch providers, reasoning blocks are automatically omitted from requests if the new provider can't replay them. API keys come from a closure instead of a string, so an app can fetch short-lived tokens from its own server; the README explains when to let people bring their own keys and when to route requests through a proxy. The library also runs on Linux, so the same code can work on a server.

The post also argues that open-weight models have become more capable, making small ones a good place to start. It lists three of the most downloaded models on the Hub right now: Google's Gemma 4 E2B in GGUF, about 3.4 GB at Q4_0 with quantization-aware training; Liquid AI's LFM2.5 2.6B in GGUF, about 1.7 GB at Q4_K_M; and Alibaba's Qwen3.8 27B for MLX, about 16 GB at 4 bits. The first two fit on an iPhone, and Qwen3.8 27B runs on a Mac with 32 GB of memory or more. Selecting the MLX model takes one line, MLXLanguageModel(modelId: "mlx-community/Qwen3.8-27B-4bit"). For scale, the post jokes that anyone with four maxed-out Mac Studios could hold Z.ai's GLM-5.3, which takes about 1.5 TB in BF16; for everyone else it is available through Inference Providers.

Upgrading means pointing the Swift package dependency at github.com/huggingface/AnyLanguageModel from 1.0.0, with the MLX trait enabled if needed. Existing apps should follow the migration guidance in the release notes of AnyLanguageModel, swift-huggingface and swift-xet. Hugging Face thanks community contributors, saying their feedback and contributions shaped several major features.

Looking ahead, the post says language models are one of many kinds of models developers can use, and Hugging Face wants to bring the same approach of familiar Swift APIs with a choice of on-device models to more capabilities. Its only specific hint: "Coming soon: models that decide, and models that listen."

Key facts

  • AnyLanguageModel 1.0 is out together with swift-huggingface 1.0 and swift-xet 1.0, a year and dozens of releases after the library was introduced.
  • Migration from Apple's Foundation Models starts with one change: import AnyLanguageModel instead of FoundationModels. The same session code then runs on the system model, llama.cpp, MLX, Core ML or hosted providers.
  • Tool calling and guided generation (including nested @Generable types) work with every provider; image support follows Foundation Models 27's syntax on iOS, macOS and visionOS 27.
  • Hosted support covers OpenAI, Open Responses, Anthropic, Gemini, Ollama, Private Cloud Compute on OS 27, and Hugging Face Inference Providers or other OpenAI-compatible endpoints such as OpenRouter.
  • The post names Gemma 4 E2B (about 3.4 GB) and LFM2.5 2.6B (about 1.7 GB) as models that fit on an iPhone, and Qwen3.8 27B (about 16 GB at 4 bits) as one for a Mac with 32 GB or more.

Why it matters

Apple's Foundation Models framework gives Swift developers one API for the system model. AnyLanguageModel keeps that API but lets an app swap in other models, local or hosted, without rewriting session code. Hugging Face frames it as removing the complexity of supporting multiple inference providers, and as a way to choose the right model for each task. The 1.0 release adds tool calling and guided generation across all providers, so the shared API is not limited to a lowest common denominator of basic text generation.

Who it affects

Mainly app developers on Apple platforms (iOS, macOS, visionOS) who use or are considering Foundation Models and want to try open-weight models or third-party hosted ones. The Linux support extends it to developers who want the same Swift code on a server. Teams already on the Hugging Face Hub also get faster model downloads through swift-huggingface and swift-xet.

How to use it

Replace import FoundationModels with import AnyLanguageModel; the same session code then works across providers. Add the Swift package from github.com/huggingface/AnyLanguageModel with from: "1.0.0", and enable the MLX trait if you want MLX models. A local model is one line, for example MLXLanguageModel(modelId: "mlx-community/Qwen3.8-27B-4bit"). For models too big for a device, use OpenAILanguageModel with the Inference Providers base URL (https://router.huggingface.co/v1/), an HF_TOKEN and a model name such as openai/gpt-oss-120b. Supply API keys from a closure so the app can fetch short-lived tokens from its own server, and check the README on when to let users bring their own keys versus using a proxy. Existing users should read the migration guidance in the three release notes.

How solid is it

This is Hugging Face's own announcement of its own release, and it reads as a feature overview rather than an evaluation. The post gives model file sizes and a feature list but no benchmark results, download counts or performance figures for the library itself. The sizes for Gemma 4 E2B, LFM2.5 2.6B, Qwen3.8 27B and GLM-5.3 are approximate, as the post states them.

Risks and caveats

Several features depend on OS 27: image support with the system model, Private Cloud Compute, and compatibility with any model conforming to the LanguageModel protocol, including Core AI models. The post does not say which Apple OS release dates correspond to OS 27. Switching providers mid-conversation has a side effect: reasoning blocks are omitted from requests if the new provider can't replay them. Shipping apps that call hosted providers raises the key-handling question the post flags, whether to let users bring their own keys or route through a proxy. The "models that decide" and "models that listen" promised for later come without a date or details.

“use the Foundation Models API with the model that fits your app.”

— Hugging Face, AnyLanguageModel 1.0 announcement