AnyLanguageModel 1.0 (Hugging Face)
A Swift package that acts as a drop-in replacement for Apple's Foundation Models framework. The same session code works with local MLX models and hosted providers (Anthropic, OpenAI, Gemini, Ollama, Hugging Face). Tool calling and @Generable work across all providers, and prompts can include images.
How to try it
- In Xcode or Package.swift, add the package https://github.com/huggingface/AnyLanguageModel at from: "1.0.0", with traits: ["MLX"] if you want local models
- In your files, replace `import FoundationModels` with `import AnyLanguageModel`
- For a local model, create `MLXLanguageModel(modelId: "mlx-community/Qwen3.8-27B-4bit")`; for a hosted one, use `OpenAILanguageModel` with your own baseURL and key
- If you're upgrading from an earlier version, read the migration notes in the release notes
Price: free (hosted models are billed by each provider)