This is a non-official iOS library of OpenAI.
OpenMagicAI is a friendly Swift library for accesing to OpenAI API. OpenAI api official docs reference.
Chat GPT-4 model support :heart: (Limited beta) Join the waitlist
There's a sample app here using the methods of OpenMagicAI library.
Chat | Create Image | List Models |
---|---|---|
![]() |
![]() |
![]() |
SPM is a tool for managing the distribution of Swift code.
dependencies: [
.package(url: "https://github.com/asyncios/OpenMagicAI.git", .upToNextMajor(from: "1.3.0"))
]
Set your API Key, if you don't have one create it here
let openMagicAI = OpenMagicAI(apiKey: "APIKEY")
openMagicAI.chat.createChatCompletion(
messages: [.init(role: .user, content: "Give me some movie options for tonight")]
) { result in
debugPrint(result)
}
// GPT-4 model
openMagicAI.chat.createChatCompletion(
model: .gpt4,
messages: [.init(role: .user, content: "Give me some movie options for tonight")]
) { result in
debugPrint(result)
}
openMagicAI.images.createImage(prompt: "dog in a park") { result in
debugPrint(result)
}
Task {
let result = try await openMagicAI.images.createImage("dog in a park")
debugPrint(result)
}
openMagicAI.images.createImage(prompt: "dog in a park").sink { _ in
} receiveValue: { value in
debugPrint(value)
}.store(in: &cancellables)
All source code is licensed under the MIT License.
link |
Stars: 2 |
Last commit: 1 week ago |
Changes:
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics