Project

swift-ai

experimental

SwiftPM port of @earendil-works/pi-ai with typed streaming, tools and a shared multi-provider model catalogue.

Overview

swift-ai brings the @earendil-works/pi-ai API and event model to Swift applications and services. It uses go-ai as the audited reference implementation and exposes parity information both in STATUS.json and through SwiftAIStatus at runtime.

The package tracks the bounded pi-ai v0.84.0 release surface. Its generated catalogues contain 1,153 text models across 38 providers and 42 image models; catalogue presence does not imply that every provider has a bundled native transport.

How it works

SwiftAI.bootstrap() initialises the actor-backed model and provider registry. A request resolves its model, credentials and provider implementation before passing through a common asynchronous stream or complete API.

HTTP providers convert SSE responses into shared typed events for text, reasoning, tool calls, usage and completion. Message transformation, partial JSON parsing and JSON Schema-based tool validation help keep provider-specific wire formats out of application code.

Features
Typed Swift surface

Codable types cover models, providers, messages, tools, usage, diagnostics, stream options and the common event protocol.

Provider implementations

Implemented streaming paths include OpenAI Chat Completions, OpenAI Responses, Azure OpenAI Responses, Codex, Anthropic Messages, Mistral, Gemini, Gemini CLI and Baseten.

OAuth support

OAuth support includes GitHub Copilot, OpenAI Codex, Anthropic, Gemini CLI and Antigravity.

Streaming tools

SSE parsing, partial tool-argument JSON, JSON Schema validation, retry handling and request or response interception hooks.

Generated catalogues

Includes release-pinned pi-ai v0.84.0 text and OpenRouter image catalogues.

Lightweight core

Bedrock request building and Codex transport surfaces are present, but heavyweight vendor SDK and WebSocket transports remain pluggable rather than bundled.

Architecture
Swift application stream · complete · tools SwiftAI registry actor-backed models + providers Request resolver model · credentials · options Provider transport HTTP · SSE · pluggable Typed event stream text · reasoning · tools · usage Provider-neutral LLM streaming API for Swift