https://github.com/vapor-community/openai
A Swift package for interacting with the OpenAI API using Vapor
https://github.com/vapor-community/openai
Last synced: 12 days ago
JSON representation
A Swift package for interacting with the OpenAI API using Vapor
- Host: GitHub
- URL: https://github.com/vapor-community/openai
- Owner: vapor-community
- License: mit
- Created: 2023-01-02T19:40:04.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-04T16:30:25.000Z (almost 3 years ago)
- Last Synced: 2024-11-17T09:47:03.741Z (11 months ago)
- Language: Swift
- Homepage:
- Size: 7.81 KB
- Stars: 12
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OpenAI

### OpenAI is a Vapor helper to use [OpenAIKit](https://github.com/dylanshine/openai-kit)
## Usage guide
In your `Package.swift` file, add the following~~~~swift
.package(url: "https://github.com/vapor-community/openai.git", from: "1.0.0")
~~~~To use OpenAI in your Vapor application, set the environment variable for you OpenAI API key and optional Organization
~~~
export OPENAI_API_KEY="YOUR-KEY"
export OPENAI_ORGANIZATION="YOUR-ORGANIZATION"
~~~Now you can access a `OpenAI.Client` via `Request`.
~~~~swift
func generatePoem(req: Request) async throws -> HTTPStatus {
let completion = try await req.openai.completions.create(
model: Model.GPT3.davinci,
prompts: ["Write a haiku about dogs."]
)
...
}
~~~~## License
OpenAI is available under the MIT license. See the [LICENSE](LICENSE) file for more info.
## Want to help?
Feel free to submit a pull request whether it's a clean up, a new approach to handling things, adding a new part of the API, or even if it's just a typo. All help is welcomed! 😀