This repository acts as a template for all of Oracle's GitHub repositories. It contains information about the guidelines for those repositories. All files and sections contained in this template are mandatory, and a GitHub app ensures alignment with these guidelines. To get started with a new repository, replace the italic paragraphs with the respective text for your project.
OCI Enterprise AI provides documentation and examples for OCI Generative AI authentication libraries across Python and Java. The repository is intended for developers building with OpenAI-compatible REST APIs hosted by OCI Generative AI and OCI Enterprise AI Agents.
Use the language-specific setup instructions below to install the OCI Generative AI authentication helpers and run the examples. The Python examples use oci-genai-auth with the OpenAI SDK, and the Java examples use oci-genai-auth-java with the OpenAI Java SDK.
Developer-oriented documentation is published in this repository. Product documentation must be published on https://docs.oracle.com.
- Python: oci-genai-auth
- Java: oci-genai-auth-java
- Migration Guides
- Examples
- Help
- Contributing
- Security
- License
The OCI GenAI Auth Python library provides OCI request-signing helpers for the OpenAI-compatible REST APIs hosted by OCI Generative AI.
Source: oci-genai-auth-python
pip install oci-genai-authoci-genai-auth is designed to work together with the official OpenAI SDK.
Use OCI IAM auth when you want to sign requests with your OCI profile (session/user/resource/instance principal). Recommended if you are building OCI-native production workloads.
import httpx
from openai import OpenAI
from oci_genai_auth import OciSessionAuth
client = OpenAI(
base_url="https://inference.generativeai.us-chicago-1.oci.oraclecloud.com/openai/v1",
api_key="not-used",
http_client=httpx.Client(auth=OciSessionAuth(profile_name="DEFAULT")),
)Use OCI Generative AI API Keys if you want a long-lived API key style auth. Recommended if you are migrating from other OpenAI-compatible API providers.
To create the OCI Generative AI API Keys, follow this guide.
You don't need to install oci-genai-auth if you use API key auth.
import os
from openai import OpenAI
client = OpenAI(
base_url="https://inference.generativeai.us-chicago-1.oci.oraclecloud.com/openai/v1",
api_key=os.getenv("OCI_GENAI_API_KEY"),
)OCI Enterprise AI Agents provides a unified API for interacting with models and agentic capabilities.
- It is compatible with OpenAI's Responses API and the Open Responses Spec, enabling developers to build agents with OpenAI SDK, OpenAI Agents SDK, LangChain, LangGraph, AI SDK, CrewAI, and more.
- It offers a uniform interface, auth, billing to access multiple model providers including OpenAI, Gemini, xAI, and GPT-OSS models hosted in OCI and your Dedicated AI Cluster.
- It provides built-in agentic primitives such as agent loop, reasoning, short-term memory, long-term memory, web search, file search, image generation, code execution, and more.
In addition to the compatible endpoint to Responses API, OCI Enterprise AI Agents also offers compatible endpoints to Files API, Vector Stores API, and Containers API.
Explore examples to get started.
Note: OpenAI commercial models and image generation are only available to Oracle internal teams at this moment.
import httpx
from openai import OpenAI
from oci_genai_auth import OciSessionAuth
client = OpenAI(
base_url="https://inference.generativeai.us-chicago-1.oci.oraclecloud.com/openai/v1",
api_key="not-used",
project="ocid1.generativeaiproject.oc1.us-chicago-1.aaaaaaaaexample",
http_client=httpx.Client(auth=OciSessionAuth(profile_name="DEFAULT")),
)The OCI GenAI Auth Java library provides OCI request-signing helpers for the OpenAI-compatible REST APIs hosted by OCI Generative AI.
Requires Java 17+ and Maven 3.8+.
oci-genai-auth-java is designed to work together with the official OpenAI Java SDK.
<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>Use OCI IAM auth when you want to sign requests with your OCI profile (session/user/resource/instance principal). Recommended if you are building OCI-native production workloads.
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.us-chicago-1.oci.oraclecloud.com/openai/v1")
.okHttpClient(ociHttpClient)
.apiKey("not-used")
.build();Use OCI Generative AI API Keys if you want a long-lived API key style auth. Recommended if you are migrating from other OpenAI-compatible API providers.
To create the OCI Generative AI API Keys, follow this guide.
You don't need to install oci-genai-auth-java if you use API key auth.
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
OpenAIClient client = OpenAIOkHttpClient.builder()
.baseUrl("https://inference.generativeai.us-chicago-1.oci.oraclecloud.com/openai/v1")
.apiKey(System.getenv("OCI_GENAI_API_KEY"))
.build();OCI Enterprise AI Agents provides a unified API for interacting with models and agentic capabilities.
- It is compatible with OpenAI's Responses API and the Open Responses Spec, enabling developers to build agents with OpenAI SDK, OpenAI Agents SDK, LangChain, LangGraph, AI SDK, CrewAI, and more.
- It offers a uniform interface, auth, billing to access multiple model providers including OpenAI, Gemini, xAI, and GPT-OSS models hosted in OCI and your Dedicated AI Cluster.
- It provides built-in agentic primitives such as agent loop, reasoning, short-term memory, long-term memory, web search, file search, image generation, code execution, and more.
In addition to the compatible endpoint to Responses API, OCI Enterprise AI Agents also offers compatible endpoints to Files API, Vector Stores API, and Containers API.
Explore examples to get started.
Note: OpenAI commercial models and image generation are only available to Oracle internal teams at this moment.
OciAuthConfig config = OciAuthConfig.builder()
.authType("security_token")
.profile("DEFAULT")
.build();
OkHttpClient ociHttpClient = OciOkHttpClientFactory.build(config);
OpenAIClient client = OpenAIOkHttpClient.builder()
.baseUrl("https://inference.generativeai.us-chicago-1.oci.oraclecloud.com/openai/v1")
.okHttpClient(ociHttpClient)
.apiKey("not-used")
.addHeader("openai-project", "ocid1.generativeaiproject.oc1.us-chicago-1.aaaaaaaaexample")
.build();Demo code and instructions on how to run them can be found in the examples folder.
For official support from Oracle, use your normal Oracle support channels. For issues with the examples in this repository, open an issue in this repository.
This project welcomes contributions from the community. Before submitting a pull request, please review our contribution guide
Please consult the security guide for our responsible security vulnerability disclosure process
Copyright (c) 2026 Oracle and/or its affiliates.
Released under the Universal Permissive License v1.0 as shown at https://oss.oracle.com/licenses/upl/.