Skip to content

Commit 1926dcd

Browse files
release: 2.19.1 (#555)
* fix(client): accidental mutability of some classes * chore(internal): remove unnecessary `[...]` in `@see` * docs: more code comments * chore(internal): simplify handling of deployment models (#556) * deployment-models: simplified code handling of deployment models * deployment-models: shorter test function names. * deployment-models: return null if reflection fails. * deployment-models: handle reflection errors more specifically. * release: 2.19.1 --------- Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com> Co-authored-by: D Gardner <[email protected]>
1 parent c0aa6b5 commit 1926dcd

File tree

277 files changed

+2227
-1650
lines changed

Some content is hidden

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

277 files changed

+2227
-1650
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "2.19.0"
2+
".": "2.19.1"
33
}

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
# Changelog
22

3+
## 2.19.1 (2025-07-24)
4+
5+
Full Changelog: [v2.19.0...v2.19.1](https://github.com/openai/openai-java/compare/v2.19.0...v2.19.1)
6+
7+
### Bug Fixes
8+
9+
* **client:** accidental mutability of some classes ([8f377c4](https://github.com/openai/openai-java/commit/8f377c400550b7f99f8b91b59caf92c9274f174f))
10+
11+
12+
### Chores
13+
14+
* **internal:** remove unnecessary `[...]` in `[@see](https://github.com/see)` ([ba7945f](https://github.com/openai/openai-java/commit/ba7945f92514c41c5ebb367272082d6658f06ad4))
15+
* **internal:** simplify handling of deployment models ([#556](https://github.com/openai/openai-java/issues/556)) ([2c7e661](https://github.com/openai/openai-java/commit/2c7e661877d07372ad7e54f788d665a459b18fba))
16+
17+
18+
### Documentation
19+
20+
* more code comments ([2110f40](https://github.com/openai/openai-java/commit/2110f40666a81e08ad2f493773fe1f2ca4a562b2))
21+
322
## 2.19.0 (2025-07-23)
423

524
Full Changelog: [v2.18.2...v2.19.0](https://github.com/openai/openai-java/compare/v2.18.2...v2.19.0)

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
<!-- x-release-please-start-version -->
44

5-
[![Maven Central](https://img.shields.io/maven-central/v/com.openai/openai-java)](https://central.sonatype.com/artifact/com.openai/openai-java/2.19.0)
6-
[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/2.19.0/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/2.19.0)
5+
[![Maven Central](https://img.shields.io/maven-central/v/com.openai/openai-java)](https://central.sonatype.com/artifact/com.openai/openai-java/2.19.1)
6+
[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/2.19.1/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/2.19.1)
77

88
<!-- x-release-please-end -->
99

1010
The OpenAI Java SDK provides convenient access to the [OpenAI REST API](https://platform.openai.com/docs) from applications written in Java.
1111

1212
<!-- x-release-please-start-version -->
1313

14-
The REST API documentation can be found on [platform.openai.com](https://platform.openai.com/docs). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.openai/openai-java/2.19.0).
14+
The REST API documentation can be found on [platform.openai.com](https://platform.openai.com/docs). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.openai/openai-java/2.19.1).
1515

1616
<!-- x-release-please-end -->
1717

@@ -24,7 +24,7 @@ The REST API documentation can be found on [platform.openai.com](https://platfor
2424
### Gradle
2525

2626
```kotlin
27-
implementation("com.openai:openai-java:2.19.0")
27+
implementation("com.openai:openai-java:2.19.1")
2828
```
2929

3030
### Maven
@@ -33,7 +33,7 @@ implementation("com.openai:openai-java:2.19.0")
3333
<dependency>
3434
<groupId>com.openai</groupId>
3535
<artifactId>openai-java</artifactId>
36-
<version>2.19.0</version>
36+
<version>2.19.1</version>
3737
</dependency>
3838
```
3939

@@ -1321,7 +1321,7 @@ If you're using Spring Boot, then you can use the SDK's [Spring Boot starter](ht
13211321
#### Gradle
13221322

13231323
```kotlin
1324-
implementation("com.openai:openai-java-spring-boot-starter:2.19.0")
1324+
implementation("com.openai:openai-java-spring-boot-starter:2.19.1")
13251325
```
13261326

13271327
#### Maven
@@ -1330,7 +1330,7 @@ implementation("com.openai:openai-java-spring-boot-starter:2.19.0")
13301330
<dependency>
13311331
<groupId>com.openai</groupId>
13321332
<artifactId>openai-java-spring-boot-starter</artifactId>
1333-
<version>2.19.0</version>
1333+
<version>2.19.1</version>
13341334
</dependency>
13351335
```
13361336

@@ -1415,7 +1415,7 @@ See the complete Azure OpenAI example in the [`openai-java-example`](openai-java
14151415

14161416
### Retries
14171417

1418-
The SDK automatically retries 2 times by default, with a short exponential backoff.
1418+
The SDK automatically retries 2 times by default, with a short exponential backoff between requests.
14191419

14201420
Only the following error types are retried:
14211421

@@ -1425,7 +1425,7 @@ Only the following error types are retried:
14251425
- 429 Rate Limit
14261426
- 5xx Internal
14271427

1428-
The API may also explicitly instruct the SDK to retry or not retry a response.
1428+
The API may also explicitly instruct the SDK to retry or not retry a request.
14291429

14301430
To set a custom number of retries, configure the client using the `maxRetries` method:
14311431

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ repositories {
88

99
allprojects {
1010
group = "com.openai"
11-
version = "2.19.0" // x-release-please-version
11+
version = "2.19.1" // x-release-please-version
1212
}
1313

1414
subprojects {

openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClient.kt

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import com.openai.client.OpenAIClient
88
import com.openai.client.OpenAIClientImpl
99
import com.openai.core.ClientOptions
1010
import com.openai.core.Timeout
11+
import com.openai.core.http.AsyncStreamResponse
1112
import com.openai.core.http.Headers
13+
import com.openai.core.http.HttpClient
1214
import com.openai.core.http.QueryParams
1315
import com.openai.core.jsonMapper
1416
import com.openai.credential.Credential
@@ -22,13 +24,22 @@ import javax.net.ssl.SSLSocketFactory
2224
import javax.net.ssl.X509TrustManager
2325
import kotlin.jvm.optionals.getOrNull
2426

27+
/**
28+
* A class that allows building an instance of [OpenAIClient] with [OkHttpClient] as the underlying
29+
* [HttpClient].
30+
*/
2531
class OpenAIOkHttpClient private constructor() {
2632

2733
companion object {
2834

29-
/** Returns a mutable builder for constructing an instance of [OpenAIOkHttpClient]. */
35+
/** Returns a mutable builder for constructing an instance of [OpenAIClient]. */
3036
@JvmStatic fun builder() = Builder()
3137

38+
/**
39+
* Returns a client configured using system properties and environment variables.
40+
*
41+
* @see ClientOptions.Builder.fromEnv
42+
*/
3243
@JvmStatic fun fromEnv(): OpenAIClient = builder().fromEnv().build()
3344
}
3445

@@ -105,23 +116,58 @@ class OpenAIOkHttpClient private constructor() {
105116
clientOptions.checkJacksonVersionCompatibility(checkJacksonVersionCompatibility)
106117
}
107118

119+
/**
120+
* The Jackson JSON mapper to use for serializing and deserializing JSON.
121+
*
122+
* Defaults to [com.openai.core.jsonMapper]. The default is usually sufficient and rarely
123+
* needs to be overridden.
124+
*/
108125
fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) }
109126

127+
/**
128+
* The executor to use for running [AsyncStreamResponse.Handler] callbacks.
129+
*
130+
* Defaults to a dedicated cached thread pool.
131+
*/
110132
fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply {
111133
clientOptions.streamHandlerExecutor(streamHandlerExecutor)
112134
}
113135

136+
/**
137+
* The clock to use for operations that require timing, like retries.
138+
*
139+
* This is primarily useful for using a fake clock in tests.
140+
*
141+
* Defaults to [Clock.systemUTC].
142+
*/
114143
fun clock(clock: Clock) = apply { clientOptions.clock(clock) }
115144

145+
/**
146+
* The base URL to use for every request.
147+
*
148+
* Defaults to the production environment: `https://api.openai.com/v1`.
149+
*/
116150
fun baseUrl(baseUrl: String?) = apply { clientOptions.baseUrl(baseUrl) }
117151

118152
/** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */
119153
fun baseUrl(baseUrl: Optional<String>) = baseUrl(baseUrl.getOrNull())
120154

155+
/**
156+
* Whether to call `validate` on every response before returning it.
157+
*
158+
* Defaults to false, which means the shape of the response will not be validated upfront.
159+
* Instead, validation will only occur for the parts of the response that are accessed.
160+
*/
121161
fun responseValidation(responseValidation: Boolean) = apply {
122162
clientOptions.responseValidation(responseValidation)
123163
}
124164

165+
/**
166+
* Sets the maximum time allowed for various parts of an HTTP call's lifecycle, excluding
167+
* retries.
168+
*
169+
* Defaults to [Timeout.default].
170+
*/
125171
fun timeout(timeout: Timeout) = apply { clientOptions.timeout(timeout) }
126172

127173
/**
@@ -133,6 +179,21 @@ class OpenAIOkHttpClient private constructor() {
133179
*/
134180
fun timeout(timeout: Duration) = apply { clientOptions.timeout(timeout) }
135181

182+
/**
183+
* The maximum number of times to retry failed requests, with a short exponential backoff
184+
* between requests.
185+
*
186+
* Only the following error types are retried:
187+
* - Connection errors (for example, due to a network connectivity problem)
188+
* - 408 Request Timeout
189+
* - 409 Conflict
190+
* - 429 Rate Limit
191+
* - 5xx Internal
192+
*
193+
* The API may also explicitly instruct the SDK to retry or not retry a request.
194+
*
195+
* Defaults to 2.
196+
*/
136197
fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) }
137198

138199
fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) }
@@ -241,6 +302,11 @@ class OpenAIOkHttpClient private constructor() {
241302
clientOptions.removeAllQueryParams(keys)
242303
}
243304

305+
/**
306+
* Updates configuration using system properties and environment variables.
307+
*
308+
* @see ClientOptions.Builder.fromEnv
309+
*/
244310
fun fromEnv() = apply { clientOptions.fromEnv() }
245311

246312
/**

openai-java-client-okhttp/src/main/kotlin/com/openai/client/okhttp/OpenAIOkHttpClientAsync.kt

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import com.openai.client.OpenAIClientAsync
88
import com.openai.client.OpenAIClientAsyncImpl
99
import com.openai.core.ClientOptions
1010
import com.openai.core.Timeout
11+
import com.openai.core.http.AsyncStreamResponse
1112
import com.openai.core.http.Headers
13+
import com.openai.core.http.HttpClient
1214
import com.openai.core.http.QueryParams
1315
import com.openai.core.jsonMapper
1416
import com.openai.credential.Credential
@@ -22,13 +24,22 @@ import javax.net.ssl.SSLSocketFactory
2224
import javax.net.ssl.X509TrustManager
2325
import kotlin.jvm.optionals.getOrNull
2426

27+
/**
28+
* A class that allows building an instance of [OpenAIClientAsync] with [OkHttpClient] as the
29+
* underlying [HttpClient].
30+
*/
2531
class OpenAIOkHttpClientAsync private constructor() {
2632

2733
companion object {
2834

29-
/** Returns a mutable builder for constructing an instance of [OpenAIOkHttpClientAsync]. */
35+
/** Returns a mutable builder for constructing an instance of [OpenAIClientAsync]. */
3036
@JvmStatic fun builder() = Builder()
3137

38+
/**
39+
* Returns a client configured using system properties and environment variables.
40+
*
41+
* @see ClientOptions.Builder.fromEnv
42+
*/
3243
@JvmStatic fun fromEnv(): OpenAIClientAsync = builder().fromEnv().build()
3344
}
3445

@@ -105,23 +116,58 @@ class OpenAIOkHttpClientAsync private constructor() {
105116
clientOptions.checkJacksonVersionCompatibility(checkJacksonVersionCompatibility)
106117
}
107118

119+
/**
120+
* The Jackson JSON mapper to use for serializing and deserializing JSON.
121+
*
122+
* Defaults to [com.openai.core.jsonMapper]. The default is usually sufficient and rarely
123+
* needs to be overridden.
124+
*/
108125
fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) }
109126

127+
/**
128+
* The executor to use for running [AsyncStreamResponse.Handler] callbacks.
129+
*
130+
* Defaults to a dedicated cached thread pool.
131+
*/
110132
fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply {
111133
clientOptions.streamHandlerExecutor(streamHandlerExecutor)
112134
}
113135

136+
/**
137+
* The clock to use for operations that require timing, like retries.
138+
*
139+
* This is primarily useful for using a fake clock in tests.
140+
*
141+
* Defaults to [Clock.systemUTC].
142+
*/
114143
fun clock(clock: Clock) = apply { clientOptions.clock(clock) }
115144

145+
/**
146+
* The base URL to use for every request.
147+
*
148+
* Defaults to the production environment: `https://api.openai.com/v1`.
149+
*/
116150
fun baseUrl(baseUrl: String?) = apply { clientOptions.baseUrl(baseUrl) }
117151

118152
/** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */
119153
fun baseUrl(baseUrl: Optional<String>) = baseUrl(baseUrl.getOrNull())
120154

155+
/**
156+
* Whether to call `validate` on every response before returning it.
157+
*
158+
* Defaults to false, which means the shape of the response will not be validated upfront.
159+
* Instead, validation will only occur for the parts of the response that are accessed.
160+
*/
121161
fun responseValidation(responseValidation: Boolean) = apply {
122162
clientOptions.responseValidation(responseValidation)
123163
}
124164

165+
/**
166+
* Sets the maximum time allowed for various parts of an HTTP call's lifecycle, excluding
167+
* retries.
168+
*
169+
* Defaults to [Timeout.default].
170+
*/
125171
fun timeout(timeout: Timeout) = apply { clientOptions.timeout(timeout) }
126172

127173
/**
@@ -133,6 +179,21 @@ class OpenAIOkHttpClientAsync private constructor() {
133179
*/
134180
fun timeout(timeout: Duration) = apply { clientOptions.timeout(timeout) }
135181

182+
/**
183+
* The maximum number of times to retry failed requests, with a short exponential backoff
184+
* between requests.
185+
*
186+
* Only the following error types are retried:
187+
* - Connection errors (for example, due to a network connectivity problem)
188+
* - 408 Request Timeout
189+
* - 409 Conflict
190+
* - 429 Rate Limit
191+
* - 5xx Internal
192+
*
193+
* The API may also explicitly instruct the SDK to retry or not retry a request.
194+
*
195+
* Defaults to 2.
196+
*/
136197
fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) }
137198

138199
fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) }
@@ -241,6 +302,11 @@ class OpenAIOkHttpClientAsync private constructor() {
241302
clientOptions.removeAllQueryParams(keys)
242303
}
243304

305+
/**
306+
* Updates configuration using system properties and environment variables.
307+
*
308+
* @see ClientOptions.Builder.fromEnv
309+
*/
244310
fun fromEnv() = apply { clientOptions.fromEnv() }
245311

246312
/**

0 commit comments

Comments
 (0)