openai-kotlin  by aallam

Kotlin client for OpenAI API

Created 4 years ago
1,764 stars

Top 24.3% on SourcePulse

GitHubView on GitHub
Project Summary

This project provides a Kotlin client for the OpenAI API, targeting Kotlin developers who need to integrate with OpenAI's services. It offers multiplatform support and leverages Kotlin coroutines for asynchronous operations, simplifying the development of AI-powered applications in Kotlin.

How It Works

The client is built on top of Ktor, a Kotlin multiplatform asynchronous framework for creating connected applications. This choice allows for efficient, non-blocking network requests and seamless integration across different platforms (JVM, JS, Native). The library exposes a fluent Kotlin API that maps directly to OpenAI's REST endpoints, abstracting away the complexities of HTTP requests and JSON serialization.

Quick Start & Requirements

  • Install: Add com.aallam.openai:openai-client:4.0.1 to your build.gradle file.
  • Dependencies: Requires a Ktor client engine (e.g., ktor-client-okhttp). For multiplatform projects, specify the engine for each target.
  • Setup: Basic setup involves instantiating the OpenAI client with an API key.
  • Docs: Getting Started, Guides

Highlighted Details

  • Supports a comprehensive range of OpenAI API features including Chat, Images, Embeddings, Files, Fine-tuning, Moderations, Audio, and Assistants.
  • Built with Kotlin Multiplatform, enabling code sharing across JVM, Android, iOS, and other Kotlin-supported platforms.
  • Leverages Kotlin Coroutines for asynchronous API calls, promoting a modern and efficient development style.
  • Includes ProGuard/R8 rules bundled within the JAR for automatic compatibility.

Maintenance & Community

The project is actively maintained by aallam. Contributions are welcome via pull requests and issue reporting.

Licensing & Compatibility

  • License: MIT License.
  • Compatibility: Permissive MIT license allows for commercial use and integration into closed-source projects.

Limitations & Caveats

This is an unofficial library and is not affiliated with or endorsed by OpenAI. Some beta features of the OpenAI API might not be immediately supported.

Health Check
Last Commit

4 months ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
1
Star History
15 stars in the last 30 days

Explore Similar Projects

Feedback? Help us improve.