OCI Responses API

Use the OCI Responses API to call supported models, generate model outputs, and build tool-based or multi-step workflows through a single OpenAI-compatible, Open Responses-compliant API. It supports text and image inputs and text outputs. You can use it to build stateful interactions with conversation history, add supported tools such as File Search and Code Interpreter, and connect the model to external systems through Function Calling and MCP Calling.

How The Responses API Fits Into Agent Building

Use the Responses API together with the following agent-building components in OCI Generative AI:

Component Purpose
Responses API The primary OpenAI-compatible API for interacting with supported models and agentic workflows.
Agent Tools Tools for the Responses API, including File Search, Code Interpreter, Function Calling, and MCP Calling.
Agent Memory Memory for the Conversations API, including long-term memory access, and short-term memory context compaction.
Foundational Agent Building Blocks OpenAI-compatible foundational API such as Files, Vector Stores, and Containers API that you can use with the Responses API for direct control over resources.

If needed, you can use the low-level foundational building blocks with the Responses API.

What You Can Do With The Responses API

Use the Responses API to:

  • Call supported hosted models and imported models.
  • Send text and image inputs and receive text outputs.
  • Generate text or structured outputs.
  • Run single-step prompts or multi-step workflows.
  • Add supported tools in the request.
  • Stream responses back to the client.
  • Use OCI-managed conversation state through the Conversations API.
  • Reuse conversation history or previous outputs as context for later requests.
  • Connect the model to external systems and data through Function Calling and MCP Calling.
  • Combine model requests with files, vector stores, or containers when needed.

This lets you start with a simple prompt and expand to more advanced workflows without switching to a different API.

When to Use The Responses API

For most new applications, start with the Responses API.

Use it when you want to:

  • Use one API for model interaction and agentic capabilities.
  • Add supported tools to a model request.
  • Use OCI-managed conversation history.
  • Generate structured outputs.
  • Build workflows that can also use files, vector stores, or containers when needed.

Supported API Endpoint

Base URL Endpoint Path Authentication
https://inference.generativeai.${region}.oci.oraclecloud.com/openai/v1 /responses 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.

Note

The OCI Responses API uses the same format as the OpenAI Responses API with the OCI OpenAI-compatible endpoint. For syntax and request details, see the OpenAI Responses API documentation. If you use tools, ensure that you use only the tool types supported by the OCI OpenAI-compatible endpoint.

Before You Begin

Before calling the Responses API:

  • Create an OCI Generative AI project. OCI OpenAI-compatible API calls require a project.
  • Set up the client with the OCI OpenAI-compatible base URL.
  • Set up authentication.
  • Use a supported model in a supported region.

For setup steps, see QuickStart, Authentication, and Supported Models and Regions.

To call the Responses API from code, we recommend using the OpenAI SDK. See the QuickStart.

Create Your First Response

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",
)

response = client.responses.create(
    model="<supported-model-id>",
    input="Write a one-sentence explanation of what a database is."
)

print(response.output_text)

In this example:

  • base_url points to the OCI OpenAI-compatible endpoint.
  • client.responses.create(...) calls the OCI Responses API.
  • project identifies the OCI Generative AI project for the request.

Use Agent Memory with Responses API

To let OCI manage multi-turn conversation history, first create a conversation:

conversation = client.conversations.create()

Then include the conversation ID in the Responses API request:


response = client.responses.create(
  model="<supported-model-id>",
  input=[
        {
            "role": "user",
            "content": "Recommend a restaurant based on the food I like."
        }
    ],
    conversation=conversation.id,
)

Use this pattern when you want OCI to manage conversation state across requests.

For more information about memory capabilities, see Conversations API, Short-Term Memory, Long-Term Memory, and Short-Term Memory Compaction.

Use Tools with the Responses API

The Responses API supports tool-enabled workflows through the tools property. For many use cases, you can declare the tools in the request and let OCI Generative AI coordinate model execution and tool use.

Tool support is available only through the API.

Supported Tool Types

OCI Generative AI supports the following tool types with the Responses API:

Tool tools[].type Description
File Search "file_search" Lets the model search uploaded files and vector store content for retrieval-based responses.
Code Interpreter "code_interpreter" Lets the model run code in an OCI-managed sandbox environment.
Function Calling "function" Lets the user define local functions and have the application run the functions and return the results to the model.
MCP Calling "mcp" Gives the model access to methods exposed by a remote MCP server.

For setup steps and examples, select the link for each tool in the table.

Note

OpenAI documents other tool types, but OCI Generative AI supports only the tool types listed here for the Responses API. Other OCI capabilities, such as NL2SQL, are documented separately and aren't configured through the Responses API tools field.

Example: MCP Calling

The following example defines an MCP tool in the request:

response = client.responses.create(
    model="openai.gpt-oss-120b",
    tools=[
        {
            "type": "mcp",
            "server_url": "https://example.com/mcp",
        }
    ],
    input="What events are scheduled for 2026-04-02?"
)

In this example, the Responses API invokes the model and passes the MCP tool definition as part of the same request. You don't need a separate MCP-specific API.

When to Use Foundational API

You can use the low-level foundational agent building blocks with the Responses API when your workflow needs direct control over files, vector stores, or containers.

Common examples include:

  • Uploading files before sending a model request
  • Managing vector store contents directly
  • Reusing files or resources across multiple requests
  • Working with sandbox containers as part of a broader workflow

The following API are commonly used with the Responses API:

API Endpoint Path Typical Use with the Responses API
Files API /files Upload and manage files that you later reference in a response request.
Vector Stores API /vector_stores/... Manage vector store contents used for retrieval workflows such as File Search.
Containers API /containers and /containers/{id}/files Manage sandbox resources used in tool-enabled workflows.

Example: Upload a file first, then use it in the Responses API

First upload a file:

file_response = client.files.create(
    file=open("example-document.pdf", "rb"),
    purpose="assistants"
)

file_id = file_response.id

Then reference the uploaded file in the Responses API request:

response = client.responses.create(
    model="<model-id>",
    input=[
        {
            "role": "user",
            "content": [
                { "type": "input_file", "file_id": file_id },
                { "type": "input_text", "text": "List all the cities mentioned in this document." }
            ]
        }
    ]
)

In this example, the Files API and the Responses API work together in one workflow.

SDKs and Frameworks

You can use the OCI Responses API with the OpenAI SDK. You can also use it with compatible client-side agent frameworks.

The OpenAI SDK supports these languages:

  • Python
  • Java
  • TypeScript
  • Go
  • .NET

More language support is available through community libraries.

Compatible agent frameworks include:

  • OpenAI Agents SDK (recommended)
  • OpenAI Codex SDK
  • Microsoft Agent Framework
  • LangChain
  • LangGraph
  • CrewAI
  • AutoGen
  • LlamaIndex
  • Pydantic

OCI Responses API and OpenAI Responses API

Feature OCI Responses API OpenAI Responses API
Model choice Supports OCI-hosted models and non-OpenAI models OpenAI models only
Model serving infrastructure OCI shared infrastructure or dedicated AI clusters OpenAI shared infrastructure
Authentication OCI IAM or API keys API keys
Data retention Data remains in OCI Data is stored in OpenAI
Private networking Supports OCI VCN integration and private endpoints Not available
Endpoint model Regional endpoints Global endpoint