OpenAI Android

The project for OpenAI official APIs

Usages

implementation 'com.yat3s.openai:openai-android:0.0.3'

Text Completion

val response = TextCompletionBuilder(BuildConfig.OPENAI_API_KEY).build().textCompletion("Your prompt)

Advanced Configurations

val response = TextCompletionBuilder(BuildConfig.OPENAI_API_KEY)
    .maxTokens(1000)
    .temperature(0.6f)
    .model("you model")
    .build().textCompletion(text)

Please go Open AI text completion parameters to check the definition of the parameters.

Image Generation(DALL-E)

val response = ImageGenerationBuilder(BuildConfig.OPENAI_API_KEY).build().imageGeneration("Your prompt")

Advanced Configurations

val response = ImageGenerationBuilder(BuildConfig.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")

How to get API KEY

Please go to Open AI API KEY to create your API KEY. image

GitHub

View Github