Open SourceAIChatKit
Swift Package · Swift · MIT

One chat interface. Every provider.

AIChatKit gives every Apple-platform app a single, unified chat interface across cloud and on-device AI providers. OpenAI, Anthropic, and Apple Intelligence all share the same protocol, message model, and optional SwiftUI components — swap providers with a one-line change.

$.package(url: "https://github.com/NerdSnipe-Inc/AIChatKit", from: "0.1.0")
5
Modules
iOS 17+
Platform
MIT
License
What's inside

One protocol, five modules

AIChatCore defines the shared message model and provider protocol. AIChatOpenAI, AIChatAnthropic, and AIChatFoundationModels each implement it — pull in only the providers your app actually uses.

ChatSession does the state management

A single ObservableObject drives streaming, tool calls, reasoning traces, and activity entries. session.send(_:) is non-blocking — entries append as tokens arrive, and session.isGenerating tracks in-flight state.

Drop-in or fully custom UI

Most apps render session.entries into their own bubble views. Apps with no design requirements can use ChatView directly and get a complete chat UI for free.

Styled markdown out of the box

AIChatUI ships MarkdownMessageView — syntax-highlighted fenced code blocks with a language label and copy button, plus headings, tables, and blockquotes, built on swift-markdown-ui and Splash.

Restore persisted conversations

loadSnapshot(entries:history:) restores a saved conversation into both the display entries and the provider's history in a single call, so session.send() has full context immediately.

Apple Intelligence, natively

AIChatFoundationModels wires Apple's on-device Foundation Models framework (macOS 26+/iOS 26+) into the same ChatSession API as the cloud providers — no separate integration path.

Add to your Package.swift
Package
$.package(url: "https://github.com/NerdSnipe-Inc/AIChatKit", from: "0.1.0")
Target dependencies — add only what you need
$.product(name: "AIChatCore", package: "AIChatKit"), .product(name: "AIChatOpenAI", package: "AIChatKit"), .product(name: "AIChatAnthropic", package: "AIChatKit"), .product(name: "AIChatFoundationModels", package: "AIChatKit"), .product(name: "AIChatUI", package: "AIChatKit")

For on-device inference, add a companion package: AIChatKitMLX (Apple MLX) or AIChatKitLlama (llama.cpp/GGUF) — both speak the same AIChatCore protocol as the cloud providers.

Design

Providers are interchangeable by design.

Every provider — OpenAI, Anthropic, Apple Intelligence, or an on-device model via AIChatKitMLX/AIChatKitLlama — implements the same protocol and feeds the same ChatSession. Switching providers is a constructor change, not a rewrite.

Frequently asked

Do I need all five modules?

No. AIChatCore is required; add only the provider modules (AIChatOpenAI, AIChatAnthropic, AIChatFoundationModels) and AIChatUI that your app actually uses.

How do I add on-device inference?

Add AIChatKitMLX for Apple MLX models (Apple Silicon only) or AIChatKitLlama for GGUF models via llama.cpp. Both implement the same AIChatCore protocol, so your ChatSession code doesn't change.

What platforms are supported?

macOS 14+ and iOS 17+, built with Swift 5.10+.

Ship one chat UI, support every provider.

Add AIChatKit to your Package.swift and pick the providers you need. Pair it with AIChatKitMLX or AIChatKitLlama for on-device inference.