Skip to content
Open
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
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,21 @@ implementation("com.openai:openai-java:4.51.0")
The framework-neutral SDK artifacts require Java 8 or later. Runtime floors and lifecycle states
are declared per artifact in the [Java version support policy](docs/version-support-policy.md).

### Java Platform Module System

The published artifacts are not modular JARs, but each one declares a stable `Automatic-Module-Name`
so it can be placed on the module path:

| Artifact | Module name |
| --- | --- |
| `openai-java` | `com.openai` |
| `openai-java-core` | `com.openai.core` |
| `openai-java-client-okhttp` | `com.openai.client.okhttp` |
| `openai-java-bedrock` | `com.openai.bedrock` |

Each package is contained in exactly one artifact, so these modules can be resolved together on the
module path.

## Usage

> [!TIP]
Expand Down Expand Up @@ -93,8 +108,8 @@ implementation("com.openai:openai-java-bedrock:4.51.0")
<!-- x-release-please-end -->

```java
import com.openai.bedrock.BedrockOpenAIOkHttpClient;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.BedrockOpenAIOkHttpClient;

// Uses the standard AWS credential chain, including environment credentials,
// ~/.aws/credentials, AWS_PROFILE, workload roles, and instance metadata.
Expand Down
2 changes: 1 addition & 1 deletion bedrock.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ implementation("com.openai:openai-java-bedrock:4.51.0")
Configure AWS credentials as you normally would, then provide the region:

```java
import com.openai.bedrock.BedrockOpenAIOkHttpClient;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.BedrockOpenAIOkHttpClient;

OpenAIClient client = BedrockOpenAIOkHttpClient.builder()
.awsRegion("us-east-1")
Expand Down
25 changes: 25 additions & 0 deletions buildSrc/src/main/kotlin/openai.publish.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,31 @@ repositories {
mavenCentral()
}

// Stable JPMS module names for the published artifacts, derived from the `com.openai` group ID and
// the packages each artifact ships. Without them, consumers on the module path get a name derived
// from the JAR file name, which is neither namespaced nor stable across renames. Treat these as
// public API: once released, changing a name breaks every consumer that `requires` it.
val automaticModuleNames =
mapOf(
// Aggregator artifact: ships no packages of its own, so it takes the group's root name.
"openai-java" to "com.openai",
// Ships `com.openai.core` along with the rest of the `com.openai` namespace.
"openai-java-core" to "com.openai.core",
"openai-java-client-okhttp" to "com.openai.client.okhttp",
"openai-java-bedrock" to "com.openai.bedrock",
)

val automaticModuleName =
checkNotNull(automaticModuleNames[project.name]) {
"${project.name} is published but has no automatic module name"
}

pluginManager.withPlugin("java") {
tasks.named<Jar>("jar") {
manifest { attributes("Automatic-Module-Name" to automaticModuleName) }
}
}

extra["signingInMemoryKey"] = System.getenv("GPG_SIGNING_KEY")
extra["signingInMemoryKeyId"] = System.getenv("GPG_SIGNING_KEY_ID")
extra["signingInMemoryKeyPassword"] = System.getenv("GPG_SIGNING_PASSWORD")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.openai.client.okhttp
package com.openai.bedrock

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Defer the package move to a major release

When users of the published 4.51.0 Bedrock artifact upgrade to the next 4.x release, moving this public class removes com.openai.client.okhttp.BedrockOpenAIOkHttpClient: existing source imports will no longer compile, and already-compiled applications can fail with NoClassDefFoundError. The version remains on the 4.x line, so this relocation should be deferred to a major release rather than shipped as an otherwise routine upgrade.

Useful? React with 👍 / 👎.


import com.fasterxml.jackson.databind.json.JsonMapper
import com.openai.bedrock.BedrockAuthOptions
import com.openai.bedrock.resolve
import com.openai.client.OpenAIClient
import com.openai.client.okhttp.OpenAIOkHttpClient
import com.openai.core.LogLevel
import com.openai.core.Sleeper
import com.openai.core.Timeout
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.openai.client.okhttp
package com.openai.bedrock

import com.github.tomakehurst.wiremock.client.WireMock.findAll
import com.github.tomakehurst.wiremock.client.WireMock.get
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.openai.example;

import com.openai.bedrock.BedrockOpenAIOkHttpClient;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.BedrockOpenAIOkHttpClient;
import com.openai.models.responses.ResponseCreateParams;

public final class BedrockResponsesExample {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.openai.example;

import com.openai.bedrock.BedrockOpenAIOkHttpClient;
import com.openai.client.OpenAIClientAsync;
import com.openai.client.okhttp.BedrockOpenAIOkHttpClient;
import com.openai.models.responses.ResponseCreateParams;

public final class BedrockResponsesStreamingAsyncExample {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.openai.compatibility;

import com.openai.bedrock.BedrockOpenAIOkHttpClient;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.BedrockOpenAIOkHttpClient;

public final class BedrockRuntimeProbe {
private static final String[] RUNTIME_PROVIDER_CLASSES = {
Expand Down