AnyLanguageModel offers a Foundation Models-style API across local and cloud LLMs
Hugging Face
- Developer tools
- Models
- #swift
- #foundation models
- #mlx
- #llama.cpp
Browse Developer tools topic page →
A Hugging Face blog post announces AnyLanguageModel, a Swift package that mirrors Apple's Foundation Models API so developers can switch between Apple's system model, local backends such as MLX, Core ML and llama.cpp, and cloud providers. The post describes opt-in package traits and experimental image support, and notes the project is pre-1.0.
What the announcement describes
The publisher's post introduces AnyLanguageModel as a Swift package that keeps Apple's Foundation Models session API while allowing other model backends behind it. A developer would keep code such as LanguageModelSession and change the import from FoundationModels to AnyLanguageModel, then choose a model object — the post shows Apple's system model and, alternatively, an MLX-served quantized model. The post lists Apple Foundation Models, Core ML, MLX, llama.cpp, Ollama, OpenAI, Anthropic, Google Gemini and Hugging Face Inference Providers as supported routes, framing local downloadable models as the focus and cloud providers as a starting point and migration path. Dependencies are controlled through Swift 6.1 package traits (CoreML, MLX, Llama); by default only the base API and URLSession-based cloud providers are pulled in. The author also extends image prompts, which Foundation Models does not currently offer, and acknowledges that Apple may later ship a conflicting design. The package is pre-1.0, with tool calling, MCP integration, guided generation and local-inference optimizations listed as work in progress.
Scenario for an iOS engineering lead
An iOS team maintaining an on-device feature might want to compare Apple's system model with a locally downloaded open model without rewriting view logic around two different client APIs. Because the post describes a shared session abstraction and opt-in traits, a lead could scope a spike that wires one existing prompt path to the system model and, in a branch, to an MLX model, keeping UI code unchanged. The post's stated motive — that integration friction discourages developers from discovering local models — suggests the comparison itself is the point, not an immediate production switch. This remains a proposal: the excerpt does not report anyone completing such a comparison, and support depth may vary by backend.
Running a bounded trial
A team could try a small, reversible experiment: pick one representative prompt or task, record current output and latency from the existing baseline (for example, the system model), then run the same inputs through one explicitly enabled backend such as MLX. Measure output quality by human review, along with response time and build-size impact from the added trait. Keep the change behind a trait and a feature flag so it can be reverted. Failure checks should include cancellation or error handling when the backend is unavailable, and verification that only needed dependencies were pulled in. Because tool calling and guided generation are still in progress per the post, avoid relying on those features in the trial. Any output shown to end users should keep human review in the loop.
Trade-offs and when to hold back
Building on Foundation Models inherits its limits; the post says the framework intentionally represents a lowest common denominator, and image support had to be added outside it, with the risk of future conflict with Apple's own design. Each extra backend adds configuration and maintenance surface, even with traits. Prerequisites include Swift 6.1 for traits, and the post notes Xcode projects need a small internal package to declare them. The excerpt gives no performance numbers, licensing details or measured reliability across providers, so teams should not assume parity of features such as tool calling. If a product depends on structured outputs, tools or MCP today, the post indicates those are unfinished, so waiting or isolating the dependency may be wiser than adopting now.
Context and limitations
- Based on a short excerpt of the publisher's blog post; the full article and library code were not analyzed.
- The package is described as pre-1.0, with tool calling, MCP, guided generation and local-inference optimizations still in progress.
- Claims about provider support and image handling come from the publisher, not independent testing.
- Based on bounded source text, not independent testing. Practical suggestions are editorial proposals.