
AnyLanguageModel 1.0: One Year of Local Models on Apple Platforms
AnyLanguageModel 1.0 is a Swift package that gives apps Apple's Foundation Models API across the system model, llama.cpp, MLX, Core ML and hosted providers. This release post covers tool calling and guided generation on every provider, image input, and hosted support for OpenAI, Anthropic, Gemini, Ollama and Hugging Face Inference Providers. It also ships swift-huggingface 1.0 and swift-xet 1.0, and lists small open-weight models that fit on iPhone and Mac.
What it claims
AnyLanguageModel 1.0 is a Swift package from Hugging Face that implements Apple's Foundation Models API so the same session code runs against the system model, open-weight models (llama.cpp, MLX, Core ML) and hosted providers. Adoption is an import swap: import FoundationModels becomes import AnyLanguageModel. The release lands after about a year of development, alongside swift-huggingface 1.0 and swift-xet 1.0, which handle accelerated model downloads from the Hub. The package also runs on Linux, so the same code can run on a server.
How it works
Guided generation works on every provider and supports nested @Generable types and arrays of them. Tool calling, with streaming, also works on every provider. Hosted responses report token usage. Images attach to prompts using Foundation Models 27 syntax, including with the system model on iOS, macOS and visionOS 27. On OS 27 the package accepts any model conforming to Foundation Models' LanguageModel protocol, including Core AI models, and adds Private Cloud Compute as a provider.
Reasoning is stored in the transcript. When a session switches providers, reasoning blocks are dropped from requests if the new provider cannot replay them. API keys come from a closure rather than a string, so an app can fetch short-lived tokens from its own server. The README covers when to let users bring their own keys and when to proxy requests.
Hosted backends: OpenAI Chat Completions and Responses, Open Responses-compatible endpoints, Anthropic Messages (with adaptive thinking and effort options), Google Gemini, Ollama, and any OpenAI-compatible endpoint via custom base URL (Hugging Face Inference Providers, OpenRouter).
How to use it
Swift Package Manager dependency, with the MLX backend enabled as a trait:
dependencies: [
.package(
url: "https://github.com/huggingface/AnyLanguageModel",
from: "1.0.0",
traits: ["MLX"]
)
]Hugging Face Inference Providers through the OpenAI-compatible client:
let model = OpenAILanguageModel(
baseURL: URL(string: "https://router.huggingface.co/v1/")!,
apiKey: ProcessInfo.processInfo.environment["HF_TOKEN"]!,
model: "openai/gpt-oss-120b",
apiVariant: .chatCompletions
)A local MLX model:
let model = MLXLanguageModel(modelId: "mlx-community/Qwen3.8-27B-4bit")Suggested starting models with stated sizes: Gemma 4 E2B in GGUF at about 3.4 GB (Q4_0, quantization-aware training) and LFM2.5 2.6B in GGUF at about 1.7 GB (Q4_K_M) both fit on an iPhone. Qwen3.8 27B for MLX is about 16 GB at 4 bits and needs a Mac with 32 GB of memory or more. GLM-5.3 is about 1.5 TB in BF16 and is pointed to Inference Providers instead.
Limits
1.0 includes breaking changes. Upgrades from earlier versions should follow the migration notes in the release notes of all three packages. Image input via the system model, Private Cloud Compute and LanguageModel protocol conformance require OS 27. Reasoning blocks are silently omitted when the target provider cannot replay them. The post gives no performance, latency or quality figures for any backend, and states no licence. Upcoming work is described only as "models that decide, and models that listen."
Organisations named here
Technologies named here
- Swift
- Linux
- AnyLanguageModel
- Gemma 4 E2B
- swift-huggingface
- LFM2.5-2.6B
- Qwen3.8-27B
- swift-xet
- Foundation Models
- GLM-5.3
- gpt-oss-120b
- llama.cpp
- MLX
- Core ML
- Core AI
- Hugging Face Inference Providers
- Ollama
- OpenRouter
- Private Cloud Compute
- OpenAI Chat Completions and Responses APIs
- Open Responses
- Anthropic Messages API
- Google Gemini API
- GGUF
- OpenAI API
- Gemini
- Hugging Face
- Gemma 4
Techniques named here
- Guided generation
- Tool calling
- Quantization-aware training
- Reasoning blocks in the transcript
Related in inference

