Call OpenAI chat completions from shared Kotlin code in an Android plus iOS app
Add embeddings and vector store APIs only, keeping the binary small
Use the realtime WebSocket module from a desktop Kotlin client
Run image and audio endpoints from a Wasm or Linux x64 target
Needs a Kotlin Multiplatform Gradle project plus an OpenAI API key, and you must add a separate module per endpoint family.
openai-kmp is a Kotlin Multiplatform SDK for the OpenAI APIs. The point of being multiplatform is that the same Kotlin code can be compiled for many targets: Android, JVM, iOS in several CPU variants, macOS, tvOS, watchOS, Linux x64, Windows mingw x64, and WasmJs. The transport layer is built on Ktor, and the SDK is published to Maven Central. Instead of one giant artifact, the project is split into about fourteen small modules. openai-core holds shared error and list contracts, and openai-client provides the HTTP transport, configuration, and JSON or multipart plumbing. On top of that sit one module per OpenAI endpoint family: chat completions, responses, embeddings, files, batches, models, moderations, images, audio, realtime over WebSocket, fine-tuning, vector stores, and multipart upload sessions. You pick only the modules your app needs, which keeps binaries small. The Gradle version catalog snippet in the README pins everything to a single openai-kmp version reference so all modules move together. In your commonMain source set you depend on openai-client plus whichever endpoint modules you want. A client is built with OpenAI.create, passing an api key from an environment variable plus optional settings like logging, a timeout in milliseconds, and OpenAI organization and project IDs. From the client you call accessor methods such as client.chat(), client.responses(), client.embeddings(), client.images(), client.audio(), client.fineTuning(), client.vectorStores(), and client.uploads(), each of which exposes typed request methods like createTyped or generateTyped. Results are returned as an outcome object rather than being thrown. You call onSuccess and onFailure on it, where the failure side gives you a status code and message. The project is MIT licensed.
Generated 2026-05-22 · Model: sonnet-4-6 · Verify against the repo before relying on details.