Skip to main content

1. Register a backend, then initialize

Order matters. The C++ plugin registry has to know which engines exist before the first model load, otherwise loading fails with “No provider could handle the request”.
initialize is synchronous and throwing. Pass an empty API key for keyless local mode, or your control-plane credentials to run in .production.

2. Generate text

Generation loads whatever it needs, and downloads the model when options.model names one that is not on disk yet.

3. Stream it instead

For anything a person waits on, stream. Tokens arrive as they are produced.

4. Hold a conversation

Pass messages instead of a prompt. System turns become options.systemPrompt, the trailing user turn becomes the prompt, and everything between travels as history.
The call throws if the conversation contains no user turn.

5. Add speech

A complete SwiftUI example

Next

Managing models

Download, load, and unload

Tool calling

Let the model call your functions

Voice agent

A full spoken conversation

Error handling

What throws and when