A kotlin client for OpenAI APIs to quickly insert into your Kotlin JVM apps
Create an OpenAI account and sign up for a paid account. This will allow you to create an API key that can be used to invocate the GPT-3 model endpoints.
Once you have signed up and created an API key, copy your API key and export it in your local environment:
export OPENAI_API_KEY=<your_api_key>
If you want to do this on startup of every shell session, add the above statement to your bash/zsh rc file (in either
~/.bashrc
or ~/.zshrc
respectively)
The example-app
module in this package contains a simple App.kt
kotlin function to invocate the GPT-3 /completions
endpoint using the Davinci model.
Once you have the Open AI setup done, you can run the following gradle command to test that your setup is working correctly:
./gradlew :example-app:run
You should see something like the following output:
Keep in mind this is a generative model, so you might get different names for your squirrel!
In order to use this package into your app, you'll need to declare a dependency for it from the maven repository.
TBD:
dependencies {
implementation com.arvarik.openai-kotlin:openai-kotlin-client:0.0.1
}
The openai-kotlin repository aims to provide a lightweight, consistent and error-prone kotlin client for OpenAI APIs
It's primary use it provide an out-of-the-box package for kotlin JVM apps to quickly use the OpenAI API.
The repository has two main modules.
This module contains all the base classes for the OpenAI APIs. It mostly contains data classes that map to the OpenAI API json schemas as well as any other common or utility functions.
This module contains the main functionality to make requests to the OpenAI APIs and retrieve their responses.
TBD:
-
Full Open AI completion
-
More OpenAI Configurations
-
Security Features, including rate limiting