AnyLanguageModel 1.0: One Year of Local Models on Apple Platforms
Back to Articles AnyLanguageModel 1.0: One Year of Local Models on Apple Platforms Published October 20, 2026 Update on GitHub Upvote 4 Mattt mattt Follow Last November, we introduced AnyLanguageModel on this blog: a drop-in replacement for Apple’s Foundation Models framework that lets you choose the model and provider your app uses. We heard from app developers who were curious about local models but weren’t always sure how to get started. They also wanted to avoid the added complexity of supporting multiple inference providers. AnyLanguageModel grew out of that feedback. Local and hosted inference each have their strengths, and both have a role in building this new generation of intelligent apps. A shared API makes it easier to choose the right model for each task. A year and dozens of releases later, AnyLanguageModel 1.0 is out, along with swift-huggingface 1.0 and swift-xet 1.0. Here’s what changed, and what’s next:
返回文章 AnyLanguageModel 1.0:Apple 平台本地模型的一年,发布于 2026 年 10 月 20 日。去年 11 月,我们在博客上介绍了 AnyLanguageModel:它是 Apple Foundation Models 框架的直接替代品,允许您选择应用程序使用的模型和提供商。我们从开发者那里了解到,他们对本地模型感到好奇,但并不总是知道如何开始。他们还希望避免支持多个推理提供商所带来的额外复杂性。AnyLanguageModel 正是基于这些反馈而诞生的。本地推理和托管推理各有优势,在构建新一代智能应用时都发挥着作用。共享 API 使为每项任务选择合适的模型变得更加容易。一年过去了,经过数十次发布,AnyLanguageModel 1.0 现已推出,同时发布的还有 swift-huggingface 1.0 和 swift-xet 1.0。以下是变化内容及未来计划:
A drop-in compatible API The core idea of AnyLanguageModel remains the same: use the Foundation Models API with the model that fits your app. To get started, change your import statement: - import FoundationModels + import AnyLanguageModel The same session code then works with the system model, with open-weight models through llama.cpp, MLX, and Core ML, and with the hosted providers below. Over the past year, we’ve added several major features: Tool calling works with every provider. Guided generation works with every provider, too, including nested @Generable types and arrays of them. Image support lets you attach images to prompts using Foundation Models 27’s syntax, including when you use 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. Alongside AnyLanguageModel, we’ve built out swift-huggingface and swift-xet to bring accelerated model downloads from the Hub to Swift apps.
直接兼容的 API。AnyLanguageModel 的核心理念保持不变:使用适合您应用的 Foundation Models API。要开始使用,请更改您的导入语句:- import FoundationModels + import AnyLanguageModel。同样的会话代码随后即可与系统模型、通过 llama.cpp、MLX 和 Core ML 运行的开放权重模型,以及下方的托管提供商配合使用。在过去的一年中,我们增加了几个主要功能:工具调用适用于所有提供商。引导式生成也适用于所有提供商,包括嵌套的 @Generable 类型及其数组。图像支持允许您使用 Foundation Models 27 的语法将图像附加到提示词中,包括在 iOS、macOS 和 visionOS 27 上使用系统模型时。在 OS 27 上,AnyLanguageModel 还适用于任何符合 Foundation Models 的 LanguageModel 协议的模型,包括 Core AI 模型。除了 AnyLanguageModel,我们还构建了 swift-huggingface 和 swift-xet,以便将 Hub 的加速模型下载功能引入 Swift 应用。
Hosted models, too Support for hosted models expanded this year, too. AnyLanguageModel now supports: OpenAI’s Chat Completions and Responses APIs Open Responses, for any provider with a compatible endpoint Anthropic’s Messages API, with adaptive thinking and effort options Google’s Gemini API Ollama Private Cloud Compute, on OS 27 Hugging Face Inference Providers, and other OpenAI-compatible endpoints such as OpenRouter, through a custom base URL With Inference Providers, you can use open-weight models that are too big to run on the device with the same session code: let model = OpenAILanguageModel( baseURL: URL(string: “https://router.huggingface.co/v1/”)!, apiKey: ProcessInfo.processInfo.environment[“HF_TOKEN”]!, model: “openai/gpt-oss-120b”, apiVariant: .chatCompletions ) Hosted providers get the same features as local models: guided generation, tool calling with streaming, and token usage on responses. Reasoning is now part of the transcript too. When you switch providers, reasoning blocks are automatically omitted from requests if the new provider can’t replay them. API keys come from a closure instead of a string, so your app can fetch short-lived tokens from your own server. The README explains when to let people bring their own keys and when to route requests through a proxy. AnyLanguageModel also runs on Linux, so the same code can work on a server.
托管模型方面,今年对托管模型的支持也有所扩展。AnyLanguageModel 现在支持:OpenAI 的 Chat Completions 和 Responses API;Open Responses(适用于任何具有兼容端点的提供商);Anthropic 的 Messages API(带有自适应思维和努力选项);Google 的 Gemini API;Ollama;OS 27 上的 Private Cloud Compute;Hugging Face Inference Providers;以及通过自定义基础 URL 连接的其他 OpenAI 兼容端点(如 OpenRouter)。通过 Inference Providers,您可以使用那些太大而无法在设备上运行的开放权重模型,并使用相同的会话代码:let model = OpenAILanguageModel( baseURL: URL(string: “https://router.huggingface.co/v1/”)!, apiKey: ProcessInfo.processInfo.environment[“HF_TOKEN”]!, model: “openai/gpt-oss-120b”, apiVariant: .chatCompletions )。托管提供商获得了与本地模型相同的功能:引导式生成、带流式传输的工具调用以及响应中的令牌使用情况。推理过程现在也成为了记录的一部分。当您切换提供商时,如果新提供商无法重放推理块,它们会自动从请求中省略。API 密钥现在来自闭包而不是字符串,因此您的应用可以从您自己的服务器获取短期令牌。README 中解释了何时允许用户使用自己的密钥,以及何时通过代理路由请求。AnyLanguageModel 也可以在 Linux 上运行,因此相同的代码可以在服务器上工作。
Open-weight models got better While we’ve made local models easier to use, the models themselves have become more capable, making the small ones a good place to start. Here are some of the most downloaded models on the Hub right now: Gemma 4 E2B from Google, in GGUF, about 3.4 GB at Q4_0 with quantization-aware training. LFM2.5 2.6B from Liquid AI, in GGUF, about 1.7 GB at Q4_K_M. 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: let model = MLXLanguageModel(modelId: “mlx-community/Qwen3.8-27B-4bit”) And if you have four maxed-out Mac Studios handy, GLM-5.3 from Z.ai takes about 1.5 TB in BF16. For the rest of us, it’s available through Inference Providers. Upgrading to 1.0 dependencies: [ .package( url: “https://github.com/huggingface/AnyLanguageModel”, from: “1.0.0”, traits: [“MLX”] ) ] If you’re upgrading an existing app, see the migration guidance in the AnyLanguageModel, swift-huggingface, and swift-xet release notes for help updating your code. Community feedback and contributions have shaped several of our major features. Thank you to everyone who contributed for helping make AnyLanguageModel more useful to app developers.
开放权重模型变得更好了。虽然我们让本地模型更易于使用,但模型本身也变得更加强大,这使得小型模型成为了一个很好的起点。以下是目前 Hub 上下载量最高的一些模型:来自 Google 的 Gemma 4 E2B(GGUF 格式,Q4_0 量化感知训练,约 3.4 GB);来自 Liquid AI 的 LFM2.5 2.6B(GGUF 格式,Q4_K_M,约 1.7 GB);来自阿里巴巴的 Qwen3.8 27B(MLX 格式,4 位,约 16 GB)。前两个可以在 iPhone 上运行,而 Qwen3.8 27B 可以在拥有 32 GB 或更多内存的 Mac 上运行。选择 MLX 模型只需一行代码:let model = MLXLanguageModel(modelId: “mlx-community/Qwen3.8-27B-4bit”)。如果您手头有四台顶配 Mac Studio,Z.ai 的 GLM-5.3 在 BF16 格式下占用约 1.5 TB。对于我们其他人,它可以通过 Inference Providers 使用。升级到 1.0 依赖项:[ .package( url: “https://github.com/huggingface/AnyLanguageModel”, from: “1.0.0”, traits: [“MLX”] ) ]。如果您正在升级现有应用,请参阅 AnyLanguageModel、swift-huggingface 和 swift-xet 发行说明中的迁移指南以获取代码更新帮助。社区的反馈和贡献塑造了我们的几个主要功能。感谢每一位贡献者,感谢你们让 AnyLanguageModel 对应用开发者更有用。
What’s next Language models have proven to be a powerful tool for building intelligence into products. They’re also one of many kinds of models developers can put to work. We’re excited to bring the same approach to more capabilities: familiar Swift APIs with a choice of models running on the device. Coming soon: models that decide, and models that listen.
未来计划。语言模型已被证明是为产品构建智能的强大工具。它们也是开发者可以利用的多种模型之一。我们很高兴能将同样的方法应用于更多功能:熟悉的 Swift API 以及在设备上运行的模型选择。即将推出:能够决策的模型和能够倾听的模型。