I’m trying to integrate an Oracle Cloud AI Agent with my Oracle Function using Python SDK, but I keep getting a 404 error saying the resource is unknown. My goal is to connect this to Oracle Apex so it can query the database using SQL tools.
The error response looks like this:
{
"status": "error",
"response": "AI agent call failed: {
'service': 'generative_ai_agent_runtime',
'status': 404,
'code': '404',
'request-id': '3175158ED25353360BFCC3E88F2679CD/09596E03EC04969FE05E5A79576352BC/A30E4A49BC2CC5F7B9D17F5EBF5E5206',
'message': 'Unknown resource 3ce33fc6-ec55-5ge8-c280-ef834bb513bb',
'operation': 'chat',
'timestamp': '2025-06-11T10:42:18.342108+00:00',
'sdk_version': 'Oracle-PythonSDK/2.154.1',
'endpoint': 'POST https://agent-runtime.generativeai.eu-frankfurt-1.oci.oraclecloud.com/20240531/agentEndpoints/ocid1.genaiagentendpoint.oc1.eu-frankfurt-1.amaaaaaabumsjqaa4ezfogmwva8nrjyxfulahgsznx8hdmco4fwqrjg3amor/actions/chat'
}
}
Here’s my Python implementation:
import json
import oci
import uuid
from oci.config import from_file
def invoke_ai_agent(message):
try:
# Initialize with Resource Principal authentication
auth_signer = oci.auth.signers.get_resource_principals_signer()
ai_agent_client = oci.generative_ai_agent_runtime.GenerativeAiAgentRuntimeClient(
config={}, signer=auth_signer
)
conversation_id = str(uuid.uuid4())
response = ai_agent_client.chat(
agent_endpoint_id="ocid1.genaiagentendpoint.oc1.eu-frankfurt-1.amaaaaaabumsjqaa4ezfogmwva8nrjyxfulahgsznx8hdmco4fwqrjg3amor",
chat_details=oci.generative_ai_agent_runtime.models.ChatDetails(
user_message=message,
session_id=conversation_id
)
)
return response.data
except Exception as error:
return f"AI agent invocation failed: {str(error)}"
I’ve already set up the AI agent and endpoint in eu-frankfurt-1 region and double checked the OCIDs. The Dynamic Group has proper IAM policies for generative-ai-family access in the right compartment. Authentication works fine with resource principals. Both agent and endpoint are active and the compartment OCID is verified. The function runs in Oracle Cloud and uses the Python SDK correctly.