OCI Conversations API
Use the OCI Conversations API to manage session memory. With the Conversations API, you create a conversation first and then include the conversation ID in the Responses API request. This creates a dedicated conversation object that you can reuse across turns.
The OCI Conversations API uses the same format as the OpenAI Conversations API with the OCI OpenAI-compatible endpoint. For syntax and request details, see the OpenAI Conversations API documentation. For unsupported properties, see the OCI Limitations section for each operation on this page.
Supported API Endpoint
| Base URL | Endpoint Path | Authentication |
|---|---|---|
https://inference.generativeai.${region}.oci.oraclecloud.com/openai/v1 |
/conversations |
API key or IAM session |
Replace ${region} with a supported OCI region such as us-chicago-1.
Although the request format is OpenAI-compatible, authentication uses OCI credentials, requests are routed through OCI Generative AI inference endpoints, and resources and execution remain in OCI.
Authentication
You can access OCI OpenAI-compatible endpoints in two ways:
Use API keys for testing and early development. Use IAM-based authentication for production workloads and OCI-managed environments.
Creating a Conversation
POST /conversations
- Reference
-
Python example:
# create a conversation conversation = client.conversations.create( ... ) print(conversation.id) - OCI Limitations
- None
Retrieving a Conversation
GET /conversations/{conversation_id}
- Reference
-
Python example:
# retrieve a conversation conversation = client.conversations.retrieve( "conversation_id", ) print(conversation.id) - OCI Limitations
- None
Updating a Conversation
POST /conversations/{conversation_id}
- Reference
-
Python example:
# update a conversation updated_conversation = client.conversations.update( ... ) print(updated_conversation) - OCI Limitations
- None
Deleting a Conversation
DELETE /conversations/{conversation_id}
- Reference
-
Python example:
# delete a conversation client.conversations.delete( "conversation_id" ) - OCI Limitations
- None
Create Your First Conversation
The following example uses the OpenAI SDK with the OCI OpenAI-compatible endpoint, an OCI Generative AI API key, and a project OCID:
from openai import OpenAI
client = OpenAI(
base_url="https://inference.generativeai.us-chicago-1.oci.oraclecloud.com/openai/v1",
api_key="sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
project="ocid1.generativeaiproject.oc1.us-chicago-1.xxxxxxxx",
)
# create a conversation
conversation = client.conversations.create(
metadata={"topic": "offsite"}
)
print("Conversation ID:", conversation.id)
# first question
response1 = client.responses.create(
model="openai.gpt-oss-120b",
input="Give me three ideas for a team offsite.",
conversation=conversation.id,
)
print("Response 1:", response1.output_text)
# second question
response2 = client.responses.create(
model="openai.gpt-oss-120b",
input="Make the second idea more budget friendly.",
conversation=conversation.id,
)
print("Response 2:", response2.output_text)
In this example:
base_urlpoints to the OCI OpenAI-compatible endpoint.client.responses.create(...)calls the OCI Responses API.projectidentifies an already created OCI Generative AI project for the request.