I’m building an Oracle Cloud application and need to call a Generative AI Agent from within an Oracle Function using Python SDK. The plan is to integrate this with Oracle APEX so the agent can execute SQL queries against our database.
When I try to invoke the agent, I keep getting a 404 error saying ‘Unknown resource’. Here’s what the error looks like:
{
"status": "success",
"ai_response": "Error calling AI agent: {
'target_service': 'generative_ai_agent_runtime',
'status': 404,
'code': '404',
'opc-request-id': '3A74B8E9C25341A7B2F1E8D6A9E47CB5/17A6F93E8B72947D84C5B6A735E2F8AC/8E1D4A67F3C88B5A9F7E3D2A6B9F8E4C',
'message': 'Unknown resource 5fa33dc8-ac67-4fe9-a287-ed834bb513bb',
'operation_name': 'chat',
'timestamp': '2025-06-11T10:22:18.456789+00:00',
'client_version': 'Oracle-PythonSDK/2.154.1',
'request_endpoint': 'POST https://agent-runtime.generativeai.eu-frankfurt-1.oci.oraclecloud.com/20240531/agentEndpoints/ocid1.genaiagentendpoint.oc1.eu-frankfurt-1.amaaaaaabumsjqaa7h5ycnwvza9prjyxdslazguxym8hglcn4fvpqjg3amrx/actions/chat'
}"
}
My Python function code:
import io
import os
import json
import oci
import uuid
import logging
from oci.config import from_file
def invoke_ai_agent(user_input):
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())
agent_response = ai_agent_client.chat(
agent_endpoint_id="ocid1.genaiagentendpoint.oc1.eu-frankfurt-1.amaaaaaabumsjqaa7h5ycnwvza9prjyxdslazguxym8hglcn4fvpqjg3amrx",
chat_details=oci.generative_ai_agent_runtime.models.ChatDetails(
user_message=user_input,
session_id=conversation_id
)
)
return agent_response.data
except Exception as error:
return f"Error calling AI agent: {str(error)}"
I’ve already verified that the agent and endpoint exist in eu-frankfurt-1 region. The Dynamic Group is set up properly with IAM policies allowing access to generative-ai-family resources. Authentication works fine since I’m not getting auth errors. The OCIDs are copied directly from the console and the agent shows as active.
Any ideas why this 404 error keeps happening?