OpenAI Kotlin API client with multiplatform and coroutines support, mirroring OpenAI endpoints in Kotlin. Latest release 4.1.0 adds Batch extension and Responses API, with Kotlin 2.0 upgrade and WasmJs target updates.
Collecting history — the radar snapshots this repo daily. The trend line appears after 3 days of data (1 so far).
What it is
OpenAI API client for Kotlin. It provides a multiplatform Kotlin client for OpenAI APIs with coroutine support and various features (Chat, Images, Embeddings, Files, fine-tuning, Moderations, Audio, Batch, etc.).
How it works
The library exposes an OpenAI client that you instantiate with a token and optional configuration, then use the client to perform API requests. It supports multiple targets and engines based on Ktor HTTP client configurations. The README references a pre-configured OpenAIConfig for building the client and describes using different engines per target.
Getting started
Install via Gradle by adding the dependency:
repositories {
mavenCentral()
}
dependencies {
implementation "com.aallam.openai:openai-client:4.1.0"
}
Or use the BOM approach:
dependencies {
// import Kotlin API client BOM
implementation platform('com.aallam.openai:openai-client-bom:4.1.0')
// define dependencies without versions
implementation 'com.aallam.openai:openai-client'
runtimeOnly 'io.ktor:ktor-client-okhttp'
}
Create an OpenAI instance:
val openai = OpenAI(
token = "your-api-key",
timeout = Timeout(socket = 60.seconds),
// additional configurations...
)
Or with OpenAIConfig:
val config = OpenAIConfig(
token = apiKey,
timeout = Timeout(socket = 60.seconds),
// additional configurations...
)
val openAI = OpenAI(config)
Supported features include: Responses, Models, Chat, Images, Embeddings, Files, Fine-tuning, Moderations, Audio, Batch, and beta features like Assistants, Threads, Messages, Runs, Vector Stores.
Quick usage notes
- Documentation and guides are linked in the repository.
- Environment variables are recommended for API key handling.
Recent releases
- 4.1.0 (2026-02-07): Added batch support by making OpenAI interface extend Batch; added Responses API support (create, retrieve, cancel, delete, input_items listing); various internal changes.
- 4.0.1 (2025-02-02): Added chat features like reasoning effort, max completion tokens, store options for reasoning model support.
- 4.0.0 (2025-02-02): WasmJs target; added structured response for assistants; chat structured outputs; updated ChatCompletionRequest (and related features).
- 4.0.0-beta01 (2024-10-28): WasmJs target; structured response for assistants.
Traction
- Stars: 1842
- Forks: 237
- Open issues: 81
License
MIT
Behind the repo
Not provided in the facts block beyond the repository metadata.
Caveats
License: MIT; age since creation: 2021-03-06; last push: 2026-02-07. No further caveats specified in the provided content.






