← all repositories
jamesrochabrun/SwiftOpenAI

A Swift client that actually covers the whole OpenAI surface area

Most Swift wrappers for OpenAI stop at chat completions; this one chases every endpoint, including the new Realtime voice API and beta Assistants streaming.

SwiftOpenAI
Velocity · 7d
+0.7
★ / day
Trend
steady
star history

What it does

SwiftOpenAI is a Swift Package Manager library that wraps OpenAI’s public API—every endpoint, not just the popular ones. It covers chat (with vision, function calling, and structured outputs), embeddings, fine-tuning, images, audio (transcription, translation, speech, and the new Realtime bidirectional voice API), files, batch jobs, and the full Assistants beta including threads, runs, vector stores, and streaming deltas. It also supports Azure, AIProxy, and a laundry list of OpenAI-compatible providers (Anthropic, Gemini, Groq, Ollama, xAI, OpenRouter, DeepSeek) through convenience initializers in OpenAIServiceFactory.

The interesting bit

The README doesn’t just list endpoints—it documents the undocumented. For audio transcriptions, it notes that fileName (with extension) is “not documented in OpenAI’s official documentation; however, it is essential for constructing the multipart request.” That’s the kind of papercut that costs an afternoon, and they’ve already paper-cut themselves so you don’t have to. Linux support uses AsyncHTTPClient to work around Foundation URLSession bugs, which is a pragmatic admission rather than a platform boast.

Key highlights

  • Full endpoint coverage including beta Assistants streaming and Realtime API
  • Cross-platform: iOS 15+, macOS 13+, watchOS 9+, and Linux (with Vapor-friendly AsyncHTTPClient)
  • Built-in AIProxy backend support to keep API keys out of client-side code
  • Explicit error handling with APIError.responseUnsuccessful exposing HTTP status codes (e.g., 429 rate limits) for UI-driven retry logic
  • Requires Swift 5.9 and Xcode 15; SPM install with a note about Xcode’s version-range quirk beyond 2.0.0

Caveats

  • The README is thorough to the point of being a reference manual; finding the specific snippet you need takes scrolling
  • No performance benchmarks or comparison against other Swift OpenAI clients (e.g., MacPaw’s OpenAI)
  • Realtime API and Assistants streaming are marked beta, so expect upstream churn

Verdict

Worth a look if you’re building a Swift app that needs more than basic chat completions—especially if you’re targeting watchOS, need voice interactions, or want to route through non-OpenAI providers without swapping client libraries. If you just need GPT-4 calls from an iOS app and nothing else, it’s probably overkill.

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