MacPaw/OpenAI

Swift community driven package for OpenAI public API

What it solves

This project provides a community-maintained Swift SDK for interacting with the OpenAI API. It simplifies the process of integrating AI capabilities—such as text generation, image creation, audio processing, and assistant management—into Swift-based applications (iOS, macOS, etc.) without needing to manually handle complex REST API requests.

How it works

The library acts as a wrapper around OpenAI's REST API. Developers initialize the client with an API token and then use Swift-native methods to send queries and receive strongly-typed responses. It supports modern Swift features like Swift Concurrency (async/await) for clean, readable code, as well as Combine for reactive programming. It also supports OpenAI-compatible APIs from other providers.

Who it’s for

This is for Swift and Apple platform developers who want to build AI-powered features into their applications. It is designed for those who prefer using a native library over writing raw network requests to interact with LLMs and generative AI services.

Highlights

  • Comprehensive API Coverage: Includes support for Chat Completions, DALL-E image generation, audio transcription/translation, and Assistants API.
  • Modern Swift Support: Fully compatible with Swift Concurrency (async/await) and Combine.
  • Flexible Integration: Can be used with OpenAI or other providers that offer OpenAI-compatible endpoints.
  • Type-Safe: Uses Swift structures to model API requests and responses, reducing errors compared to handling raw JSON.

Related

  • Project
  • Project
  • Project
  • Project
  • Project