{"id":13607825,"url":"https://github.com/aallam/openai-kotlin","last_synced_at":"2025-05-14T02:05:37.875Z","repository":{"id":37399192,"uuid":"345180734","full_name":"aallam/openai-kotlin","owner":"aallam","description":"OpenAI API client for Kotlin with multiplatform and coroutines capabilities.","archived":false,"fork":false,"pushed_at":"2025-04-23T09:16:12.000Z","size":12879,"stargazers_count":1671,"open_issues_count":61,"forks_count":215,"subscribers_count":30,"default_branch":"main","last_synced_at":"2025-04-23T09:37:53.789Z","etag":null,"topics":["api","chatgpt","client","coroutines","dall-e","gpt","kotlin","llm","multiplatform","openai","whisper"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aallam.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-03-06T19:45:05.000Z","updated_at":"2025-04-23T09:16:17.000Z","dependencies_parsed_at":"2024-04-17T22:26:55.114Z","dependency_job_id":"5b25670f-1673-45f9-b2de-0ef959a8787f","html_url":"https://github.com/aallam/openai-kotlin","commit_stats":{"total_commits":366,"total_committers":37,"mean_commits":9.891891891891891,"dds":0.5382513661202186,"last_synced_commit":"3d9202286dececdb058bdbf490ca7b8ddb63e7d6"},"previous_names":[],"tags_count":50,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aallam%2Fopenai-kotlin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aallam%2Fopenai-kotlin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aallam%2Fopenai-kotlin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aallam%2Fopenai-kotlin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aallam","download_url":"https://codeload.github.com/aallam/openai-kotlin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254052692,"owners_count":22006716,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","chatgpt","client","coroutines","dall-e","gpt","kotlin","llm","multiplatform","openai","whisper"],"created_at":"2024-08-01T19:01:21.914Z","updated_at":"2025-05-14T02:05:32.854Z","avatar_url":"https://github.com/aallam.png","language":"Kotlin","funding_links":[],"categories":["CLIs","LLM Provider API","SDK, Libraries, Frameworks","Kotlin","2. Libraries \u0026 Frameworks"],"sub_categories":["Kotlin library, sdk or frameworks","Kotlin"],"readme":"# OpenAI API client for Kotlin\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.aallam.openai/openai-client?color=blue\u0026label=Download)](https://central.sonatype.com/namespace/com.aallam.openai)\n[![License](https://img.shields.io/github/license/Aallam/openai-kotlin?color=yellow)](LICENSE.md)\n[![Documentation](https://img.shields.io/badge/docs-api-a97bff.svg?logo=kotlin)](https://mouaad.aallam.com/openai-kotlin/)\n\nKotlin client for [OpenAI's API](https://beta.openai.com/docs/api-reference) with multiplatform and coroutines\ncapabilities.\n\n## 📦 Setup\n\n1. Install OpenAI API Kotlin client by adding the following dependency to your `build.gradle` file:\n\n```groovy\nrepositories {\n    mavenCentral()\n}\n\ndependencies {\n    implementation \"com.aallam.openai:openai-client:4.0.1\"\n}\n```\n\n2. Choose and add to your dependencies one of [Ktor's engines](https://ktor.io/docs/http-client-engines.html).\n\n#### BOM\n\nAlternatively, you can use [openai-client-bom](/openai-client-bom)  by adding the following dependency to your `build.gradle` file\n\n```groovy\ndependencies {\n    // import Kotlin API client BOM\n    implementation platform('com.aallam.openai:openai-client-bom:4.0.1')\n\n    // define dependencies without versions\n    implementation 'com.aallam.openai:openai-client'\n    runtimeOnly 'io.ktor:ktor-client-okhttp'\n}\n```\n\n### Multiplatform\n\nIn multiplatform projects, add openai client dependency to `commonMain`, and choose\nan [engine](https://ktor.io/docs/http-client-engines.html) for each target.\n\n### Maven\n\nGradle is required for multiplatform support, but there's nothing stopping you from using the jvm client in a Maven\nproject. You still need to add to your dependencies one\nof [Ktor's engines](https://ktor.io/docs/http-client-engines.html).\n\n\u003cdetails\u003e\n \u003csummary\u003eSetup the client with maven\u003c/summary\u003e\n\n```xml\n\u003cdependencies\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003ecom.aallam.openai\u003c/groupId\u003e\n        \u003cartifactId\u003eopenai-client-jvm\u003c/artifactId\u003e\n        \u003cversion\u003e3.8.0\u003c/version\u003e\n    \u003c/dependency\u003e\n            \n    \u003cdependency\u003e\n        \u003cgroupId\u003eio.ktor\u003c/groupId\u003e\n        \u003cartifactId\u003ektor-client-okhttp-jvm\u003c/artifactId\u003e\n        \u003cversion\u003e2.3.2\u003c/version\u003e\n        \u003cscope\u003eruntime\u003c/scope\u003e\n    \u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\n\u003c/details\u003e\n\nThe BOM is not supported for Maven projects.\n\n## ⚡️ Getting Started\n\n\u003e [!NOTE]\n\u003e OpenAI encourages using environment variables for the API key.\n\u003e [Read more](https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety).\n\nCreate an instance of `OpenAI` client:\n\n```kotlin\nval openai = OpenAI(\n    token = \"your-api-key\",\n    timeout = Timeout(socket = 60.seconds),\n    // additional configurations...\n)\n```\n\nOr you can create an instance of `OpenAI` using a pre-configured `OpenAIConfig`:\n\n```kotlin\nval config = OpenAIConfig(\n    token = apiKey,\n    timeout = Timeout(socket = 60.seconds),\n    // additional configurations...\n)\n\nval openAI = OpenAI(config)\n```\n\nUse your `OpenAI` instance to make API requests. [Learn more](guides/GettingStarted.md).\n\n### Supported features\n\n- [Models](guides/GettingStarted.md#models)\n- [Chat](guides/GettingStarted.md#chat)\n- [Images](guides/GettingStarted.md#images)\n- [Embeddings](guides/GettingStarted.md#embeddings)\n- [Files](guides/GettingStarted.md#files)\n- [Fine-tuning](guides/GettingStarted.md#fine-tuning)\n- [Moderations](guides/GettingStarted.md#moderations)\n- [Audio](guides/GettingStarted.md#audio)\n\n#### Beta\n\n- [Assistants](guides/GettingStarted.md#assistants)\n- [Threads](guides/GettingStarted.md#threads)\n- [Messages](guides/GettingStarted.md#messages)\n- [Runs](guides/GettingStarted.md#runs)\n\n#### Deprecated\n- [Completions](guides/GettingStarted.md#completions)\n- [Fine-tunes](guides/GettingStarted.md#fine-tunes)\n- [Edits](guides/GettingStarted.md#edits)\n\n*Looking for a tokenizer? Try [ktoken](https://github.com/aallam/ktoken), a Kotlin library for tokenizing text.*\n\n## 📚 Guides\n\nGet started and understand more about how to use OpenAI API client for Kotlin with these guides:\n\n- [Getting Started](guides/GettingStarted.md)\n- [Chat \u0026 Function Call](guides/ChatToolCalls.md)\n- [FileSource Guide](guides/FileSource.md)\n- [Assistants](guides/Assistants.md)\n\n## ℹ️ Sample apps\n\nSample apps are available under `sample`, please check the [README](sample/README.md) for running instructions.\n\n## 🔒 ProGuard / R8\n\nThe specific rules are [already bundled](openai-core/src/jvmMain/resources/META-INF/proguard/openai.pro) into the Jar which can be interpreted by R8 automatically.\n\n## 📸 Snapshots\n\n[![Snapshot](https://img.shields.io/badge/dynamic/xml?url=https://oss.sonatype.org/service/local/repositories/snapshots/content/com/aallam/openai/openai-client/maven-metadata.xml\u0026label=snapshot\u0026color=red\u0026query=.//versioning/latest)](https://oss.sonatype.org/content/repositories/snapshots/com/aallam/openai/openai-client/)\n\n\u003cdetails\u003e\n \u003csummary\u003eLearn how to import snapshot version\u003c/summary\u003e\n\nTo import snapshot versions into your project, add the following code snippet to your gradle file:\n\n```groovy\nrepositories {\n   //...\n   maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }\n}\n```\n\n\u003c/details\u003e\n\n## 🛠️ Troubleshooting\n\nFor common issues and their solutions, check the [Troubleshooting Guide](TROUBLESHOOTING.md).\n\n## ⭐️ Support\n\nAppreciate the project? Here's how you can help:\n\n1. **Star**: Give it a star at the top right. It means a lot!\n2. **Contribute**: Found an issue or have a feature idea? Submit a PR.\n3. **Feedback**: Have suggestions? Open an issue or start a discussion.\n\n## 📄 License\n\nOpenAI Kotlin API Client is an open-sourced software licensed under the [MIT license](LICENSE.md).\n**This is an unofficial library, it is not affiliated with nor endorsed by OpenAI**. Contributions are welcome.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faallam%2Fopenai-kotlin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faallam%2Fopenai-kotlin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faallam%2Fopenai-kotlin/lists"}