This is a Swift package for the OpenAI public API. It is generated from the official OpenAI OpenAPI specification using Swift OpenAPI Generator.
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.
- 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.
AuthenticationMiddleware
is provided to add API key authentication.- Check out Tests
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"),
]),
]