Skip to content

Install

Add SwiftAISDK to your package manifest:

Package.swift
dependencies: [
.package(url: "https://github.com/ozio/SwiftAISDK.git", from: "1.1.1"),
],
targets: [
.target(
name: "YourApp",
dependencies: [
.product(name: "SwiftAISDK", package: "SwiftAISDK"),
]
),
]

For an application that must stay on a reviewed SDK build, replace from: with SwiftPM’s exact: requirement for that release. Production applications should not depend on the moving main branch.

Then import the library:

import SwiftAISDK

Provider factories read upstream-style environment variables by default:

ProviderDefault environment variable
OpenAIOPENAI_API_KEY
AnthropicANTHROPIC_API_KEY
Google Generative AIGOOGLE_GENERATIVE_AI_API_KEY or GEMINI_API_KEY

You can also pass credentials explicitly:

let provider = try AIProviders.openAI(
settings: ProviderSettings(apiKey: "your-api-key")
)

Use explicit settings when you need custom headers, a custom base URL, a mock transport, or per-environment credentials.