open-source

AnyLanguageModel 1.0: Hugging Face's Drop-In Replacement for Apple's Foundation Models Framework

Summarized by AI from reporting by Hugging Face Blog, published under our editorial policy.

Hugging Face released AnyLanguageModel 1.0, a drop-in replacement for Apple's Foundation Models framework that lets developers use local and hosted AI models with a single API. The update adds guided generation, image support, and support for OpenAI, Anthropic, and Hugging Face Inference Providers.

A developer working on a MacBook, illustrating the use of AnyLanguageModel 1.0 on Apple devices.

Key takeaways

  • AnyLanguageModel 1.0 is a drop-in replacement for Apple's Foundation Models framework that lets developers use local and hosted AI models with a single API.
  • The framework supports guided generation, image prompts, and reasoning blocks across all providers including local and hosted models.
  • AnyLanguageModel 1.0 supports hosted models from OpenAI, Anthropic, and Hugging Face Inference Providers, plus any OpenAI-compatible endpoint.
  • API keys are fetched from a closure instead of a string, allowing apps to use short-lived tokens from a developer's own server.
  • The framework runs on Linux in addition to Apple platforms, so the same code can work on a server.

Hugging Face has released AnyLanguageModel 1.0, a framework that acts as a drop-in replacement for Apple's Foundation Models framework, allowing developers to choose the model and provider their app uses. A year after its initial introduction and dozens of releases, the 1.0 version is now available alongside swift-huggingface 1.0 and swift-xet 1.0.

How AnyLanguageModel 1.0 Lets Developers Switch Models With One Import Statement

AnyLanguageModel 1.0 allows developers to use a variety of AI models with the same code. By changing a single import statement, developers can switch between Apple's system model, open-weight models through llama.cpp, MLX, and Core ML, and hosted providers. The core idea is to use the Foundation Models API with the model that fits your app, making it easier to choose the right model for each task without adding the complexity of supporting multiple inference providers.

The framework supports hosted models from OpenAI's Chat Completions and Responses APIs, Anthropic's Messages API with adaptive thinking and effort options, and Hugging Face Inference Providers. It also supports other OpenAI-compatible endpoints such as OpenRouter through a custom base URL. Hosted providers get the same features as local models: guided generation, tool calling with streaming, and token usage on responses.

Key Features: Guided Generation, Image Support, and Reasoning Blocks

The latest version of AnyLanguageModel includes several major features. Guided generation works with every provider, including nested @Generable types and arrays. Image support lets developers attach images to prompts using Foundation Models 27's syntax, including when using the system model on iOS, macOS, and visionOS 27. On OS 27, AnyLanguageModel also works with any model that conforms to Foundation Models' LanguageModel protocol, including Core AI models.

Reasoning blocks are now part of the transcript. When switching providers, reasoning blocks are automatically omitted from requests if the new provider cannot replay them. API keys come from a closure instead of a string, so apps can fetch short-lived tokens from a developer's own server. The README explains when to let people bring their own keys and when to route requests through a proxy.

Models That Fit on an iPhone and Beyond

While AnyLanguageModel makes local models easier to use, the models themselves have become more capable. The most downloaded models on the Hugging Face Hub include Gemma 4 E2B from Google in GGUF format (about 3.4 GB at Q4_0), LFM2.5 2.6B from Liquid AI in GGUF (about 1.7 GB at Q4_K_M), and Qwen3.8 27B for MLX from Alibaba (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 of code.

Cross-Platform Support and Migration Guidance

AnyLanguageModel also runs on Linux, so the same code can work on a server. For developers upgrading an existing app, migration guidance is available in the AnyLanguageModel, swift-huggingface, and swift-xet release notes. Community feedback and contributions have shaped several major features.

Hugging Face also announced upcoming tools: AnySpeechRecognizer and AnyDecisionModel, which will bring the same approach to speech recognition and decision-making models on Apple platforms.

Frequently asked

Is AnyLanguageModel 1.0 free to use?
The source text does not explicitly state whether AnyLanguageModel 1.0 is free or paid, but it is an open-source framework released by Hugging Face on a blog post, and similar Hugging Face tools are typically open-source and free to use.
Do I need to be a developer to use AnyLanguageModel 1.0?
Yes, AnyLanguageModel 1.0 is designed for developers building apps on Apple platforms. It requires changing import statements and writing Swift code.
Which models can I use with AnyLanguageModel 1.0?
AnyLanguageModel 1.0 supports Apple's system model, open-weight models through llama.cpp, MLX, and Core ML, plus hosted models from OpenAI, Anthropic, and Hugging Face Inference Providers.
Can I use AnyLanguageModel 1.0 on non-Apple devices?
Yes, the framework also runs on Linux, so the same code can work on a server.