swift-openai-api

1.0.0

OpenAI API client generated using Swift OpenAPI Generator
atacan/swift-openai-api

What's New

1.0.0

2025-06-01T12:41:34Z

Swift OpenAI API

This is a Swift package for the OpenAI public API. It is generated from the official OpenAI OpenAPI specification using Swift OpenAPI Generator.

Why not generate it yourself?

OpenAI's OpenAPI specification has some issues. Some of them are fixed in the download script with string replacements.

For example, duplicate models are removed, type mismatches are fixed.

Additions

  • The server-sent-events response type for chat completions is now supported
  • The original API document has only 200 status documented as response. We add all the possible error responses with decodable error message payload, so that you can know what the error is.

Usage

  • AuthenticationMiddleware is provided to add API key authentication.
  • Check out Tests

Installation

Add the following to your Package.swift file:

dependencies: [
    .package(url: "https://github.com/atacan/swift-openai-api", from: "0.1.0"),
],
targets: [
    .target(name: "YourTarget", dependencies: [
        .product(name: "OpenAIUrlSessionClient", package: "swift-openai-api"),
        // .product(name: "OpenAIAsyncHTTPClient", package: "swift-openai-api"),
    ]),
]

Description

  • Swift Tools 6.0.0
View More Packages from this Author

Dependencies

Last updated: Fri Jun 27 2025 18:45:36 GMT-0900 (Hawaii-Aleutian Daylight Time)