API reference

Every public function and type, with signatures generated from the source.

Each page documents one symbol: what it does, when to reach for it, and its exact signature.

Signatures here are extracted from Sources/AI on every build, so they cannot drift from the code. The prose around them is written by hand. Everything else in the docs teaches a concept or walks a task; this section is for looking something up.

Functions

Text

Structured output

Embeddings and ranking

Images, audio, and video

Loop control

Context

Middleware and providers

UI and transports

MCP

Audio buffers

Utilities

Types

The types you construct or inspect directly. Everything else in the public API is plumbing these hand back to you.

Building blocks

Results

Configuration

UI

Values

Conventions

Swift argument labels are shown as written, so _ means the parameter is called positionally. A parameter with no default is required; everything else can be omitted.

any LanguageModel and any AIToolProtocol appear throughout because the SDK takes existentials rather than generics on those positions, which is what lets you swap a provider without changing a call site.

Type pages list stored properties, initializers, and methods, including any added in a public extension. Computed properties and protocol conformances are left out.

For the error cases these functions throw, see the errors reference.