Build an AI Powered Chat Router Using Oracle Cloud Infrastructure AI Agent Platform

Introduction

This tutorial demonstrates how to build an Oracle Cloud Infrastructure (OCI) AI agent which will route the user input based on its context to the LLMs hosted in OCI Generative AI service using the Oracle Cloud Infrastructure Agent Development Kit (OCI ADK). You will learn how to package OCI service logic as tools, create an AI agent that interprets natural language, and effectively gets answers based on the context. This gets the best out of the LLMs hosted inside OCI using AI agents.

As part of this tutorial we will be using only two LLMs in the backend. If the user’s input is based on content generation or text summarization, then that input will be sent to Llama 3.3 70B; if the user’s input is about coding or math, then it will be sent to Llama 4 Maverick hosted on the OCI Generative AI services.

Note:

Objectives

Prerequisites

Task 1: Create an OCI AI Agent from the OCI Console

The Oracle Cloud Infrastructure AI Agent Platform (OCI AI Agent Platform) enables you to create intelligent assistants that interpret user questions, plan actions, and call custom or built-in tools (skills) against OCI APIs. Each tool is packaged as a Python class with specific methods, confirming to the OCI ADK’s tool registration system.

  1. Log in to the OCI Console, navigate to Generative AI Agents and click Create agent.

    image

  2. In the Basic information section, enter a Name and the Welcome message. The Routing instruction will be kept blank as part of this tutorial. Click Next.

    image

  3. In the Add tool section, do not create any tools. We will use OCI ADK to create it.

  4. In the Setup agent endpoint section, select Guardrails.

    image

  5. Click Create Agent.

Key concepts:

Note: An agent can route user requests across multiple toolkits (for example, Oracle Cloud Guard, compartments) and compose multi-step operations as needed.

Task 2: Setup the OCI ADK Locally

You will write Python classes defining tools to expose Oracle Cloud Guard operations. Each function is annotated with @tool and can be called with natural language by the agent.

Update the Authentication in the Agent File

image

Task 3. Run the AI Agent

  1. Download the following file and save it in the same directory.

  2. Update the input in the oci_ai_route.py file as per your requirement.

    image

  3. Run the oci_ai_route.py file using the following command.

    uv run oci_ai_route.py 
    
  4. Based on the context the required model is invoked and content is generated.

    image

Note: You can use the agent.run() from the oci_ai_route.py added to your webapp or application to invoke this agent.

Acknowledgments

More Learning Resources

Explore other labs on docs.oracle.com/learn or access more free learning content on the Oracle Learning YouTube channel. Additionally, visit education.oracle.com/learning-explorer to become an Oracle Learning Explorer.

For product documentation, visit Oracle Help Center.