AnyLanguageModel 1.0: Your Guide to Seamless Integration of AI Models in Swift Apps
Last November, we unveiled AnyLanguageModel, a pioneering drop-in replacement for Apple’s Foundation Models framework, designed to empower app developers with the flexibility to select models and providers that best suit their applications. Since then, we’ve been diligently listening to your feedback, particularly regarding local models and the complexities of integrating multiple inference providers. AnyLanguageModel emerged as a solution to streamline this process while adding robust functionalities.
The Essence of AnyLanguageModel
At its core, AnyLanguageModel aims to simplify the integration of various machine learning models in your app. By simply modifying your import statement from FoundationModels to AnyLanguageModel, you unlock the ability to harness the power of the model that fits your needs without extra technical overhead.
swift
import AnyLanguageModel
With this change, your application can effortlessly work with system models, open-weight models via llama.cpp, MLX, Core ML, and various hosted providers. This unified API allows developers to focus on building remarkable features rather than dealing with integration hurdles.
Major Advancements in Version 1.0
Over the past year of development, we’ve rolled out several critical features that enhance the functionality and versatility of AnyLanguageModel:
- Tool Calling: Now available with every provider, enabling more sophisticated interactions with your models.
- Guided Generation: This feature supports complex structures, including nested
@Generabletypes and arrays. You’ll find it provides a powerful way to generate content efficiently. - Image Support: Attaching images to prompts has never been easier. With the syntax from Foundation Models 27, you can integrate visual inputs when using the system model across iOS, macOS, and visionOS 27.
Additionally, on OS 27, AnyLanguageModel interacts seamlessly with any model conforming to the Foundation Models LanguageModel protocol, including Core AI models, broadening your app’s capabilities significantly.
Expanding Hosted Model Support
The community’s need for more hosted models has been met with considerable enhancements. This version now supports:
- OpenAI’s Chat Completions and Responses APIs
- Adaptive thinking options via Anthropic’s Messages API
- Google’s Gemini API
- Integration with Ollama and several other OpenAI-compatible endpoints
The great aspect of hosted models is that you can use them with the same session code as local implementations, making it remarkably easy to switch between them. Here’s a quick illustration:
swift
let model = OpenAILanguageModel(
baseURL: URL(string: “https://router.huggingface.co/v1/“)!,
apiKey: ProcessInfo.processInfo.environment[“HF_TOKEN”]!,
model: “openai/gpt-oss-120b”,
apiVariant: .chatCompletions
)
With this approach, you can also benefit from the features of local models—like guided generation and tool calling—while accessing powerful cloud capabilities.
Enhancements for Open-weight Models
The advancements aren’t just in functionality; the capabilities of the models have also significantly improved. Some of the most downloaded open-weight models on the Hub include:
- Gemma 4 E2B from Google, compact enough at about 3.4 GB with quantization-aware training.
- LFM2.5 2.6B from Liquid AI, approximately 1.7 GB.
- Qwen3.8 27B for MLX from Alibaba, suited for larger memory environments.
For instance, the LFM2.5 model can run on an iPhone, while Qwen3.8 works beautifully on high-performance Macs. Integrating these models is simple:
swift
let model = MLXLanguageModel(modelId: “mlx-community/Qwen3.8-27B-4bit”)
Moving to Version 1.0
If you’re ready to upgrade your existing apps to AnyLanguageModel 1.0, here’s a straightforward dependency declaration to get you started:
swift
dependencies: [
.package(
url: “https://github.com/huggingface/AnyLanguageModel“,
from: “1.0.0”,
traits: [“MLX”]
)
]
For additional assistance, please refer to the migration guidance provided in the AnyLanguageModel, swift-huggingface, and swift-xet release notes.
Looking Ahead: The Future of AI in Swift
Language models have become indispensable for enhancing the intelligence of applications. However, the potential goes beyond just text generation. There are exciting prospects as we aim to introduce more capabilities to AnyLanguageModel, ensuring that the familiar Swift APIs continue to provide versatility and ease of use for developers. Expect to see models that can make decisions and listen in our forthcoming releases!
Helpful Resources and Community Engagement
Showcasing community-driven development, many of the enhancements in AnyLanguageModel 1.0 come from valuable contributions and feedback from our users. Thank you to everyone who has participated—your input helps us shape a tool that’s robust and incredibly useful for app developers.
As we progress, we invite you to explore the potential of AnyLanguageModel and share your experiences. Let’s build the next generation of intelligent applications together!
Inspired by: Source

