Skip to content

Commit 6458f96

Browse files
Merge pull request #507 from openai/release-please--branches--main--changes--next
release: 2.8.0
2 parents c5268a1 + e6b4713 commit 6458f96

File tree

206 files changed

+4996
-654
lines changed

Some content is hidden

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

206 files changed

+4996
-654
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
- 'integrated/**'
88
- 'stl-preview-head/**'
99
- 'stl-preview-base/**'
10+
pull_request:
11+
branches-ignore:
12+
- 'stl-preview-head/**'
13+
- 'stl-preview-base/**'
1014

1115
jobs:
1216
lint:

.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.7.0"
2+
".": "2.8.0"
33
}

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 86
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-3ae9c18dd7ccfc3ac5206f24394665f563a19015cfa8847b2801a2694d012abc.yml
3-
openapi_spec_hash: 48175b03b58805cd5c80793c66fd54e5
4-
config_hash: 4caff63b74a41f71006987db702f2918
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-9e41d2d5471d2c28bff0d616f4476f5b0e6c541ef4cb51bdaaef5fdf5e13c8b2.yml
3+
openapi_spec_hash: 86f765e18d00e32cf2ce9db7ab84d946
4+
config_hash: dc5515e257676a27cb1ace1784aa92b3

CHANGELOG.md

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

3+
## 2.8.0 (2025-06-17)
4+
5+
Full Changelog: [v2.7.0...v2.8.0](https://github.com/openai/openai-java/compare/v2.7.0...v2.8.0)
6+
7+
### Features
8+
9+
* **api:** add reusable prompt IDs ([0767a2b](https://github.com/openai/openai-java/commit/0767a2b50d853feff84748fed3eb6cf544bec6fb))
10+
* **api:** manual updates ([ec235f7](https://github.com/openai/openai-java/commit/ec235f7f311ca1866ae8a05e9a622ab588062071))
11+
* **client:** implement per-endpoint base URL support ([c87f1af](https://github.com/openai/openai-java/commit/c87f1af80b1f3d898a5a1553be48ee87ea4e7b4f))
12+
13+
14+
### Bug Fixes
15+
16+
* **client:** update StructuredResponse with Prompt details ([a47219b](https://github.com/openai/openai-java/commit/a47219b0247dcb4d25b3bf0f33ba6b392c61cd38))
17+
* **internal:** run formatter ([5757aa6](https://github.com/openai/openai-java/commit/5757aa6af407d749a7bba6e1f0714eec850d4369))
18+
* **tests:** fix required prop in test ([e820c6f](https://github.com/openai/openai-java/commit/e820c6f115ff392b567abb355f11ce5acfcab537))
19+
20+
21+
### Chores
22+
23+
* **ci:** enable for pull requests ([9c90b16](https://github.com/openai/openai-java/commit/9c90b16585ebe3ffc031e0df598a27b5b6a85bb8))
24+
* **internal:** codegen related update ([3597aee](https://github.com/openai/openai-java/commit/3597aee95ae1956afbe8bd62b5a6946dd62256b3))
25+
* run formatter ([426527b](https://github.com/openai/openai-java/commit/426527b76371e7e0a66e368b0ddbb8da806fae2b))
26+
* run formatter ([426527b](https://github.com/openai/openai-java/commit/426527b76371e7e0a66e368b0ddbb8da806fae2b))
27+
* run formatter ([899f79c](https://github.com/openai/openai-java/commit/899f79c88b9a79ada33982af0d2ee64f96445230))
28+
329
## 2.7.0 (2025-06-10)
430

531
Full Changelog: [v2.6.0...v2.7.0](https://github.com/openai/openai-java/compare/v2.6.0...v2.7.0)

README.md

Lines changed: 20 additions & 5 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.7.0)
6-
[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/2.7.0/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/2.7.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.8.0)
6+
[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/2.8.0/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/2.8.0)
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.7.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.8.0).
1515

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

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

2424
```kotlin
25-
implementation("com.openai:openai-java:2.7.0")
25+
implementation("com.openai:openai-java:2.8.0")
2626
```
2727

2828
### Maven
@@ -31,7 +31,7 @@ implementation("com.openai:openai-java:2.7.0")
3131
<dependency>
3232
<groupId>com.openai</groupId>
3333
<artifactId>openai-java</artifactId>
34-
<version>2.7.0</version>
34+
<version>2.8.0</version>
3535
</dependency>
3636
```
3737

@@ -132,6 +132,21 @@ See this table for the available options:
132132
> Don't create more than one client in the same application. Each client has a connection pool and
133133
> thread pools, which are more efficient to share between requests.
134134
135+
### Modifying configuration
136+
137+
To temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:
138+
139+
```java
140+
import com.openai.client.OpenAIClient;
141+
142+
OpenAIClient clientWithOptions = client.withOptions(optionsBuilder -> {
143+
optionsBuilder.baseUrl("https://example.com");
144+
optionsBuilder.maxRetries(42);
145+
});
146+
```
147+
148+
The `withOptions()` method does not affect the original client or service.
149+
135150
## Requests and responses
136151

137152
To send a request to the OpenAI API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.

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.7.0" // x-release-please-version
11+
version = "2.8.0" // x-release-please-version
1212
}
1313

1414
subprojects {

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

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package com.openai.client.okhttp
22

33
import com.openai.core.RequestOptions
44
import com.openai.core.Timeout
5-
import com.openai.core.checkRequired
65
import com.openai.core.http.Headers
76
import com.openai.core.http.HttpClient
87
import com.openai.core.http.HttpMethod
@@ -17,7 +16,6 @@ import java.time.Duration
1716
import java.util.concurrent.CompletableFuture
1817
import okhttp3.Call
1918
import okhttp3.Callback
20-
import okhttp3.HttpUrl
2119
import okhttp3.HttpUrl.Companion.toHttpUrl
2220
import okhttp3.MediaType
2321
import okhttp3.MediaType.Companion.toMediaType
@@ -28,8 +26,7 @@ import okhttp3.Response
2826
import okhttp3.logging.HttpLoggingInterceptor
2927
import okio.BufferedSink
3028

31-
class OkHttpClient
32-
private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val baseUrl: HttpUrl) :
29+
class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpClient) :
3330
HttpClient {
3431

3532
override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse {
@@ -140,11 +137,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
140137
}
141138

142139
private fun HttpRequest.toUrl(): String {
143-
url?.let {
144-
return it
145-
}
146-
147-
val builder = baseUrl.newBuilder()
140+
val builder = baseUrl.toHttpUrl().newBuilder()
148141
pathSegments.forEach(builder::addPathSegment)
149142
queryParams.keys().forEach { key ->
150143
queryParams.values(key).forEach { builder.addQueryParameter(key, it) }
@@ -194,12 +187,9 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
194187

195188
class Builder internal constructor() {
196189

197-
private var baseUrl: HttpUrl? = null
198190
private var timeout: Timeout = Timeout.default()
199191
private var proxy: Proxy? = null
200192

201-
fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl.toHttpUrl() }
202-
203193
fun timeout(timeout: Timeout) = apply { this.timeout = timeout }
204194

205195
fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build())
@@ -214,8 +204,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
214204
.writeTimeout(timeout.write())
215205
.callTimeout(timeout.request())
216206
.proxy(proxy)
217-
.build(),
218-
checkRequired("baseUrl", baseUrl),
207+
.build()
219208
)
220209
}
221210
}

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,7 @@ class OpenAIOkHttpClient private constructor() {
186186
fun build(): OpenAIClient =
187187
OpenAIClientImpl(
188188
clientOptions
189-
.httpClient(
190-
OkHttpClient.builder()
191-
.baseUrl(clientOptions.baseUrl())
192-
.timeout(timeout)
193-
.proxy(proxy)
194-
.build()
195-
)
189+
.httpClient(OkHttpClient.builder().timeout(timeout).proxy(proxy).build())
196190
.build()
197191
)
198192
}

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,7 @@ class OpenAIOkHttpClientAsync private constructor() {
186186
fun build(): OpenAIClientAsync =
187187
OpenAIClientAsyncImpl(
188188
clientOptions
189-
.httpClient(
190-
OkHttpClient.builder()
191-
.baseUrl(clientOptions.baseUrl())
192-
.timeout(timeout)
193-
.proxy(proxy)
194-
.build()
195-
)
189+
.httpClient(OkHttpClient.builder().timeout(timeout).proxy(proxy).build())
196190
.build()
197191
)
198192
}

openai-java-core/src/main/kotlin/com/openai/azure/HttpRequestBuilderExtensions.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ internal fun HttpRequest.Builder.addPathSegmentsForAzure(
1010
clientOptions: ClientOptions,
1111
deploymentModel: String?,
1212
): HttpRequest.Builder = apply {
13-
if (isAzureEndpoint(clientOptions.baseUrl)) {
13+
if (isAzureEndpoint(clientOptions.baseUrl())) {
1414
addPathSegment("openai")
1515
deploymentModel?.let { addPathSegments("deployments", it) }
1616
}
@@ -21,7 +21,8 @@ internal fun HttpRequest.Builder.replaceBearerTokenForAzure(
2121
clientOptions: ClientOptions
2222
): HttpRequest.Builder = apply {
2323
if (
24-
isAzureEndpoint(clientOptions.baseUrl) && clientOptions.credential is BearerTokenCredential
24+
isAzureEndpoint(clientOptions.baseUrl()) &&
25+
clientOptions.credential is BearerTokenCredential
2526
) {
2627
replaceHeaders("Authorization", "Bearer ${clientOptions.credential.token()}")
2728
}

0 commit comments

Comments
 (0)