Story

Show HN: SwiftAI – open-source library to easily build LLM features on iOS/macOS

mi12-root Thursday, August 28, 2025

We built SwiftAI, an open-source Swift library that lets you use Apple’s on-device LLMs when available (Apple opened access in June), and fall back to a cloud model when they aren’t available — all without duplicating code.

SwiftAI gives you: - A single, model-agnostic API - An agent/tool loop - Strongly-typed structured outputs - Optional chat state

Backstory: We started experimenting with Apple’s local models because they’re free (no API calls), private, and work offline. The problem: not all devices support them (older iPhones, Apple Intelligence disabled, low battery, etc.). That meant writing two codepaths — one for local, one for cloud — and scattering branching logic across the app. SwiftAI centralizes that decision. Your feature code stays the same whether you’re on-device or cloud.

Example

  import SwiftAI
   
  let llm: any LLM = SystemLLM.ifAvailable ?? OpenaiLLM(model: "gpt-5-mini", apiKey: "<key>")

  let response = try await llm.reply(to: "Write a haiku about Hacker News")
  print(response.content)
It's open source — we'd love for you to try it, break it, and help shape the roadmap. Join our discord / slack or email us at root@mit12.dev.

Links

- GitHub (source, docs): https://github.com/mi12labs/SwiftAI

- System Design: https://github.com/mi12labs/SwiftAI/blob/main/Docs/Proposals...

- Swift Package Index (compat/builds): https://swiftpackageindex.com/mi12labs/SwiftAI

- Discord https://discord.com/invite/ckfVGE5r and slack https://mi12swiftai.slack.com/join/shared_invite/zt-3c3lr6da...

Summary
SwiftAI is an open-source library that provides a concise and easy-to-use interface for integrating various AI and machine learning models into Swift-based applications, enabling developers to leverage the power of artificial intelligence across a wide range of platforms, including iOS, macOS, and server-side environments.
70 19
Summary
github.com
Visit article Read on Hacker News Comments 19