ACMOpenAI is an unofficial library that help developers to use Open AI API easily.
Add this dependency to your project's POM:
<repositories>
  <repository>
      <id>jitpack.io</id>
      <url>https://jitpack.io</url>
  </repository>
</repositories>
<dependency>
    <groupId>com.github.AppcentMobile</groupId>
    <artifactId>ACMOpenAI-Android</artifactId>
    <version>1.0.2</version>
</dependency>Add this dependency to your project's build file:
allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}
dependencies {
   implementation 'com.github.AppcentMobile:ACMOpenAI-Android:1.0.2'
}Basicly create a instance of ACMOpenAI
and set the apiKey
val openApi = ACMOpenAI.Builder()
    .apiKey("${YOUR_API_KEY}")
    .debugging(true)
    .build()
val response = openApi.chat().createChatCompletion(
    CreateChatCompletionRequest(
        model = "gpt-3.5-turbo",
        messages = arrayOf(
            ChatCompletionRequestMessage(
                role = ChatCompletionRequestMessage.Role.USER.value,
                content = "Hello ChatGPT"
            )
        )
    )
)Chat and Completions apis has stream property to provide server-sent events to collectors.
val openApi = ACMOpenAI.Builder()
    .apiKey("${YOUR_API_KEY}")
    .build()
openApi.chat().createChatCompletion(
    CreateChatCompletionRequest(
        model = "gpt-3.5-turbo",
        messages = arrayOf(
            ChatCompletionRequestMessage(
                role = ChatCompletionRequestMessage.Role.USER.value,
                content = "What did Schrodinger's Cat 😺 experiment prove?"
            )
        ),
        stream = true
    )
).collect {
    print(it?.choices?.get(0)?.message?.content)
}The ACMOpenAI supports the following options on initialization. These options are all keys in the single constructor parameter.
| Option | Default value | Type | Description | 
|---|---|---|---|
apiKey | 
undefined | 
string | 
Bearer token for authentication. Should be given for every request | 
baseUrl | 
"https://api.openai.com/v1" | 
string | 
Base URL | 
logLevel | 
HttpLoggingInterceptor.Level.NONE | 
HttpLoggingInterceptor.Level | 
|
client | 
Default client generated by ACMOpenAI | OkHttpClient | 
Define OkHttpClient by yourself | 
Domentation All URIs are relative to https://api.openai.com/v1