Skip to content

Commit 2f6940a

Browse files
release: 3.1.1 (#588)
* chore(internal/ci): setup breaking change detection * Proposal for more intuitive usage of `AzureUrlPathMode` configuration value. (#583) * Added AzureUrlPathMode.AUTO to encapsulate current behaviour * Changed default to AzureUrlPathMode.AUTO to be default and provided details in the documentation * Fixed clientOptions tests * spotlessApply * Adjusted README and documentation for AzureUrlPathMode * SpotlessApply * release: 3.1.1 --------- Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com> Co-authored-by: Jose Alvarez <jpalvarezl@users.noreply.github.com>
1 parent 2ca0aed commit 2f6940a

File tree

12 files changed

+249
-31
lines changed

12 files changed

+249
-31
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: CI
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
- next
7+
8+
jobs:
9+
detect_breaking_changes:
10+
runs-on: 'ubuntu-latest'
11+
name: detect-breaking-changes
12+
if: github.repository == 'openai/openai-java'
13+
steps:
14+
- name: Calculate fetch-depth
15+
run: |
16+
echo "FETCH_DEPTH=$(expr ${{ github.event.pull_request.commits }} + 1)" >> $GITHUB_ENV
17+
18+
- uses: actions/checkout@v4
19+
with:
20+
# Ensure we can check out the pull request base in the script below.
21+
fetch-depth: ${{ env.FETCH_DEPTH }}
22+
23+
- name: Set up Java
24+
uses: actions/setup-java@v4
25+
with:
26+
distribution: temurin
27+
java-version: |
28+
8
29+
21
30+
cache: gradle
31+
- name: Set up Gradle
32+
uses: gradle/gradle-build-action@v2
33+
34+
- name: Detect breaking changes
35+
run: |
36+
# Try to check out previous versions of the breaking change detection script. This ensures that
37+
# we still detect breaking changes when entire files and their tests are removed.
38+
git checkout "${{ github.event.pull_request.base.sha }}" -- ./scripts/detect-breaking-changes 2>/dev/null || true
39+
./scripts/detect-breaking-changes ${{ github.event.pull_request.base.sha }}

.release-please-manifest.json

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

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 111
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-7ef7a457c3bf05364e66e48c9ca34f31bfef1f6c9b7c15b1812346105e0abb16.yml
33
openapi_spec_hash: a2b1f5d8fbb62175c93b0ebea9f10063
4-
config_hash: 76afa3236f36854a8705f1281b1990b8
4+
config_hash: 4870312b04f48fd717ea4151053e7fb9

CHANGELOG.md

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

3+
## 3.1.1 (2025-08-20)
4+
5+
Full Changelog: [v3.1.0...v3.1.1](https://github.com/openai/openai-java/compare/v3.1.0...v3.1.1)
6+
7+
### Chores
8+
9+
* **internal/ci:** setup breaking change detection ([2a18622](https://github.com/openai/openai-java/commit/2a1862218ccafea3a37801367aee303564b48ca3))
10+
311
## 3.1.0 (2025-08-19)
412

513
Full Changelog: [v3.0.3...v3.1.0](https://github.com/openai/openai-java/compare/v3.0.3...v3.1.0)

README.md

Lines changed: 14 additions & 7 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/3.1.0)
6-
[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/3.1.0/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/3.1.0)
5+
[![Maven Central](https://img.shields.io/maven-central/v/com.openai/openai-java)](https://central.sonatype.com/artifact/com.openai/openai-java/3.1.1)
6+
[![javadoc](https://javadoc.io/badge2/com.openai/openai-java/3.1.1/javadoc.svg)](https://javadoc.io/doc/com.openai/openai-java/3.1.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/3.1.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/3.1.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:3.1.0")
27+
implementation("com.openai:openai-java:3.1.1")
2828
```
2929

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

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

13321332
```kotlin
1333-
implementation("com.openai:openai-java-spring-boot-starter:3.1.0")
1333+
implementation("com.openai:openai-java-spring-boot-starter:3.1.1")
13341334
```
13351335

13361336
#### Maven
@@ -1339,7 +1339,7 @@ implementation("com.openai:openai-java-spring-boot-starter:3.1.0")
13391339
<dependency>
13401340
<groupId>com.openai</groupId>
13411341
<artifactId>openai-java-spring-boot-starter</artifactId>
1342-
<version>3.1.0</version>
1342+
<version>3.1.1</version>
13431343
</dependency>
13441344
```
13451345

@@ -1420,6 +1420,13 @@ OpenAIClient client = OpenAIOkHttpClient.builder()
14201420

14211421
See the complete Azure OpenAI example in the [`openai-java-example`](openai-java-example/src/main/java/com/openai/example/AzureEntraIdExample.java) directory. The other examples in the directory also work with Azure as long as the client is configured to use it.
14221422

1423+
### Optional: URL path mode configuration
1424+
1425+
The [`ClientOptions`](openai-java-core/src/main/kotlin/com/openai/core/ClientOptions.kt) can be configured to treat Azure OpenAI endpoint URLs differently, depending on your service setup. The default value is [`AzureUrlPathMode.AUTO`](openai-java-core/src/main/kotlin/com/openai/azure/AzureUrlPathMode.kt). To customize the SDK behavior, each value does the following:
1426+
- `AzureUrlPathMode.LEGACY`: forces the deployment or model name into the path.
1427+
- `AzureUrlPathMode.UNIFIED`: for newer endpoints ending in `/openai/v1` the service behaviour matches OpenAI's, therefore [`AzureOpenAIServiceVersion`](openai-java-core/src/main/kotlin/com/openai/azure/AzureOpenAIServiceVersion.kt) becomes optional and the model is passed in the request object.
1428+
- `AzureUrlPathMode.AUTO`: automatically detects the path mode based on the base URL. Default value.
1429+
14231430
## Network options
14241431

14251432
### Retries

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

1414
subprojects {

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

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,24 @@ internal enum class AzureUrlCategory {
2323
fun categorizeBaseUrl(baseUrl: String, pathMode: AzureUrlPathMode): AzureUrlCategory {
2424
val trimmedBaseUrl = baseUrl.trim().trimEnd('/')
2525
val host = URI.create(trimmedBaseUrl).host
26-
return when {
27-
// Azure OpenAI resource URL with the old schema.
28-
host.endsWith(".openai.azure.com", ignoreCase = true) ||
29-
// Azure OpenAI resource URL with the OpenAI unified schema.
30-
host.endsWith(".services.ai.azure.com", ignoreCase = true) ||
31-
// Azure OpenAI resource URL, but with a schema different to the known ones.
32-
host.endsWith(".azure-api.net", ignoreCase = true) ||
33-
host.endsWith(".cognitiveservices.azure.com", ignoreCase = true) ->
34-
when (pathMode) {
35-
AzureUrlPathMode.LEGACY -> AZURE_LEGACY
36-
AzureUrlPathMode.UNIFIED ->
26+
27+
return when (pathMode) {
28+
AzureUrlPathMode.LEGACY -> AZURE_LEGACY
29+
AzureUrlPathMode.UNIFIED -> AZURE_UNIFIED
30+
AzureUrlPathMode.AUTO ->
31+
when {
32+
host.endsWith(".openai.azure.com", ignoreCase = true) ||
33+
// Azure OpenAI resource URL with the OpenAI unified schema.
34+
host.endsWith(".services.ai.azure.com", ignoreCase = true) ||
35+
// Azure OpenAI resource URL, but with a schema different to the known
36+
// ones.
37+
host.endsWith(".azure-api.net", ignoreCase = true) ||
38+
host.endsWith(".cognitiveservices.azure.com", ignoreCase = true) ->
3739
if (trimmedBaseUrl.endsWith("/openai/v1")) AZURE_UNIFIED
3840
else AZURE_LEGACY
39-
}
4041

41-
else -> NON_AZURE
42+
else -> NON_AZURE
43+
}
4244
}
4345
}
4446
}
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
package com.openai.azure
22

33
/**
4-
* To force the deployment or model named to be part of the URL path for Azure OpenAI requests, use
5-
* [AzureUrlPathMode.LEGACY]. The default is [AzureUrlPathMode.UNIFIED].
4+
* Configures how the baseURL of [com.openai.core.ClientOptions] is treated for Azure OpenAI
5+
* endpoints.
66
*/
77
enum class AzureUrlPathMode {
8+
/** Forces the deployment or model name into the path. */
89
LEGACY,
10+
/** [AzureOpenAIServiceVersion] is optional and the model is part of the request. */
911
UNIFIED,
12+
/** Automatically detects the path mode based on the base URL. This is the default value. */
13+
AUTO,
1014
}

openai-java-core/src/main/kotlin/com/openai/core/ClientOptions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ private constructor(
166166
private var maxRetries: Int = 2
167167
private var credential: Credential? = null
168168
private var azureServiceVersion: AzureOpenAIServiceVersion? = null
169-
private var azureUrlPathMode: AzureUrlPathMode = AzureUrlPathMode.UNIFIED
169+
private var azureUrlPathMode: AzureUrlPathMode = AzureUrlPathMode.AUTO
170170
private var organization: String? = null
171171
private var project: String? = null
172172
private var webhookSecret: String? = null

0 commit comments

Comments
 (0)