Hugging Face Provides Unified API for Local and Cloud LLMs with AnyLanguageModel 1.0

·2026.10.23 16:30

Key point

You can control local and cloud LLMs identically by changing only the import statement.

1 / 6

Details

  • Hugging Face officially released the Swift package AnyLanguageModel 1.0, which follows the Apple Foundation Models API, on October 13, 2026
  • By changing only the import statement from FoundationModels to AnyLanguageModel, you can switch between system models, MLX, llama.cpp, Core ML, and cloud APIs using the same session code
  • Tool calling and structured output are supported across all providers, including support for nested @Generable types and array handling
  • Works on Swift 6.3 or later, iOS 17, macOS 14, visionOS 1, and Linux, and supports external model protocols on OS 27

Key Features and Changes

  • Receives API keys as @autoclosure @Sendable closures, re-reading them on each request
  • Cloud providers offer the same features as local models (structured output, tool calling during streaming, and token usage return)
  • Breaking changes occurred in swift-huggingface 1.0.0 and swift-xet 1.0.0, including changes to the JSONValue type and enum generation format

Supported Models and Environments

  • Local models such as Gemma 4 E2B and LFM2.5 2.6B can run on an iPhone or a Mac with 32GB or more
  • Supports cloud APIs from OpenAI, Anthropic, Google Gemini, HF Inference Providers, and OpenRouter
  • MCP integration is not included in the package; it is recommended to handle it at the app level

This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.

Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.