Swift Language Models: bring any provider to Apple's Foundation Models API

Hi everyone,

Swift Language Models is a wrapper that brings other providers' language models into Apple's native Foundation Models API.

Foundation Models 27 lets any type conform to LanguageModel (Apple's guide), and this package provides those conformances. Your app keeps Apple's own API: LanguageModelSession, tools, @Generable guided generation, streaming, transcripts and Dynamic Profiles. Moving a session from the on-device model to a remote one changes only its model:, and new framework features reach every model without waiting for a wrapper update.

let onDevice = LanguageModelSession(model: SystemLanguageModel.default)
let remote = LanguageModelSession(model: OpenRouterLanguageModel(.anthropicClaudeHaiku5_5, apiKey: { key }))

What you get

  • One API for every model. Code written for Apple's on-device model runs unchanged on a remote one.
  • Provider modules. Each provider is its own module, so an app builds only the providers it imports.
  • Typed model catalogs. Where a provider lists its models, every model is a static member with its context size, limits and capabilities, kept current by a bot.
  • Typed reasoning levels. Code completion offers only the levels each model accepts, and Apple's .light, .moderate and .deep still work.
  • Evaluations. Compare Apple's on-device model with remote ones in one evaluation, using Apple's Evaluations framework.

First provider: OpenRouter

The first module is OpenRouter, which reaches hundreds of models from Anthropic, OpenAI, Google, DeepSeek, Meta, Mistral and others through one key. It also supports fallbacks, provider routing and web search. More providers are coming.

It needs iOS, macOS, visionOS or watchOS 27 and Swift 6.4. Feedback is very welcome.

If you find it useful, a :star: on GitHub helps the project grow.

1 Like