Open AI Models

AnyLanguageModel 1.0 unifies local and hosted AI inference for Apple platforms

Key Takeaway

Hugging Face's AnyLanguageModel 1.0 lets Swift developers use Apple's Foundation Models API with local open-weight models via llama.cpp, MLX, and Core ML, as well as hosted providers including OpenAI, Anthropic, Google Gemini, and Hugging Face Inference Providers.

Summary

AnyLanguageModel 1.0 is now available after a year of development, alongside swift-huggingface 1.0 and swift-xet 1.0. The Swift package provides a drop-in replacement for Apple's Foundation Models framework, allowing developers to switch between system models, local open-weight models, and hosted providers without changing session code. New features include tool calling and guided generation across all providers, image support with Foundation Models 27 syntax, and Linux compatibility for server-side use.

What AnyLanguageModel 1.0 adds

  • Drop-in API compatibility: Replace import FoundationModels with import AnyLanguageModel to use the same session code across system, local, and hosted models
  • Local inference backends: llama.cpp, MLX, and Core ML for on-device execution
  • Hosted provider support: OpenAI Chat Completions/Responses, Anthropic Messages with adaptive thinking, Google Gemini, Ollama, Private Cloud Compute (OS 27), Hugging Face Inference Providers, and OpenAI-compatible endpoints via custom base URL
  • Unified features across providers: tool calling, guided generation (including nested @Generable types and arrays), streaming, and token usage reporting
  • Image support: attach images using Foundation Models 27 syntax on iOS, macOS, and visionOS 27
  • Security improvement: API keys fetched via closure rather than hardcoded strings, enabling short-lived token retrieval from developer servers
  • Linux support: same codebase runs on servers
  • Companion packages: swift-huggingface 1.0 and swift-xet 1.0 for accelerated model downloads from the Hub

Why it matters

The release lowers barriers for iOS and macOS developers to experiment with local open-weight models while maintaining fallback paths to hosted APIs, potentially increasing adoption of on-device AI that preserves user privacy. The MLX backend specifically benefits Apple's silicon ecosystem where memory-constrained devices can run quantized models like Gemma 4 E2B (3.4 GB) and LFM2.5 2.6B (1.7 GB) on iPhones.

Original reference: huggingface.co →