OpenAIKit

1.2.5

A comprehensive Swift SDK for the OpenAI API.
guitaripod/OpenAIKit

What's New

1.2.5

2025-07-11T16:27:24Z

What's Changed

  • Document OpenAI's increased structured output limits (Marcus ZiadΓ©)

Installation

Swift Package Manager

dependencies: [
    .package(url: "https://github.com/marcusziade/OpenAIKit.git", from: "1.2.5")
]

OpenAIKit

Swift Platforms Swift Package Manager Documentation License CI

A comprehensive Swift SDK for the OpenAI API.

Documentation

Visit https://marcusziade.github.io/OpenAIKit/ for complete documentation and tutorials.

Features

  • πŸš€ Type-safe API with Swift's powerful type system
  • 🌍 Cross-platform support (iOS 15+, macOS 12+, watchOS 8+, tvOS 15+, visionOS, Linux)
  • πŸ“š Complete API coverage (Chat, Images, Audio, Embeddings, and more)
  • ⚑ Modern async/await with streaming support
  • πŸ›‘οΈ Comprehensive error handling
  • πŸ“– Full DocC documentation with interactive tutorials
  • βœ… Production-ready with 100% test coverage

API Coverage

βœ… Implemented

  • Chat Completions - Text generation with streaming support
  • Function Calling - Tool use and multi-function support
  • Embeddings - Text vectorization with dimension control
  • Audio - Speech-to-text and text-to-speech
  • Images - DALL-E 2/3 and GPT Image 1
  • Moderation - Content safety checking
  • Models - List and retrieve model information
  • Files - Upload, download, list, and delete
  • Streaming - Real-time responses with usage tracking
  • Batch API - Async processing with 50% cost savings
  • Error Handling - Comprehensive UI-friendly errors
  • DeepResearch - Advanced research with web search, MCP tools, and code interpretation (models: o3-deep-research, o4-mini-deep-research)

🚧 Not Implemented

  • Assistants API - Beta feature
  • Threads API - Part of Assistants (beta)
  • Vector Stores - Part of Assistants (beta)
  • Fine-tuning - Not implemented

Installation

Add OpenAIKit to your Package.swift:

dependencies: [
    .package(url: "https://github.com/marcusziade/OpenAIKit.git", from: "1.0.0")
]

Quick Start

import OpenAIKit

let openAI = OpenAIKit(configuration: .init(apiKey: "your-api-key"))

let response = try await openAI.chat.completions(
    .init(
        model: .gpt4o,
        messages: [.user("Hello, world\!")]
    )
)

print(response.choices.first?.message.content ?? "")

Testing the SDK with OpenAIKitTester.swift

run swift run OpenAIKitTester <test>

Description

  • Swift Tools 5.9.0
View More Packages from this Author

Dependencies

Last updated: Thu Apr 09 2026 00:15:51 GMT-0900 (Hawaii-Aleutian Daylight Time)