← all repositories
adamrushy/OpenAISwift

Swift wrapper for OpenAI: typed, async, and mostly complete

A community-maintained Swift library that wraps the OpenAI HTTP API with async/await and completion-handler variants for iOS and macOS developers.

OpenAISwift
Not currently ranked — collecting fresh signals.
star history

What it does OpenAISwift is a thin, community-maintained wrapper around OpenAI’s HTTP API. It covers completions, chat (GPT-3.5/GPT-4), DALL·E image generation, edits, moderation, and embeddings. You initialize it with an API key, then call typed methods like sendCompletion or sendChat that return either Result objects or throw via async/await.

The interesting bit The library doesn’t try to be clever — it’s essentially a typed HTTP client — but it does expose every optional API parameter (temperature, top-p, logit bias, etc.) without forcing you to hand-craft JSON. The dual async/await and completion-handler support is a nice concession to Swift’s transitional concurrency landscape.

Key highlights

  • Supports SPM, CocoaPods, or manual file copying
  • Covers six OpenAI endpoints: completions, chat, images, edits, moderation, embeddings
  • Model types are enum-driven (OpenAIModelType.gpt3(.davinci), .chat(.chatgpt), etc.)
  • Chat API supports full conversation threading with ChatMessage arrays
  • MIT licensed; author notes it was “created mainly for fun”

Caveats

  • Streaming message content is explicitly not supported for the chat endpoint
  • The README links to beta.openai.com/docs, which is outdated branding; unclear if the library itself tracks the latest API versions
  • No mention of rate-limit handling, retries, or request cancellation

Verdict Handy if you’re building a Swift app and want typed OpenAI calls without pulling in a heavy networking framework. Skip it if you need streaming responses or sophisticated error handling beyond basic Result types.

Frequently asked

What is adamrushy/OpenAISwift?
A community-maintained Swift library that wraps the OpenAI HTTP API with async/await and completion-handler variants for iOS and macOS developers.
Is OpenAISwift open source?
Yes — adamrushy/OpenAISwift is open source, released under the MIT license.
What language is OpenAISwift written in?
adamrushy/OpenAISwift is primarily written in Swift.
How popular is OpenAISwift?
adamrushy/OpenAISwift has 1.7k stars on GitHub.
Where can I find OpenAISwift?
adamrushy/OpenAISwift is on GitHub at https://github.com/adamrushy/OpenAISwift.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.