Swift logo

Swift

Free

Swift community-driven OpenAI API client

FreeFree tier
Inputs: text, image, audioOutputs: text, image, audio
Type
Open Source
Company
MacPaw

About Swift

OpenAI is a Swift community-driven package that provides a client implementation for the OpenAI public API. Developed by MacPaw, this open-source library enables Swift developers to integrate a wide range of OpenAI's capabilities into their applications, including chat completions, image generation and editing, audio transcription and speech synthesis, embeddings, moderations, and assistants (beta). The package is designed to closely follow the REST API documentation from OpenAI, offering structured types and methods for each endpoint. It also includes support for other providers such as Gemini, DeepSeek, Perplexity, and OpenRouter, allowing flexible integration with various AI services. The library is distributed via Swift Package Manager and includes a demo project and contribution guidelines.

Key Features

Swift community-maintained implementation of the OpenAI public API
Supports chat completions with function calling and tools, including MCP (Model Context Protocol)
Image generation, editing, and variation creation
Audio speech creation, transcription, and translation
Structured outputs and specialized models
Embeddings and moderations endpoints
Assistants (beta) with thread and message management
Support for other providers like Gemini, DeepSeek, Perplexity, and OpenRouter

Pros & Cons

Pros
  • Open-source and community-driven, allowing for transparency and contributions
  • Covers a broad range of OpenAI API endpoints in a single Swift package
  • Supports multiple AI providers beyond OpenAI, increasing flexibility
  • Includes structured outputs and function calling for advanced use cases
  • Provides a demo project and clear documentation for getting started
Cons
  • Requires an OpenAI API key and internet access to function; no offline capabilities
  • Free tier of the OpenAI API has usage limits that should be verified
  • Assistants feature is marked as beta, so stability may vary
  • Dependency on Swift Package Manager may limit use in non-Swift environments
  • Community-maintained, so updates may lag behind official API changes

Best For

Building AI-powered chat applications in SwiftIntegrating image generation and editing into iOS or macOS appsAdding speech-to-text or text-to-speech capabilities to Swift projectsImplementing content moderation or embedding-based searchCreating AI assistants with thread-based conversation managementDeveloping cross-provider AI clients that can switch between OpenAI and other services

FAQ

What is the OpenAI Swift package?
It is an open-source Swift library that provides a client for the OpenAI public API, allowing developers to integrate AI features like chat, images, and audio into their Swift applications.
Is this package free to use?
The package itself is open-source and free to use, but it requires an OpenAI API key, which may involve usage costs based on OpenAI's pricing. Free tier limits should be verified on OpenAI's website.
Does it support image generation?
Yes, based on available information, the package supports creating, editing, and creating variations of images through the OpenAI API.
Can I use this with providers other than OpenAI?
Yes, the package includes support for other providers such as Gemini, DeepSeek, Perplexity, and OpenRouter, though exact configuration details should be checked in the documentation.
How do I install the package?
It can be integrated into an Xcode project using Swift Package Manager. Instructions are provided in the repository's README.
Is the Assistants API fully supported?
The package includes support for the Assistants API, but it is marked as beta, so functionality may be subject to changes and should be tested thoroughly.