Install
Add SwiftAISDK to your package manifest:
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 SwiftAISDKCredentials
Section titled “Credentials”Provider factories read upstream-style environment variables by default:
| Provider | Default environment variable |
|---|---|
| OpenAI | OPENAI_API_KEY |
| Anthropic | ANTHROPIC_API_KEY |
| Google Generative AI | GOOGLE_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.