The project for OpenAI official APIs
- Text Completion
- Image Generation(DALL-E)
- Playground
- ChatGPT Web API(ChatGPT Plus)
- New Bing AI API
implementation 'com.yat3s.openai:openai-android:0.0.4'
Or exclude okhttp if you're using a version < okhttp3: 4.10.0
in your project.
implementation 'com.yat3s.openai:openai-android:0.0.4' {
exclude group: "com.squareup.okhttp3"
}
val response = TextCompletionBuilder(BuildConfig.OPENAI_API_KEY).build().textCompletion("Your prompt)
val response = TextCompletionBuilder(OPENAI_API_KEY)
.maxTokens(1000) // 1 - 4000, default 500
.temperature(0.6f) // 0 - 2f, default 1f
.model("you model") // default "text-davinci-003"
.build().textCompletion(text)
Please check the definition on Open AI text completion parameters
val response = ImageGenerationBuilder(BuildConfig.OPENAI_API_KEY).build().imageGeneration("Your prompt")
val response = ImageGenerationBuilder(OPENAI_API_KEY)
.generateCount(2) // The image count to generate, default 1
.imageSize("512x512") // "256x256", "512x512", "1024x1024" are supported, default "1024x1024"
.imageResponseFormat("url") // "url", "b64_json" are supported, default "url"
.build()
.imageGeneration("Your prompt")
Please go to Open AI API KEY to create your API keys.