AI Model Setup

Prepare AI models for your app.

Choose your AI model, check what your app needs, and download the required models.

The iOS Simulator lacks the required Metal GPU support; see MLX Swift's iOS guidance. Hence, a physical device is required before you start development.


Once you’ve added the Primordial SDK to your project and created an evaluation key, you’re ready to set up your AI models.

Create a Primordial Client

PrimordialClient is the main entry point for configuring, activating, and accessing Primordial SDK features.

import Primordial

let primordial = PrimordialClient()

Primordial takes care of choosing AI models and gives you ready-to-use defaults. See AI Capabilities to learn which model each AI capability uses by default.

Use Apple’s Foundation Model

Apple Foundation Models require iOS 26 or macOS 26, an Apple Intelligence-capable device (iPhone 15 or newer and Apple Silicon Macs), and Apple Intelligence enabled. Always check availability before showing the feature.


To use the system model provided by Apple Intelligence, use .appleFoundationModel() when creating the client.

let primordial = PrimordialClient(
  aiConfiguration: .init(
    generation: .appleFoundationModel()
  )
)

Apple’s Foundation Model is managed by the operating system, so your app does not need to download or remove it. Before using it, check whether it is available on the device. If Apple Intelligence is turned off, direct the user to Apple’s setup guide.

let capabilities = await primordial.ai.generation.capabilities()
          
switch capabilities.availability {
  case .available:
    print("Apple Foundation Model is ready")

  case .systemUnavailable(let reason):
    print("Apple Foundation Model is unavailable: \(reason)")

  case .unavailable(let message):
    print(message)
}

Configuration and fallback model option


Primordial never switches to or downloads a fallback model automatically. Your app can offer a local model as a fallback, but the user must choose it first. See Advanced API: Apple model configuration for setup.

AI Capabilities

Capability Use it for Default model downloaded
.semanticSearch Adding, rebuilding, or searching your data by meaning. Paraphrase Multilingual MiniLM L12 v2
.generation Generating, summarizing, classifying, or extracting text. Qwen3 1.7B 4-bit
.answering Answering or chatting with your data. Qwen3 1.7B 4-bit and Paraphrase Multilingual MiniLM L12 v2
.voiceInput Transcribing audio or microphone input. Parakeet 0.6B Multilingual

When the PrimordialClient uses Apple’s Foundation Model, .generation uses Apple’s system model instead of downloading Qwen3. The .answering capability still downloads the embedding model for collection search.

Check What Your App Needs

Before downloading, check which AI capabilities your app or workflow needs. Primordial tells you the download size, required storage, and whether they are ready to use.

let requirement = await primordial.ai.status(
    for: [.answering, .voiceInput]
)

print(requirement.downloadBytes)
print(requirement.requiredAvailableBytes)
print(requirement.isInstalled)
print(requirement.isAvailable)

Activate Primordial

Activate Primordial before installing models or running an AI task.

try await primordial.activate(
  .evaluationKey("pk_eval_your_key_here")
)

You can check primordial.isActivated when your UI needs to reflect activation state. Keep the evaluation key out of logs and user-visible error messages.

Download the Required Models

Use makeAvailable to download the models your app needs. If you use Apple’s Foundation Model, it checks whether the system model is ready instead.

for try await progress in primordial.ai.makeAvailable(
    [.answering, .voiceInput]
) {
    print(progress.fractionCompleted)
    print(progress.downloadedBytes)
    print(progress.totalBytes)
    print(progress.phase)
}

Primordial checks storage, downloads the missing resources, verifies them, and resumes valid partial downloads. Calling makeAvailable again does not download an already installed model again.

Primordial supports background model downloads on iOS. Downloads can continue while your app is suspended, as long as it forwards background URL-session events. See Background downloads for the required app delegate code. If the user force-quits your app, the download is canceled.

Use Custom Models

If you want to use different AI models or configure default models, see Advanced API: Model Configuration.