AnyLanguageModel: A Unified LLM API for Apple Platforms
AnyLanguageModel provides a unified interface for local and remote LLMs
Hugging Face has announced AnyLanguageModel, a Swift package designed to reduce the friction of integrating Large Language Models (LLMs) into Apple platform applications. The library acts as a drop-in replacement for Apple's Foundation Models framework, allowing developers to switch between local open-source models and cloud-based frontier models by changing a single import statement while maintaining the same API.
Support for diverse model providers
AnyLanguageModel enables developers to use a wide array of backends through a consistent interface. This approach allows for rapid experimentation, enabling developers to start with cloud providers and migrate to local models once the use case is validated.
Supported providers include:
- Apple Foundation Models: Native integration for macOS 26+ and iOS 26+.
- Local Inference: Support for Core ML (Neural Engine acceleration), MLX (Apple Silicon optimization), llama.cpp (GGUF models), and Ollama (HTTP API).
- Cloud Providers: Integration with OpenAI, Anthropic, and Google Gemini.
- Hugging Face Inference Providers: Access to hundreds of cloud models via Hugging Face.
API design based on Apple's Foundation Models
AnyLanguageModel uses Apple's Foundation Models framework as its base API template rather than creating a new abstraction. This design choice was made for three primary reasons:
- Ergonomics: The existing framework leverages Swift macros and abstractions for sessions, tools, and generation that map well to LLM functionality.
- Low Conceptual Overhead: Because most Swift developers targeting Apple platforms will encounter the Foundation Models API, building upon it reduces the learning curve.
- Stability: Using a "lowest common denominator" approach avoids excessive layers of abstraction that can distance developers from the problem they are solving.
Optimized dependency management via Swift 6.1 package traits
To prevent dependency bloat, AnyLanguageModel utilizes Swift 6.1 package traits. This allows developers to opt-in only to the specific backends they need, ensuring that heavy dependencies are not pulled into the project unnecessarily.
Available traits include CoreML, MLX, and Llama (for llama.cpp / llama.swift). By default, the package includes the base API and cloud providers, which rely only on standard URLSession networking.
Extended capabilities for vision-language models
While Apple's current Foundation Models framework does not support sending images with prompts, AnyLanguageModel extends the API to support vision-language models (VLMs). This allows developers to send images to compatible models (such as Claude) to perform tasks like image description, text extraction from screenshots, and chart analysis.
Roadmap and future developments
AnyLanguageModel is currently in a pre-1.0 state. The core API is stable, but the project is actively working to bring the following features to all adapters:
- Tool calling across all providers.
- MCP integration for tools and elicitations.
- Guided generation for structured outputs.
- Performance optimizations for local inference.
The goal is to provide the necessary scaffolding for building seamless agentic workflows on Apple platforms, where models can access system resources and utilize tools to complete complex tasks.