diff --git a/MIGRATION.md b/MIGRATION.md new file mode 100644 index 0000000..7ff4857 --- /dev/null +++ b/MIGRATION.md @@ -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..oci.oraclecloud.com/openai/v1` + `openai-project` header + - Partner : `https://inference.generativeai..oci.oraclecloud.com/20231130/actions/v1` + `compartmentId` + +## 1) Dependency Changes + +Replace the old dependency with the new one in your `pom.xml`: + +```xml + + + + + + + + com.oracle.genai + oci-genai-auth-java-bom + 1.0.0 + pom + import + + + + + + + com.oracle.genai + oci-genai-auth-java-core + + +``` + +## 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..oci.oraclecloud.com/openai/v1") + .okHttpClient(ociHttpClient) + .apiKey("not-used") + .addHeader("openai-project", "") + .build(); +``` + +### Partner APIs + +Use `/20231130/actions/v1` and include compartment ID: + +```java +OciAuthConfig config = OciAuthConfig.builder() + .authType("security_token") + .profile("DEFAULT") + .compartmentId("") + .build(); + +OkHttpClient ociHttpClient = OciOkHttpClientFactory.build(config); + +OpenAIClient client = OpenAIOkHttpClient.builder() + .baseUrl("https://inference.generativeai..oci.oraclecloud.com/20231130/actions/v1") + .okHttpClient(ociHttpClient) + .apiKey("not-used") + .build(); +``` + +## 4) Endpoint and required parameters + +- AgentHub: + - `baseUrl`: `https://inference.generativeai..oci.oraclecloud.com/openai/v1` + - required: `openai-project` header with project OCID +- Partner: + - `baseUrl`: `https://inference.generativeai..oci.oraclecloud.com/20231130/actions/v1` + - required: `compartmentId` in `OciAuthConfig` diff --git a/README.md b/README.md index a149837..efa59fa 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Requires **Java 17+** and **Maven 3.8+**. com.oracle.genai oci-genai-auth-java-bom - 0.1.0-SNAPSHOT + 1.0.0 pom import @@ -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) diff --git a/oci-genai-auth-java-bom/pom.xml b/oci-genai-auth-java-bom/pom.xml index c751d98..3ca8270 100644 --- a/oci-genai-auth-java-bom/pom.xml +++ b/oci-genai-auth-java-bom/pom.xml @@ -12,7 +12,7 @@ com.oracle.genai oci-genai-auth-java-bom - 0.1.0-SNAPSHOT + 1.0.0 pom OCI GenAI Auth :: BOM @@ -23,7 +23,7 @@ - 0.1.0-SNAPSHOT + 1.0.0 3.72.1 diff --git a/oci-genai-auth-java-core/pom.xml b/oci-genai-auth-java-core/pom.xml index 89d9889..da0f4f1 100644 --- a/oci-genai-auth-java-core/pom.xml +++ b/oci-genai-auth-java-core/pom.xml @@ -13,7 +13,7 @@ com.oracle.genai oci-genai-auth-java-parent - 0.1.0-SNAPSHOT + 1.0.0 oci-genai-auth-java-core diff --git a/pom.xml b/pom.xml index 4a4a50d..63c2618 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ com.oracle.genai oci-genai-auth-java-parent - 0.1.0-SNAPSHOT + 1.0.0 pom OCI GenAI Auth :: Parent @@ -39,7 +39,7 @@ 17 - 0.1.0-SNAPSHOT + 1.0.0 3.72.1