Android client named openai-android
for OpenAI's API, optimized for Android development, featuring coroutines support for asynchronous operations.
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")
}
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.
Explore detailed wiki on how to effectively use the OpenAI API client for Android:
- Chat: API, Interfaces
- Models: API, Interfaces
- Moderations API, Interfaces
- Audio: API, Interfaces
- Assistants: API, Interfaces
- Embeddings: API, Interfaces
- Files: API, Interfaces
- Fine-tuning: API, Interfaces
- Images: API, Interfaces
- Messages: API, Interfaces
- Runs: API, Interfaces
- Threads: API, Interfaces
This library is currently available for Android. We've designed it with robust features tailored specifically for Android applications.
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!
Like what you see? Here’s how to support the project:
- Star it: Click the star at the top. It helps a lot!
- Contribute: Issues, feature ideas? Your PRs are welcome.
- Share your thoughts: Suggestions? Open an issue or start a discussion.
- Buy me a coffee PayPal
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.