Install
Add AINativeUI via Swift Package Manager. Pull only the products you use — providers and widget bundles ship as separate targets.
// Package.swift
dependencies: [
.package(url: "https://github.com/kwakuasare/AINativeUI.git", from: "1.0.0")
],
targets: [
.target(
name: "YourApp",
dependencies: [
.product(name: "AINativeUIAgent", package: "AINativeUI"),
.product(name: "AINativeUIAnthropic", package: "AINativeUI"),
.product(name: "AINativeUIWidgets", package: "AINativeUI"),
.product(name: "AINativeUIRecipes", package: "AINativeUI"),
]
)
]Pick a provider
The policy owns the model round-trip. Swap it in one line.
Session(policy: .canvas(anthropic: apiKey))Session(policy: .canvas(openAI: apiKey))Session(policy: .canvasOnDevice()) // iOS 18.1+In production:don't ship raw API keys in a client bundle. Route through your backend or use a gateway.
Drop in a canvas
The canvas is a SwiftUI view, the policy owns the round-trip, and your existing input field stays exactly where it was.
import AINativeUIAgent
import AINativeUIAnthropic
import AINativeUIWidgets
import AINativeUIRecipes
@State private var session = Session(
policy: .canvas(anthropic: ProcessInfo.processInfo.environment["ANTHROPIC_API_KEY"]!)
)
var body: some View {
VStack {
AICanvasView(session: session)
.aiBuiltinWidgets()
.aiBuiltinRecipes()
ChatInputView(onSend: { prompt in Task { try? await session.send(prompt) } })
}
}