Community-maintained Swift package wrapping the OpenAI public API, covering chat, responses, images, audio, embeddings and assistants.
jamesrochabrun/SwiftOpenAI
A Swift package for calling OpenAI's public API across Apple platforms and Linux, with support for many OpenAI-compatible providers.
- Stars
- 665
- Forks
- 130
- Open issues
- 12
- Last commit
- last month
What is it?
SwiftOpenAI is a Swift package that wraps OpenAI's REST endpoints in typed Swift parameters and responses, covering audio, chat, responses, embeddings, fine-tuning, batch, files, images, models, moderations, and the beta Assistants, Threads, Runs and Vector Stores APIs. It also includes a Realtime API client for bidirectional voice conversations over WebSockets, with microphone capture and audio playback helpers on Apple platforms.
The package runs on iOS 15+, macOS 13+, watchOS 9+ and Linux. On Linux it uses AsyncHTTPClient and can be used with the Vapor server framework. A factory lets you point the same client at OpenAI-compatible providers such as Azure OpenAI, Anthropic, Gemini, Ollama, Groq, xAI, OpenRouter, DeepSeek and AIProxy, and it supports custom URLs and organization IDs.
The project is distributed through Swift Package Manager and is MIT licensed. The author also publishes a separate CLI and MCP server built on the package.
Key features
- 01Typed Swift wrappers for chat, audio, embeddings, images, files, fine-tuning and batch endpoints.
- 02Realtime API client for voice conversations over WebSockets, with VAD and function tools.
- 03Runs on iOS, macOS, watchOS and Linux (via AsyncHTTPClient and Vapor).
- 04Works with OpenAI-compatible providers such as Azure, Anthropic, Gemini, Ollama and Groq.
- 05Includes streaming support for chat and Assistants responses.
Use cases
- Adding OpenAI chat or speech features to an iOS or macOS app.
- Building a voice assistant on Apple devices with the Realtime API.
- Calling OpenAI-compatible model providers from a Swift server built with Vapor.
Topics
FAQ
- What is SwiftOpenAI?
- A Swift package for calling OpenAI's public API across Apple platforms and Linux, with support for many OpenAI-compatible providers. SwiftOpenAI is a Swift package that wraps OpenAI's REST endpoints in typed Swift parameters and responses, covering audio, chat, responses, embeddings, fine-tuning, batch, files, images, models, moderations, and the beta Assistants, Threads, Runs and Vector Stores APIs. It also includes a Realtime API client for bidirectional voice conversations over WebSockets, with microphone capture and audio playback helpers on Apple platforms.
- Is SwiftOpenAI free to use? What license does it have?
- SwiftOpenAI is open source under the MIT license. Check the license terms before using it in commercial products.
- Is SwiftOpenAI still maintained?
- Updated within 6 months. The last commit to SwiftOpenAI was on Oct 5, 2026.
- What can I use SwiftOpenAI for?
- Adding OpenAI chat or speech features to an iOS or macOS app. Building a voice assistant on Apple devices with the Realtime API. Calling OpenAI-compatible model providers from a Swift server built with Vapor.
- Where can I get SwiftOpenAI?
- The source code and installation instructions are on GitHub: https://github.com/jamesrochabrun/SwiftOpenAI
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
The official Python library for the OpenAI REST API, with sync and async clients and typed request and response models.
An unofficial, zero-dependency Go client for the OpenAI API, covering Responses, Chat Completions, images, audio and more.
A desktop tool that automates downloading, starting and managing RWKV large language models, exposing an OpenAI-compatible API.
A Go CLI that generates git commit messages and brief code reviews with LLMs, and can install a prepare-commit-msg git hook.
A Swift toolkit for SQLite databases, offering record persistence, a query interface, migrations, and database observation for app development.