Skip to content

OpenAI API client for Android and coroutines functionalities.

License

Notifications You must be signed in to change notification settings

sunnat629/openai-android

Repository files navigation

Maven Central License

OpenAI API Client for Android

Android client named openai-android for OpenAI's API, optimized for Android development, featuring coroutines support for asynchronous operations.

📦 Setup

Gradle

For Android projects, Add the OpenAI API Android client to your project by inserting the following dependency in your build.gradle.kts file. it's straightforward to set up the client using Gradle:

repositories {
    mavenCentral()
}

dependencies {
    implementation("dev.sunnat629:openai-android:0.1.2")
}

⚡️ Getting Started

Initialize OpenAI client instance:

val openAI = OpenAIBuilder(token = BuildConfig.OPEN_AI_TOKEN)
    .organization("your_organization_id") // Optional: Set if you have an organization ID
    .refreshToken("your_refresh_token") // Optional: Set if using OAuth2 refresh token
    .headers(mapOf("Custom-Header" to "Value")) // Optional: Set custom headers if needed
    .logging(loggingConfig) // Optional: Configure logging
    .retry(retryConfig) // Optional: Configure retry policy
    .build()

To modify the line where you use the OpenAI instance to interact with the API, incorporating the secure use of the TOKEN from your build configuration, visit here.

📚 Wiki

Explore detailed wiki on how to effectively use the OpenAI API client for Android:

Available

Upcoming

Platform Compatibility

📱 Current Support:

This library is currently available for Android. We've designed it with robust features tailored specifically for Android applications.

🚀 Future Plans:

We are excited to announce that soon we'll be expanding support to Kotlin Multiplatform. This update will enable developers to use our library across various platforms seamlessly, enhancing code reusability and efficiency. Stay tuned for more updates!

⭐️ Support

Like what you see? Here’s how to support the project:

  1. Star it: Click the star at the top. It helps a lot!
  2. Contribute: Issues, feature ideas? Your PRs are welcome.
  3. Share your thoughts: Suggestions? Open an issue or start a discussion.
  4. Buy me a coffee PayPal

📄 License

This openai-android for OpenAI's API is open-source under the MIT license. Note: This is an unofficial library and is not endorsed by OpenAI.