ainativeui

00Docs · Quickstart

From package install to first canvas in five lines.

01Install

Install

Add AINativeUI via Swift Package Manager. Pull only the products you use — providers and widget bundles ship as separate targets.

Package.swift
// 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"),
        ]
    )
]

02Pick a provider

Pick a provider

The policy owns the model round-trip. Swap it in one line.

anthropic
Session(policy: .canvas(anthropic: apiKey))
openai
Session(policy: .canvas(openAI: apiKey))
on-device
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.

03Drop in a canvas

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.

ContentView.swift
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) } })
    }
}

04What's next

What's next