swift-ai-sdk
A Swift port of the Vercel AI SDK. One API for text generation, streaming, structured output and tool calling across dozens of providers, with MCP tool support and middleware. Mostly cloud providers, not on-device.
View on GitHub ↗- Stars
- ★ 159
- Last commit
- 29 Nov 2026
- Maintenance
- Active
- Licence
- Apache-2.0
- Category
- On-device AI SDKs · Cloud-capable
- GitHub
- teunlao/
swift-ai-sdk
Overview
swift-ai-sdk brings the shape of the Vercel AI SDK to Swift, so the calls look familiar if you have used it in TypeScript. You pick a provider module, call generateText, streamText or generateObject, and get typed results. Tools, MCP tools, middleware and experimental video generation are included. The README lists 36 providers, each in its own library, so your app only links what it uses.
This is mainly a library for cloud and hosted models. It is listed here as a Swift package for building AI features into apps, not because it runs models on the device.
swift-ai-sdk is licensed under the Apache License 2.0.
Features
- generateText, streamText and generateObject with Swift types.
- Tool calling, including tools from MCP servers.
- Middleware that wraps model calls.
- Separate provider products, such as OpenAIProvider, so you link only the providers you use.
- Experimental video generation.
- Documentation at https://swift-ai-sdk-docs.vercel.app.
Requirements
- macOS 13 or iOS 16 or later, with Swift Package Manager.
- An account and API key with each provider you use.
Install
Add .package(url: "https://github.com/teunlao/swift-ai-sdk.git", from: "0.20.0") to Package.swift. Then add the SwiftAISDK product and the provider product you need, for example OpenAIProvider.
Example
Import SwiftAISDK and your provider module, then call streamText with a model from that provider and a prompt, and iterate over the stream to update a SwiftUI view. Switching provider means changing the import and the model, not the surrounding code.
Works with
Listed in
- github.com/teunlao/swift-ai-sdk
- github.com/teunlao/swift-ai-sdk/blob/main/README.md
- swift-ai-sdk-docs.vercel.app
Read the code before you install anything. SwiftAgents doesn't review or endorse the tools listed here. Active: a commit in the last 90 days. Slowing: last commit within the past year. Stale: older than a year, or archived.
More in this category
apfel
Command-line tool, chat mode and local OpenAI-compatible server for the on-device model in Apple's FoundationModels framework. Needs macOS 26 and Apple silicon.
Argmax OSS Swift (WhisperKit)
Argmax's open-source on-device speech toolkit for Apple silicon, and the home of WhisperKit.
MLX Swift Examples
Example apps and code showing how to use MLX Swift.
SwiftAgents