Skip to content

Commit 79c9106

Browse files
rasharabaallam
andauthored
Sync fork with upstream (v4.1.0) — preserve fork models, add upstream additive changes (#17)
* feat: refresh OpenAI API compatibility (aallam#458) * feat: refresh OpenAI API compatibility - add Responses API support (create/retrieve/cancel/delete/list input items) - add response models and structured input serialization - add chat compatibility fields: web_search_options, annotations, reasoning_content - fix ChatCompletionRequestBuilder mutability for reasoningEffort/store/maxCompletionTokens - improve ChatResponseFormat compatibility for primitive/object payloads - add compatibility tests and update docs/changelog/api baselines Related PRs: aallam#437 aallam#438 aallam#439 aallam#441 aallam#450 Fixes aallam#440 Refs aallam#446 aallam#454 aallam#377 * ci(test): make live API tests opt-in - gate openai-client test execution behind OPENAI_LIVE_TESTS=1 - update shared test harness and misc tests to avoid billable calls by default - disable test retries in live test config to reduce accidental cost - split CI into offline checks + JVM live smoke - add separate scheduled/manual full live workflow - document test-cost behavior in README * ci: run live test jobs only on main Restrict live-smoke-jvm and live-full jobs to refs/heads/main. * ci: run offline checks on PRs and full live tests on main - keep lint/offline checks for pull requests - run full openai-client live suite only on push to main - remove scheduled full-live workflow trigger * ci: remove standalone live-full workflow Live tests now run from build.yml only on pushes to main. * ci: fix workflow expression for live tests Remove secrets context from job-level if and guard live test step with a shell check for OPENAI_API_KEY. * fix(images,tests): stabilize live suites for image edits and vector stores (aallam#459) * test(vector-stores): avoid flaky immediate list containment assertion Vector store list responses are paginated/eventually consistent; keep create/retrieve/update/delete assertions and make list check non-brittle. * fix(images): align edit uploads with current API requirements - include default model for image edit requests when omitted - send PNG mime type for image edit/variation file parts - make live image edit tests explicit with model=dall-e-2 * test(chat-vision): remove flaky external image URL dependency Use a deterministic data URL generated from bundled test resources for common live vision tests. * chore(release): prepare 4.1.0 * chore: update maven-publish version * docs: align README and guides with current API surface [skip ci] * Remove upstream-only files: TestResponses.kt, ResponseInput.kt, ResponseId.kt * feat: rename response API methods and reasoning config Agent-Id: agent-d3cedbcf-047f-4488-b327-4bc989eab49d Linked-Note-Id: 95dee90b-6003-487e-82ff-40897eeceace * feat: add response retrieval, deletion, and cancellation endpoints Agent-Id: agent-e1e893ed-1378-4eb9-9911-3c6c4b2c5a7c Linked-Note-Id: fc3a8998-aa78-4d48-a5f2-8b9c3e21ce31 * feat: restore ResponseId value class for response identification Agent-Id: agent-91b7b111-1dd4-45c1-bc0c-5b0615a04d39 * chore: update API surface files * style: fix spotless formatting * ci: update to JDK 17 * fix: regenerate API files for JDK 17 compatibility * build: exclude dokkaHtml from build-maven-local * build: fix signing disable flag in Makefile * build: minimize build-maven-local to JVM-only publications * build: add BOM back to build-maven-local * build: include KMP metadata modules in build-maven-local * build: clean up checksums, javadoc, and tooling metadata from .maven --------- Co-authored-by: Mouaad Aallam <Mouaad@Aallam.com>
1 parent 7b8e2bd commit 79c9106

44 files changed

Lines changed: 7590 additions & 3680 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 48 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -28,49 +28,18 @@ jobs:
2828
uses: actions/setup-java@v4
2929
with:
3030
distribution: temurin
31-
java-version: 11
31+
java-version: 17
3232

3333
- name: Setup Gradle
3434
uses: gradle/gradle-build-action@v3
3535

3636
- name: Run lint
3737
run: ./gradlew spotlessCheck
3838

39-
test-jvm:
40-
name: Test JVM
39+
offline-checks:
40+
name: Offline Checks
4141
runs-on: ubuntu-latest
4242
needs: lint
43-
strategy:
44-
matrix:
45-
include:
46-
- name: Assistants
47-
test: "*.TestAssistants"
48-
- name: Audio
49-
test: "*.TestAudio"
50-
- name: Chat Completions
51-
test: "*.TestChat*"
52-
- name: Embeddings
53-
test: "*.TestEmbeddings"
54-
- name: Files
55-
test: "*.TestFiles"
56-
- name: Fine-tuning
57-
test: "*.TestFineTuning"
58-
- name: Images
59-
test: "*.TestImages"
60-
- name: Messages
61-
test: "*.TestMessages"
62-
- name: Models
63-
test: "*.TestModels"
64-
- name: Moderations
65-
test: "*.TestModerations"
66-
- name: Runs
67-
test: "*.TestRuns"
68-
- name: Threads
69-
test: "*.TestThreads"
70-
- name: Vector Stores
71-
test: "*.TestVectorStores"
72-
- name: Misc.
73-
test: "*.misc.*"
7443
steps:
7544
- name: Checkout
7645
uses: actions/checkout@v4
@@ -82,20 +51,59 @@ jobs:
8251
uses: actions/setup-java@v4
8352
with:
8453
distribution: temurin
85-
java-version: 11
54+
java-version: 17
8655

8756
- name: Setup Gradle
8857
uses: gradle/gradle-build-action@v3
8958

90-
- name: Test ${{ matrix.name }}
91-
run: ./gradlew :openai-client:jvmTest --tests ${{ matrix.test }}
59+
- name: Run offline checks
60+
run: >
61+
./gradlew
62+
:openai-core:jvmTest
63+
:openai-core:jsTest
64+
:openai-core:wasmJsTest
65+
:openai-core:apiCheck
66+
:openai-client:apiCheck
67+
:openai-client:compileTestKotlinJvm
68+
:openai-client:compileTestKotlinJs
69+
:openai-client:compileTestKotlinWasmJs
70+
71+
live-full-jvm:
72+
name: Live Full JVM
73+
runs-on: ubuntu-latest
74+
needs: offline-checks
75+
if: ${{ github.repository == 'aallam/openai-kotlin' && github.event_name == 'push' && github.ref == 'refs/heads/main' }}
76+
steps:
77+
- name: Checkout
78+
uses: actions/checkout@v4
79+
80+
- name: Validate Gradle Wrapper
81+
uses: gradle/actions/wrapper-validation@v3
82+
83+
- name: Configure JDK
84+
uses: actions/setup-java@v4
85+
with:
86+
distribution: temurin
87+
java-version: 17
88+
89+
- name: Setup Gradle
90+
uses: gradle/gradle-build-action@v3
91+
92+
- name: Run full live tests
9293
env:
94+
OPENAI_LIVE_TESTS: "1"
9395
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
96+
run: |
97+
if [ -z "${OPENAI_API_KEY}" ]; then
98+
echo "OPENAI_API_KEY is not configured; skipping live tests."
99+
exit 0
100+
fi
101+
./gradlew :openai-client:jvmTest
94102
95103
publish-docs:
96104
runs-on: ubuntu-latest
97-
needs: [ test-jvm ]
98-
if: github.repository == 'aallam/openai-kotlin' && github.ref == 'refs/heads/main'
105+
needs: [ offline-checks, live-full-jvm ]
106+
if: ${{ github.repository == 'aallam/openai-kotlin' && github.ref == 'refs/heads/main' && (needs['live-full-jvm'].result == 'success' || needs['live-full-jvm'].result == 'skipped') }}
99107
permissions:
100108
contents: write
101109
steps:
@@ -109,7 +117,7 @@ jobs:
109117
uses: actions/setup-java@v4
110118
with:
111119
distribution: temurin
112-
java-version: 11
120+
java-version: 17
113121

114122
- name: Setup Gradle
115123
uses: gradle/gradle-build-action@v3

.github/workflows/publish-snapshot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
uses: actions/setup-java@v4
3838
with:
3939
distribution: temurin
40-
java-version: 11
40+
java-version: 17
4141

4242
- name: Setup Gradle
4343
uses: gradle/gradle-build-action@v3

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ jobs:
1818
uses: actions/setup-java@v4
1919
with:
2020
distribution: temurin
21-
java-version: 11
21+
java-version: 17
2222

2323
- name: Setup Gradle
2424
uses: gradle/gradle-build-action@v3
2525

2626
- name: Upload Artifacts
27-
run: ./gradlew publishAllPublicationsToMavenCentral --no-configuration-cache
27+
run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache
2828
env:
2929
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
3030
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ coverage-error.log
2727
kotlin-js-store
2828

2929
.kotlin
30+
.codex

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
build-maven-local:
2-
@echo "Building and publishing JARs to local Maven repository (.maven)..."
3-
./gradlew :openai-core:publishJvmPublicationToMavenRepository :openai-core:publishKotlinMultiplatformPublicationToMavenRepository -PRELEASE_SIGNING_ENABLED=false
4-
./gradlew :openai-client:publishJvmPublicationToMavenRepository :openai-client:publishKotlinMultiplatformPublicationToMavenRepository -PRELEASE_SIGNING_ENABLED=false
5-
./gradlew :openai-client-bom:publishMavenPublicationToMavenRepository -PRELEASE_SIGNING_ENABLED=false
2+
@echo "Building and publishing to local Maven repository (.maven)..."
3+
./gradlew :openai-core:publishJvmPublicationToMavenRepository :openai-core:publishKotlinMultiplatformPublicationToMavenRepository :openai-client:publishJvmPublicationToMavenRepository :openai-client:publishKotlinMultiplatformPublicationToMavenRepository :openai-client-bom:publishMavenPublicationToMavenRepository -PsignAllPublications=false -x dokkaHtml
4+
@echo "Cleaning up unnecessary files..."
5+
find .maven -type f \( -name "*.md5" -o -name "*.sha1" -o -name "*.sha256" -o -name "*.sha512" -o -name "*-javadoc.jar" -o -name "*-kotlin-tooling-metadata.json" \) -delete
66
@echo "Local JARs published to .maven directory"
77

88
generate-maven-dependencies:

README.md

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![License](https://img.shields.io/github/license/Aallam/openai-kotlin?color=yellow)](LICENSE.md)
55
[![Documentation](https://img.shields.io/badge/docs-api-a97bff.svg?logo=kotlin)](https://mouaad.aallam.com/openai-kotlin/)
66

7-
Kotlin client for [OpenAI's API](https://beta.openai.com/docs/api-reference) with multiplatform and coroutines
7+
Kotlin client for [OpenAI's API](https://platform.openai.com/docs/api-reference) with multiplatform and coroutines
88
capabilities.
99

1010
## 📦 Setup
@@ -17,7 +17,7 @@ repositories {
1717
}
1818
1919
dependencies {
20-
implementation "com.aallam.openai:openai-client:4.0.1"
20+
implementation "com.aallam.openai:openai-client:4.1.0"
2121
}
2222
```
2323

@@ -30,7 +30,7 @@ Alternatively, you can use [openai-client-bom](/openai-client-bom) by adding th
3030
```groovy
3131
dependencies {
3232
// import Kotlin API client BOM
33-
implementation platform('com.aallam.openai:openai-client-bom:4.0.1')
33+
implementation platform('com.aallam.openai:openai-client-bom:4.1.0')
3434
3535
// define dependencies without versions
3636
implementation 'com.aallam.openai:openai-client'
@@ -57,13 +57,13 @@ of [Ktor's engines](https://ktor.io/docs/http-client-engines.html).
5757
<dependency>
5858
<groupId>com.aallam.openai</groupId>
5959
<artifactId>openai-client-jvm</artifactId>
60-
<version>3.8.0</version>
60+
<version>4.1.0</version>
6161
</dependency>
6262

6363
<dependency>
6464
<groupId>io.ktor</groupId>
6565
<artifactId>ktor-client-okhttp-jvm</artifactId>
66-
<version>2.3.2</version>
66+
<version>3.0.0</version>
6767
<scope>runtime</scope>
6868
</dependency>
6969
</dependencies>
@@ -105,6 +105,7 @@ Use your `OpenAI` instance to make API requests. [Learn more](guides/GettingStar
105105

106106
### Supported features
107107

108+
- [Responses](guides/GettingStarted.md#responses)
108109
- [Models](guides/GettingStarted.md#models)
109110
- [Chat](guides/GettingStarted.md#chat)
110111
- [Images](guides/GettingStarted.md#images)
@@ -113,13 +114,15 @@ Use your `OpenAI` instance to make API requests. [Learn more](guides/GettingStar
113114
- [Fine-tuning](guides/GettingStarted.md#fine-tuning)
114115
- [Moderations](guides/GettingStarted.md#moderations)
115116
- [Audio](guides/GettingStarted.md#audio)
117+
- [Batch](guides/GettingStarted.md#batch)
116118

117119
#### Beta
118120

119121
- [Assistants](guides/GettingStarted.md#assistants)
120122
- [Threads](guides/GettingStarted.md#threads)
121123
- [Messages](guides/GettingStarted.md#messages)
122124
- [Runs](guides/GettingStarted.md#runs)
125+
- [Vector Stores](guides/GettingStarted.md#vector-stores)
123126

124127
#### Deprecated
125128
- [Completions](guides/GettingStarted.md#completions)
@@ -133,7 +136,7 @@ Use your `OpenAI` instance to make API requests. [Learn more](guides/GettingStar
133136
Get started and understand more about how to use OpenAI API client for Kotlin with these guides:
134137

135138
- [Getting Started](guides/GettingStarted.md)
136-
- [Chat & Function Call](guides/ChatToolCalls.md)
139+
- [Chat & Tool Calls](guides/ChatToolCalls.md)
137140
- [FileSource Guide](guides/FileSource.md)
138141
- [Assistants](guides/Assistants.md)
139142

@@ -147,7 +150,7 @@ The specific rules are [already bundled](openai-core/src/jvmMain/resources/META-
147150

148151
## 📸 Snapshots
149152

150-
[![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&label=snapshot&color=red&query=.//versioning/latest)](https://oss.sonatype.org/content/repositories/snapshots/com/aallam/openai/openai-client/)
153+
[![Snapshot](https://img.shields.io/badge/dynamic/xml?url=https://central.sonatype.com/repository/maven-snapshots/com/aallam/openai/openai-client/maven-metadata.xml&label=snapshot&color=red&query=.//versioning/latest)](https://central.sonatype.com/repository/maven-snapshots/com/aallam/openai/openai-client/)
151154

152155
<details>
153156
<summary>Learn how to import snapshot version</summary>
@@ -157,7 +160,7 @@ To import snapshot versions into your project, add the following code snippet to
157160
```groovy
158161
repositories {
159162
//...
160-
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
163+
maven { url 'https://central.sonatype.com/repository/maven-snapshots/' }
161164
}
162165
```
163166

@@ -167,6 +170,23 @@ repositories {
167170

168171
For common issues and their solutions, check the [Troubleshooting Guide](TROUBLESHOOTING.md).
169172

173+
## 🧪 Testing
174+
175+
`openai-client` tests are live integration tests and can generate billable API traffic.
176+
177+
- Default (non-billable): live tests are disabled.
178+
- Opt-in live tests: set `OPENAI_LIVE_TESTS=1` and `OPENAI_API_KEY`.
179+
180+
Examples:
181+
182+
```bash
183+
# Free/offline checks
184+
./gradlew :openai-core:jvmTest :openai-core:jsTest :openai-core:wasmJsTest :openai-core:apiCheck :openai-client:apiCheck
185+
186+
# Live smoke (billable)
187+
OPENAI_LIVE_TESTS=1 OPENAI_API_KEY=... ./gradlew :openai-client:jvmTest --tests "*.TestModels"
188+
```
189+
170190
## ⭐️ Support
171191

172192
Appreciate the project? Here's how you can help:

TROUBLESHOOTING.md

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,37 @@
11
# Troubleshooting Guide
22

3-
Facing issues while using the OpenAI Kotlin API Client? Here are some common problems and their solutions.
3+
Facing issues while using the OpenAI Kotlin API Client? Here are common checks.
44

55
<details>
6-
<summary>I'm seeing "The model: gpt-4 does not exist"</summary>
6+
<summary>"The model ... does not exist" or "You do not have access to model ..."</summary>
77

8-
The access to GPT-4 API is restricted at the moment. You can join the waitlist using [this form](https://openai.com/waitlist/gpt-4-api).
8+
1. Confirm the model ID is valid for your account.
9+
2. Call `openAI.models()` and verify the model appears in your list.
10+
3. If you use Azure, make sure `deploymentId` matches your deployed model and that `apiVersion` is supported.
11+
</details>
12+
13+
<details>
14+
<summary>401 Unauthorized / invalid_api_key</summary>
15+
16+
1. Verify `OPENAI_API_KEY` is set in the environment used by your runtime.
17+
2. Ensure there are no extra spaces/newlines in the key value.
18+
3. If using custom hosts or proxies, confirm the `Authorization` header is being forwarded unchanged.
19+
</details>
20+
21+
<details>
22+
<summary>429 Rate limit or quota errors</summary>
23+
24+
1. Retry with exponential backoff.
25+
2. Reduce concurrency and token usage.
26+
3. Tune `RetryStrategy` in `OpenAIConfig` for your traffic pattern.
27+
</details>
28+
29+
<details>
30+
<summary>Live tests fail unexpectedly</summary>
31+
32+
`openai-client` live tests are opt-in and billable. Ensure:
33+
34+
1. `OPENAI_LIVE_TESTS=1`
35+
2. `OPENAI_API_KEY` is set
36+
3. The selected model/feature is available to your account
937
</details>

gradle.properties

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ kotlin.mpp.commonizerLogLevel=info
44

55
# Lib
66
GROUP=com.aallam.openai
7-
VERSION_NAME=4.0.7
7+
VERSION_NAME=4.1.1
88

99
# OSS
10-
SONATYPE_HOST=DEFAULT
11-
RELEASE_SIGNING_ENABLED=true
12-
SONATYPE_AUTOMATIC_RELEASE=true
10+
mavenCentralPublishing=true
11+
signAllPublications=true
12+
mavenCentralAutomaticPublishing=true
1313

1414
# POM
1515
POM_DESCRIPTION=OpenAI API Kotlin Client

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ ktoken = { group = "com.aallam.ktoken", name = "ktoken", version = "0.3.0" }
4141
kotlin-multiplaform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
4242
kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
4343
kotlinx-binary-validator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version = "0.14.0" }
44-
maven-publish = { id = "com.vanniktech.maven.publish", version = "0.25.3" }
44+
maven-publish = { id = "com.vanniktech.maven.publish", version = "0.34.0" }
4545
spotless = { id = "com.diffplug.gradle.spotless", version = "6.25.0" }
46-
dokka = { id = "org.jetbrains.dokka", version = "1.9.20" }
46+
dokka = { id = "org.jetbrains.dokka", version = "1.9.20" }

0 commit comments

Comments
 (0)