Skip to content

Latest commit

 

History

History
56 lines (46 loc) · 1.71 KB

README.md

File metadata and controls

56 lines (46 loc) · 1.71 KB

OpenAI Android

The project for OpenAI official APIs

  • Text Completion
  • Image Generation(DALL-E)
  • Playground
  • ChatGPT Web API(ChatGPT Plus)
  • New Bing AI API

Usages

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"
}

Text Completion

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

Advanced Configurations

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

Image Generation(DALL-E)

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

Advanced Configurations

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")

How to get API KEY

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