swift-ai brings the @earendil-works/pi-ai API to Swift applications without requiring the TypeScript runtime. It provides typed streaming, tool calls, OAuth helpers and registries for chat, image and classifier models.
Development has stopped. The main branch retains the published v1.0.1 package, following pi-ai v1.0.1. Unfinished v1.1.0 work is preserved on the release branch; pin v1.0.1 for the released package.
SwiftAI.bootstrap() registers models and providers in actor-backed registries. Requests resolve a model, credentials and provider implementation, then use the asynchronous stream or complete API.
Provider clients translate wire responses into typed events using Swift value types, Codable and AsyncStream. Shared helpers handle SSE parsing, tool-argument validation, retries and prompt-cache metadata. A model's presence in the catalogue does not mean every transport is bundled.
Common chat, image, classifier, message, tool, usage and diagnostic types, with actor-backed registries.
OpenAI Chat Completions and Responses, Azure Responses, Codex SSE, Anthropic, Gemini/Vertex, Gemini CLI, Mistral and Pi Messages implementations.
Streamed tool arguments, JSON Schema validation, reasoning events, prompt-cache helpers and context-overflow handling.
OpenRouter image generation and generated chat, image and classifier registries from the pinned upstream release.
Provider-specific sign-in, retry/backoff helpers, diagnostics and request/response interception.
The SwiftPM package is released at v1.0.1. The paused v1.1.0 branch has unfinished, unverified changes and is not a completed upgrade.