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

https://news.ycombinator.com/rss Hits: 7
Summary

SwiftAI A modern, type-safe Swift library for building AI-powered apps. SwiftAI provides a unified API that works seamlessly across different AI models - from Apple's on-device models to cloud-based services like OpenAI. โœจ Features ๐Ÿค– Model Agnostic : Unified API across Apple's on-device models, OpenAI, Anthropic, and custom backends : Unified API across Apple's on-device models, OpenAI, Anthropic, and custom backends ๐ŸŽฏ Structured Output : Strongly-typed structured outputs with compile-time validation : Strongly-typed structured outputs with compile-time validation ๐Ÿ”ง Agent Tool Loop : First-class support for tool use : First-class support for tool use ๐Ÿ’ฌ Conversations : Stateful chat sessions with automatic context management : Stateful chat sessions with automatic context management ๐Ÿ—๏ธ Extensible : Plugin architecture for custom models and tools : Plugin architecture for custom models and tools โšก Swift-Native: Built with async/await and modern Swift concurrency ๐Ÿš€ Quick Start import SwiftAI let llm = SystemLLM ( ) let response = try await llm . reply ( to : " What is the capital of France? " ) print ( response . content ) // "Paris" ๐Ÿ“ฆ Installation Swift Package Manager Xcode: Go to File โ†’ Add Package Dependencies Enter: https://github.com/mi12labs/SwiftAI Click Add Package Package.swift: dependencies: [ . package ( url : " https://github.com/mi12labs/SwiftAI " , from : " main " ) ] ๐Ÿ“š Getting Started ๐Ÿš€ Step 1: Your First AI Query Start with the simplest possible example - just ask a question and get an answer: import SwiftAI // Initialize Apple's on-device language model. let llm = SystemLLM ( ) // Ask a question and get a response. let response = try await llm . reply ( to : " What is the capital of France? " ) print ( response . content ) // "Paris" What just happened? SystemLLM() creates Apple's on-device AI model creates Apple's on-device AI model reply(to:) sends your question and returns a String by default sends your question and returns a by default try await h...

First seen: 2025-08-28 20:30

Last seen: 2025-08-29 02:31