Skip to content
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
108 changes: 108 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Migration Guide: `oci-genai-openai` to `oci-genai-auth-java`

This guide helps existing `oci-genai-openai` users migrate to `oci-genai-auth-java`.

## Summary

- Replace dependency `oci-genai-openai` with `oci-genai-auth-java-core`.
- Continue using the `openai-java` SDK client.
- Use `OciOkHttpClientFactory` to build a signed OkHttpClient.
- Choose endpoint/config based on API mode:
- AgentHub: `https://inference.generativeai.<region>.oci.oraclecloud.com/openai/v1` + `openai-project` header
- Partner : `https://inference.generativeai.<region>.oci.oraclecloud.com/20231130/actions/v1` + `compartmentId`

## 1) Dependency Changes

Replace the old dependency with the new one in your `pom.xml`:

```xml
<!-- Remove old dependency -->
<!-- <artifactId>oci-genai-openai</artifactId> -->

<!-- Add new dependency -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.oracle.genai</groupId>
<artifactId>oci-genai-auth-java-bom</artifactId>
<version>1.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>com.oracle.genai</groupId>
<artifactId>oci-genai-auth-java-core</artifactId>
</dependency>
</dependencies>
```

## 2) Import Changes

```java
// Old
import com.oracle.genai.openai.OciOpenAI;

// New
import com.oracle.genai.auth.OciAuthConfig;
import com.oracle.genai.auth.OciOkHttpClientFactory;
```

## 3) Client Initialization Changes

### AgentHub

Use the OpenAI-compatible endpoint and provide project OCID:

```java
import com.oracle.genai.auth.OciAuthConfig;
import com.oracle.genai.auth.OciOkHttpClientFactory;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;

OciAuthConfig config = OciAuthConfig.builder()
.authType("security_token")
.profile("DEFAULT")
.build();

OkHttpClient ociHttpClient = OciOkHttpClientFactory.build(config);

OpenAIClient client = OpenAIOkHttpClient.builder()
.baseUrl("https://inference.generativeai.<region>.oci.oraclecloud.com/openai/v1")
.okHttpClient(ociHttpClient)
.apiKey("not-used")
.addHeader("openai-project", "<ocid1.generativeaiproject...>")
.build();
```

### Partner APIs

Use `/20231130/actions/v1` and include compartment ID:

```java
OciAuthConfig config = OciAuthConfig.builder()
.authType("security_token")
.profile("DEFAULT")
.compartmentId("<ocid1.compartment...>")
.build();

OkHttpClient ociHttpClient = OciOkHttpClientFactory.build(config);

OpenAIClient client = OpenAIOkHttpClient.builder()
.baseUrl("https://inference.generativeai.<region>.oci.oraclecloud.com/20231130/actions/v1")
.okHttpClient(ociHttpClient)
.apiKey("not-used")
.build();
```

## 4) Endpoint and required parameters

- AgentHub:
- `baseUrl`: `https://inference.generativeai.<region>.oci.oraclecloud.com/openai/v1`
- required: `openai-project` header with project OCID
- Partner:
- `baseUrl`: `https://inference.generativeai.<region>.oci.oraclecloud.com/20231130/actions/v1`
- required: `compartmentId` in `OciAuthConfig`
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Requires **Java 17+** and **Maven 3.8+**.
<dependency>
<groupId>com.oracle.genai</groupId>
<artifactId>oci-genai-auth-java-bom</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>1.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -131,6 +131,7 @@ OciAuthConfig config = OciAuthConfig.builder()
.build();

OkHttpClient ociHttpClient = OciOkHttpClientFactory.build(config);

OpenAIClient client = OpenAIOkHttpClient.builder()
.baseUrl("https://inference.generativeai.us-chicago-1.oci.oraclecloud.com/20231130/actions/v1")
.okHttpClient(ociHttpClient)
Expand Down
4 changes: 2 additions & 2 deletions oci-genai-auth-java-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>com.oracle.genai</groupId>
<artifactId>oci-genai-auth-java-bom</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>1.0.0</version>
<packaging>pom</packaging>

<name>OCI GenAI Auth :: BOM</name>
Expand All @@ -23,7 +23,7 @@
</description>

<properties>
<oci-genai-auth.version>0.1.0-SNAPSHOT</oci-genai-auth.version>
<oci-genai-auth.version>1.0.0</oci-genai-auth.version>

<!-- OCI SDK -->
<oci-sdk.version>3.72.1</oci-sdk.version>
Expand Down
2 changes: 1 addition & 1 deletion oci-genai-auth-java-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<parent>
<groupId>com.oracle.genai</groupId>
<artifactId>oci-genai-auth-java-parent</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>1.0.0</version>
</parent>

<artifactId>oci-genai-auth-java-core</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>com.oracle.genai</groupId>
<artifactId>oci-genai-auth-java-parent</artifactId>
<version>0.1.0-SNAPSHOT</version>
<version>1.0.0</version>
<packaging>pom</packaging>

<name>OCI GenAI Auth :: Parent</name>
Expand All @@ -39,7 +39,7 @@
<maven.compiler.target>17</maven.compiler.target>

<!-- First-party versions -->
<oci-genai-auth.version>0.1.0-SNAPSHOT</oci-genai-auth.version>
<oci-genai-auth.version>1.0.0</oci-genai-auth.version>

<!-- OCI SDK -->
<oci-sdk.version>3.72.1</oci-sdk.version>
Expand Down
Loading