Skip to content

release: 2.19.1 #555

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "2.19.0"
".": "2.19.1"
}
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Changelog

## 2.19.1 (2025-07-24)

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

### Bug Fixes

* **client:** accidental mutability of some classes ([8f377c4](https://github.com/openai/openai-java/commit/8f377c400550b7f99f8b91b59caf92c9274f174f))


### Chores

* **internal:** remove unnecessary `[...]` in `[@see](https://github.com/see)` ([ba7945f](https://github.com/openai/openai-java/commit/ba7945f92514c41c5ebb367272082d6658f06ad4))
* **internal:** simplify handling of deployment models ([#556](https://github.com/openai/openai-java/issues/556)) ([2c7e661](https://github.com/openai/openai-java/commit/2c7e661877d07372ad7e54f788d665a459b18fba))


### Documentation

* more code comments ([2110f40](https://github.com/openai/openai-java/commit/2110f40666a81e08ad2f493773fe1f2ca4a562b2))

## 2.19.0 (2025-07-23)

Full Changelog: [v2.18.2...v2.19.0](https://github.com/openai/openai-java/compare/v2.18.2...v2.19.0)
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

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

[![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)
[![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)
[![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)
[![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)

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

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

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

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).
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).

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

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

```kotlin
implementation("com.openai:openai-java:2.19.0")
implementation("com.openai:openai-java:2.19.1")
```

### Maven
Expand All @@ -33,7 +33,7 @@ implementation("com.openai:openai-java:2.19.0")
<dependency>
<groupId>com.openai</groupId>
<artifactId>openai-java</artifactId>
<version>2.19.0</version>
<version>2.19.1</version>
</dependency>
```

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

```kotlin
implementation("com.openai:openai-java-spring-boot-starter:2.19.0")
implementation("com.openai:openai-java-spring-boot-starter:2.19.1")
```

#### Maven
Expand All @@ -1330,7 +1330,7 @@ implementation("com.openai:openai-java-spring-boot-starter:2.19.0")
<dependency>
<groupId>com.openai</groupId>
<artifactId>openai-java-spring-boot-starter</artifactId>
<version>2.19.0</version>
<version>2.19.1</version>
</dependency>
```

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

### Retries

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

Only the following error types are retried:

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

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

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

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repositories {

allprojects {
group = "com.openai"
version = "2.19.0" // x-release-please-version
version = "2.19.1" // x-release-please-version
}

subprojects {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import com.openai.client.OpenAIClient
import com.openai.client.OpenAIClientImpl
import com.openai.core.ClientOptions
import com.openai.core.Timeout
import com.openai.core.http.AsyncStreamResponse
import com.openai.core.http.Headers
import com.openai.core.http.HttpClient
import com.openai.core.http.QueryParams
import com.openai.core.jsonMapper
import com.openai.credential.Credential
Expand All @@ -22,13 +24,22 @@ import javax.net.ssl.SSLSocketFactory
import javax.net.ssl.X509TrustManager
import kotlin.jvm.optionals.getOrNull

/**
* A class that allows building an instance of [OpenAIClient] with [OkHttpClient] as the underlying
* [HttpClient].
*/
class OpenAIOkHttpClient private constructor() {

companion object {

/** Returns a mutable builder for constructing an instance of [OpenAIOkHttpClient]. */
/** Returns a mutable builder for constructing an instance of [OpenAIClient]. */
@JvmStatic fun builder() = Builder()

/**
* Returns a client configured using system properties and environment variables.
*
* @see ClientOptions.Builder.fromEnv
*/
@JvmStatic fun fromEnv(): OpenAIClient = builder().fromEnv().build()
}

Expand Down Expand Up @@ -105,23 +116,58 @@ class OpenAIOkHttpClient private constructor() {
clientOptions.checkJacksonVersionCompatibility(checkJacksonVersionCompatibility)
}

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

/**
* The executor to use for running [AsyncStreamResponse.Handler] callbacks.
*
* Defaults to a dedicated cached thread pool.
*/
fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply {
clientOptions.streamHandlerExecutor(streamHandlerExecutor)
}

/**
* The clock to use for operations that require timing, like retries.
*
* This is primarily useful for using a fake clock in tests.
*
* Defaults to [Clock.systemUTC].
*/
fun clock(clock: Clock) = apply { clientOptions.clock(clock) }

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

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

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

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

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

/**
* The maximum number of times to retry failed requests, with a short exponential backoff
* between requests.
*
* Only the following error types are retried:
* - Connection errors (for example, due to a network connectivity problem)
* - 408 Request Timeout
* - 409 Conflict
* - 429 Rate Limit
* - 5xx Internal
*
* The API may also explicitly instruct the SDK to retry or not retry a request.
*
* Defaults to 2.
*/
fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) }

fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) }
Expand Down Expand Up @@ -241,6 +302,11 @@ class OpenAIOkHttpClient private constructor() {
clientOptions.removeAllQueryParams(keys)
}

/**
* Updates configuration using system properties and environment variables.
*
* @see ClientOptions.Builder.fromEnv
*/
fun fromEnv() = apply { clientOptions.fromEnv() }

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import com.openai.client.OpenAIClientAsync
import com.openai.client.OpenAIClientAsyncImpl
import com.openai.core.ClientOptions
import com.openai.core.Timeout
import com.openai.core.http.AsyncStreamResponse
import com.openai.core.http.Headers
import com.openai.core.http.HttpClient
import com.openai.core.http.QueryParams
import com.openai.core.jsonMapper
import com.openai.credential.Credential
Expand All @@ -22,13 +24,22 @@ import javax.net.ssl.SSLSocketFactory
import javax.net.ssl.X509TrustManager
import kotlin.jvm.optionals.getOrNull

/**
* A class that allows building an instance of [OpenAIClientAsync] with [OkHttpClient] as the
* underlying [HttpClient].
*/
class OpenAIOkHttpClientAsync private constructor() {

companion object {

/** Returns a mutable builder for constructing an instance of [OpenAIOkHttpClientAsync]. */
/** Returns a mutable builder for constructing an instance of [OpenAIClientAsync]. */
@JvmStatic fun builder() = Builder()

/**
* Returns a client configured using system properties and environment variables.
*
* @see ClientOptions.Builder.fromEnv
*/
@JvmStatic fun fromEnv(): OpenAIClientAsync = builder().fromEnv().build()
}

Expand Down Expand Up @@ -105,23 +116,58 @@ class OpenAIOkHttpClientAsync private constructor() {
clientOptions.checkJacksonVersionCompatibility(checkJacksonVersionCompatibility)
}

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

/**
* The executor to use for running [AsyncStreamResponse.Handler] callbacks.
*
* Defaults to a dedicated cached thread pool.
*/
fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply {
clientOptions.streamHandlerExecutor(streamHandlerExecutor)
}

/**
* The clock to use for operations that require timing, like retries.
*
* This is primarily useful for using a fake clock in tests.
*
* Defaults to [Clock.systemUTC].
*/
fun clock(clock: Clock) = apply { clientOptions.clock(clock) }

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

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

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

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

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

/**
* The maximum number of times to retry failed requests, with a short exponential backoff
* between requests.
*
* Only the following error types are retried:
* - Connection errors (for example, due to a network connectivity problem)
* - 408 Request Timeout
* - 409 Conflict
* - 429 Rate Limit
* - 5xx Internal
*
* The API may also explicitly instruct the SDK to retry or not retry a request.
*
* Defaults to 2.
*/
fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) }

fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) }
Expand Down Expand Up @@ -241,6 +302,11 @@ class OpenAIOkHttpClientAsync private constructor() {
clientOptions.removeAllQueryParams(keys)
}

/**
* Updates configuration using system properties and environment variables.
*
* @see ClientOptions.Builder.fromEnv
*/
fun fromEnv() = apply { clientOptions.fromEnv() }

/**
Expand Down
Loading