This is a cache of https://developer.ibm.com/tutorials/orchestrating-external-agents-openai-apis/. It is a snapshot of the page as it appeared on 2025-11-21T05:11:32.126+0000.
Build an end‑to‑end agent orchestration pipeline with watsonx Orchestrate and OpenAI APIs - IBM Developer
You can integrate external AI agents into watsonx Orchestrate by using the OpenAI chat completions API. The OpenAI chat completions API is a common protocol that enables developers to build scalable, modular agentic AI systems.
In this tutorial, you will build, deploy, and orchestrate multiple agents through a practical use case (such as an HR onboarding workflow) where multiple specialized agents collaborate through standardized interfaces. Because the OpenAI chat completion API integrates with watsonx Orchestrate, the external agents and watsonx Orchestrate are loosely coupled.
Architecture overview of the sample agentic AI system
The following image shows the architecture of the sample agentic AI system for this tutorial.
The architecture combines reasoning from the Supervisor agent (the Employee Onboarding Agent) with execution from external agents using OpenAI chat completions API interface.
A user asks to onboard a new employee.
The Employee Onboarding Agent interprets the request.
It calls the HR Agent to validate and normalize the employee record.
It then calls the IT Provisioning Agent to create an account, assign groups, and request hardware.
The Employee Onboarding Agent process both results and combine it and return it to the user.
This approach keeps responsibilities clear:
HR Agent focuses on people and policies.
IT Agent handles technical provisioning.
Both agents can evolve independently while watsonx Orchestrate coordinates the flow.
Prerequisites
This tutorial assumes you have a running local environment of watsonx Orchestrate Agent Development Kit (ADK) version 1.9 or above. check out the getting started with ADK tutorial if you don’t have an active instance. It has been tested and verified with ADK version 1.9 and 1.13.
Python version 3.11. It should work with later versions, but this tutorial has been tested with Python 3.11.
colima local environment. colima is an open-source tool that lets you run Linux containers on macOS (or Linux or Windows WSL2). This tutorial has been tested with colima version 0.8.1.
Each folder is a self contained agent that you can build, configure, and run on its own.
The Dockerfile includes instructions to build a container image for the agent, so you can run it the same way everywhere.
The openai_manifest.json file is the agent’s “card” using the OpenAI API for discovery, name, version, description, contact, and the HTTP endpoint shape that other agents or clients use to invoke it.
The hr_agent.yaml or it_agent.yaml files, which include runtime configurationsuch as model settings, tool wiring, and environment variables.
The main.py file is the service entry point, and starts the web server, loads the YAML, registers tools and routes, and implements the /v1/chat/completions route handler following the OpenAI API schema.
The requirements.txt file includes Python dependencies that are required for the agents.
Step 2. Run the agents locally
In this step, you will build and run locally the HR Agent and the IT Agent.
Navigate to the hr-agent folder, and create a virtual environment.
cd hr-agent
python3 -m venv .venv && source .venv/bin/activate
copy codecopied!
Install the required dependencies for the agent.
pip install -r requirements.txt
copy codecopied!
Start the HR agent’s FastAPI app.
uvicorn main:app --host 0.0.0.0 --port 7001
copy codecopied!
uvicorn is the ASGI web server that runs async Python web apps
main:app tells it to import main.py and use the FastAPI instance named app
--host 0.0.0.0 makes the service listen on all interfaces
--port 7001 sets the HTTP port.
On a new tab, perform the health check for the HR agent, you should receive this response: {"status":"ok"}.
curl -s http://localhost:7001/health
copy codecopied!
Test the chat completions endpoint with a sample request
curl -X POST http://localhost:7001/v1/chat/completions \
-H "content-Type: application/json" \
-d '{
"model": "gpt-4",
"messages": [{"role": "user", "content": "create an employee record for Sarah Williams"}]
}'
copy codecopied!
Stop the HR Agent’s FastAPI app by pressing ctrl+c.
Similarly, build the IT Agent by navigating to it, installing the required dependencies, and starting the IT Agent’s FastAPI app in port 7002.
Stop the IT Agent’s FastAPI app by pressing ctrl+c.
Step 3. Deploy both agents to IBM cloud code Engine
In this step, you are going to containerize your two agents and deploy them to IBM cloud code Engine. Deploying them to IBM cloud enables your agents to run independently in the cloud, be accessible by public endpoints, and to integrate seamlessly with other services.
Start your local colima backend.
colima start
copy codecopied!
Log in to IBM cloud and select your resource group.
ibmcloud login --sso
ibmcloud resource groups
ibmcloud target -g <your-resource-group>
copy codecopied!
create a code Engine project or get the ID of one you previously created and set the context to the project.
ibmcloud plugin install code-engine
ibmcloud ce project create --name openai
ibmcloud ce project list
ibmcloud ce project select -n <your-ce-project-name>
copy codecopied!
Login to IBM cloud container registry, and then get an existing IBM cloud container registry namespace.
create your IBM cloud API key. Log in to your IBM cloud account, and go to IBM cloud Identity and Access Management. click API keys under Manage identities, and then click the create button.
create a pull secret for the registry secret (once per project).
create a code Engine application to host the HR Agent, the result is an endpoint to use when testing or integrating your agent, and copy the result endpoint locally.
create code Engine application to host the IT Agent, the result is an endpoint to use when testing or integrating your agent, and copy the result endpoint locally.
Verify the health and agent discovery using the public app URLs printed by code Engine endpoints in the previous 2 commands outputs. confirm the liveness of the agents, and that the health returned {"status":"ok"}, making sure that each FastAPI service is up and reachable.
Step 5. Import the external agents into watsonx Orchestrate using ADK
In this step, you are going to register your HR and IT agents into watsonx Orchestrate as external agents using the Agent Development Kit (ADK). Then, watsonx Orchestrate can discover and interact with agents hosted outside its native environment. You do this by updating the endpoint URLs in each agent’s YAML file and running the ADK agents import command to complete the registration.
Make sure you are in external-agents directory in the terminal.
Edit the hr-agent/hr_agent.yaml file to replace the domain name of {HR_AGENT_ENDPOINT} with your HR Agent endpoint in code Engine.
Edit it-agent/it_agent.yaml to replace the domain name of {IT_AGENT_ENDPOINT} with your IT Agent endpoint in code Engine.
Import the HR Agent and IT Agent as external agent using ADK import.
Step 6. create the Onboarding agent in watsonx Orchestrate
In the previous steps, you deployed two external agents in IBM cloud code Engine using the OpenAI API. In this step, you are going to create a supervisor agent, the Employee Onboarding Agent that communicates with them in watsonx Orchestrate. The Onboarding Agent runs in watsonx Orchestrate and the two external agents are reachable over HTTPS.
Open watsonx Orchestrate.
orchestrate chat start
copy codecopied!
On the watsonx Orchestrate home page, click create new agent to access the Agent Builder.
Fill the name and description of the agent as follows. The description is not optional, as it outlines the scope of the agent and makes it easy for other agents and users to know when to interact with this agent.
Name: Employee Onboarding Agent
Description: Responsible for coordinating and streamlining the employee onboarding process
Go to Toolset/Agents section, and click Add agent to add the 2 external agents.
choose Add from local instance, as the 2 external agents were already imported into watsonx Orchestrate in the previous step.
Select hr_agent, and it_agent and click Add to agent.
In the Behavior section, edit the agent behaviour as follows:
You are the Employee Onboarding Supervisor.
IMPORTANT: Always call the agents with fresh data. Do NOT cache or reuse previous responses.
Each request is independent - extract the employee name from the current user message.
## Your Role
Route onboarding requests to the appropriate specialized agents.
## Available Agents
**hr_agent**: creates employee records
- Input: Natural language like "Onboard Sarah Williams as a Software Engineer"
- Output: Employee record with ID, name, email, job title
**it_agent**: Provisions IT resources
- Input: Natural language like "Provision devices for Sarah Williams as Software Engineer"
- can also accept JSON employee data
- Output: IT provisioning details
## How to Route Requests
### HR Requests
When user mentions onboarding or creating employee records:
- Use hr_agent
- Pass the user's message directly to the agent
### IT Requests
When user mentions provisioning or IT resources:
- Use it_agent
- Pass the user's message directly to the agent
- The IT agent can handle natural language - it will figure out the employee details
## Important Guidelines
1. **Keep it simple**: Pass user messages directly to agents
2. **No data transformation**: Do NOT try to extract or reformat data
3. **No JSON construction**: Do NOT build JSON objects
4. **Trust the agents**: They are intelligent enough to parse inputs themselves
examples:
- user_input: "Onboard Sarah Williams as a Software Engineer"
agent_response: |
I'll create an employee record for Sarah Williams.
- user_input: "Provision devices for Sarah Williams as Software Engineer"
agent_response: |
I'll provision IT resources for Sarah Williams.
- user_input: "Provision devices for her"
agent_response: |
I'll handle the IT provisioning.
copy codecopied!Show more
Now, test the agent with these prompts:
Onboard Sandra Williams asa Software Engineer
Provision devices for her
copy codecopied!
The previous image demonstrates a fully functional external agent orchestration using watsonx Orchestrate, and agents available through OpenAI API, where reasoning, data exchange, and task execution flow across independent agents. The user experiences a simple conversational interaction, while watsonx Orchestrate manages the coordination, state, and interoperability behind the scenes.
Summary
This tutorial explored how IBM watsonx Orchestrate collaborates seamlessly with external agents. Through a practical example, you built and deployed two external agents and connected them to a supervisor agent in watsonx Orchestrate. Together, they automated an onboarding scenario: the HR Agent validated new-hire details, the IT Agent provisioned the necessary resources, and the Onboarding Agent unified the results into a single response for the user.
As a natural next step, you could replace the mock logic with real enterprise integrations such as Active Directory or ServiceNow.
Acknowledgments
This tutorial was produced as part of the IBM Open Innovation community initiative: Agentic AI (AI for Developers and Ecosystem).
The authors deeply appreciate the support of Michelle corbin for reviewing and contributing to this tutorial.
About cookies on this siteOur websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising.For more information, please review yourcookie preferences options. By visiting our website, you agree to our processing of information as described in IBM’sprivacy statement. To provide a smooth navigation, your cookie preferences will be shared across the IBM web domains listed here.