Introducing Swift AI SDK, an AI toolkit for iOS and macOS apps

Hi everyone,

I wanted to share a new package called Swift AI SDK. It is a toolkit for adding AI features to iOS and macOS apps. The same code works whether you use a cloud based model or a model that runs right on the device.

With it you can generate text, stream a response as it comes in word by word, and get back structured data like typed objects instead of plain text you have to parse yourself.

It also supports tool calling. That means the model can call functions in your own code, use the result, and keep working until it has a final answer.

It works with many AI providers, including Anthropic, OpenAI, Google, Groq, Mistral, and more, along with Apple's on device models. You can start with one provider and switch to another by changing a single line of code.

There is also a ready made chat object built for SwiftUI, so you can put together a working chat screen quickly. It keeps track of the messages, updates the screen as new text streams in, and can connect to the same backend your web app already uses.

For voice, it supports live spoken conversations. You can talk to it, interrupt while it is speaking, and it can run your tools in the middle of the conversation.

The project is open source under the MIT license. Code and full documentation are here: GitHub - zaidmukaddam/swift-ai-sdk: The AI SDK for your iOS and macOS Apps · GitHub

Would love to hear what people think, and I am happy to answer questions.

1 Like