SwiftyGPT is a simple and lightweight wrapper around OpenAI API which exposes services provided by ChatGPT and DALL-E. It was born with the aim of provide a Swift like interface around all OpenAI capabilities, so you can make requestes and get responses with minimal coding effort.
- Easy to use: no configuration needed, SwiftyGPT is ready to go, you just need an API Key.
- Configurable: you can choose some parameters like model, temperature or just use default values.
- SwiftUI compatible: provides an elegant SwiftUI support that is very easy to use.
You can use Swift Package Manager to add SwiftyGPT to your project.
In Xcode, select File > Add Packages...
Copy and paste the following into the search/input box.
https://github.com/antonio-war/SwiftyGPT
Use Up to Next Major Version as dependency rule and enter the current SwiftyGPT version. Then click Add Package.
The first step to using SwiftyGPT is to create an instance, you an use the same to access all features.
let swiftyGPT = SwiftyGPT(apiKey: "YOUR_API_KEY")
- Chat
- Completion
- Image Generation
- Grammar Correction
- Language Translation
- Sentiment Analysis
- Text Summary
In case of failure methods return an error, it can be a system error in case something went wrong on the iOS side. For example, network-level issues or decoding issues. If instead the error is related to ChatGPT you will get a SwiftyGPTError.
if let error = error as? SwiftyGPTError {
print(error.message)
}
SwiftyGPT is published under the Apache 2.0 license.