AnyLanguageModel
A Swift package that is an API-compatible drop-in replacement for Apple's Foundation Models framework, adding support for Core ML, MLX, llama.cpp and several hosted model APIs behind the same interface.
AnyLanguageModel lets a Swift developer swap import FoundationModels for import AnyLanguageModel and use the same session and tool-calling interface with custom language model providers instead of only Apple's own on-device models. A delegate can be attached to a session to observe or control tool execution.
Supported providers include Apple's Foundation Models and Private Cloud Compute, Core ML models, MLX models, llama.cpp GGUF models, the Ollama HTTP API, and the Anthropic Messages, Google Gemini, OpenAI Chat Completions, OpenAI Responses and Open Responses APIs.
It requires Swift 6.1 or newer and targets iOS 17, macOS 14 or visionOS 1 and above, plus Linux. Swift 6.1 package traits let a project opt into only the heavy dependencies it needs, such as Core ML or MLX support, keeping binary size and build times down when they are not enabled.