Quick start: Build and deploy an agent
This tutorial helps you to learn how to build and deploy an AI agent using watsonx.ai. The example project is a research agent that can search the web to summarize research papers using external tools.
- Required services
- watsonx.ai Studio
- watsonx.ai Runtime
Your basic workflow includes these tasks:
- Create a deployment space.
- Create an API key. An API key is a unique code that is passed in to an API to identify the calling application or user.
- Set up your development enviroment. This includes installing the prerequisite software, setting up the Python environment, and deploying the agent to IBM Cloud.
- Preview and test the agent in the deployment space.
Read about building and deploying agents
You can use the watsonx.ai chat API with foundation models that support tool calling to build agent-driven applications. You can build agent-driven workflows by using these programming methods:
- REST API
- Python
- Node.js
- LangChain (Python)
- LangChain (JS)
Read more about coding generative AI solutions.
Explore the watsonx.ai Python SDK documentation.
Alternatively, you can use graphical tools from the watsonx.ai UI to build agents. Learn more about the Agent Lab.
Watch a video about building and deploying agents
Watch this video to preview the steps in this tutorial. There might be slight differences in the user interface shown in the video. The
video is intended to be a companion to the written tutorial.
Try a tutorial to build and deploy agents
In this tutorial, you will complete these tasks:
- Task 1: Set up the watsonx.ai prerequisites
- Task 2: Build the agent
- Task 3: Deploy and test the agent
Prerequisites
This tutorial requires the following prerequisites:
For more information on the agent used in this tutorial, visit the watsonx-developer-hub GitHub repository.
Tips for completing this tutorial
Here are some tips for successfully completing this tutorial.
Use the video picture-in-picture
The following animated image shows how to use the video picture-in-picture and table of contents features:

Set up your browser windows
For the optimal experience completing this tutorial, open your account in one browser window, and keep this tutorial page open in another browser window to switch easily between the two windows. Consider arranging the two browser windows side-by-side to make it easier to follow along.

Task 1: Set up the watsonx.ai prerequisites
To preview this task, watch the video beginning at 02:26.
Task 1a: Create the deployment space
Before you can deploy the model, you need to promote the agent to a new deployment space. Deployment spaces help you to organize supporting resources such as input data and environments. Follow these steps to create a deployment space:
- From the Navigation Menu
, choose Deployments.
- Click New deployment space.
- Provide the Space name; for example:
Agent deployment space - Select your machine learning service from the list.
- Click Create.
- When the space is created, click View new space.
- Click the Manage tab.
- Next to the Space GUID, click the Copy to clipboard icon
.
- Save the value for the Space GUID in a text file to use later in the Python code.
Check your progress
The following image shows the deployment space.

Task 1b: Create an API key
You need to pass your credentials to the watsonx.ai API using an API key. If you don't have an API key, then follow these steps to create the API key:
-
From the Navigation menu
, choose Administration > Access (IAM).
-
Click the API keys page.
-
Click Create.
-
Type a name and description.
-
Click Create.
-
Copy the API key.
-
Download the API key for future use.
-
-
Save the value for the API key in a text file to use later in the Python code.
Check your progress
The following image shows the API key was successfully created.

Task 1c: Obtain the watsonx.ai URL endpoint
You need the endpoint for your region to use the APIs to build and deploy your agent. Follow these steps to obtain this information:
- Visit the Developer access page.
- Next to the watsonx.ai URL, click the Copy icon
.
- Save the value for the watsonx.ai URL in a text file to use later in the Python code.
Check your progress
The following image shows the Developer access page.

Task 2: Build the agent
To preview this task, watch the video beginning at 02:54.
Follow these steps to build the agent:
Task 2a: Download the agent template
-
Install the IBM watsonx.ai CLI by running the following command:
pip install -U ibm-watsonx-ai-cli -
Download the agent template. For details about supported agent templates, see Official agent templates in the
watsonx-developer-hubGitHub repository.The following command downloads the arXiv Research Agent template:
watsonx-ai template new community/langgraph-arxiv-researchWhen you run the command, a prompt appears where you can specify the target directory as the location to store the agent template or use the default directory name.
Task 2b: Install the agent template
-
Navigate to the directory that contains the agent template by running the following command:
cd langgraph-arxiv-research/ -
Use one of the following package installers to set up the Poetry tool for Python package and dependency management:
For
pipx:a. Set up the environment by installing Poetry.
pipx install --python 3.11 poetryFor
uv: a. Set up the environment.uv venv --python 3.11b. Install Poetry.
uv pip install poetryImportant: You can use any other tool to run your Python code. Use the Python version that is available on your system to set up the environment and make sure to use Python version 3.11 or higher. -
Use Poetry to install Python dependencies.
poetry install -
Optional: Run the following commands to install the repository in a separate virtual environment:
On a Unix-based operating system:
source $(poetry -q env use 3.11 && poetry env info --path)/bin/activate # start the environmentOn a Windows operating system:
source "$(poetry -q env use 3.12 && poetry env info --path)/Scripts/activate"
Check your progress
The following image shows the template installed successfully.

Task 2c: Set the enviroment variables
Before you can run the agent locally, you need to edit the configuration files to provide the credentials to use the watsonx.ai APIs. Follow these steps to add the working directory to the Python path and edit the configuration files:
-
Add the working directory to the
PYTHONPATHby running the following command:export PYTHONPATH=$(pwd):${PYTHONPATH} -
Make a copy of the
template.envfile and rename the configuration file to.env.cp template.env .envOpen the
.envfile in a text editor and replace the values forWATSONX_APIKEY,WATSONX_URL, andWATSONX_SPACE_IDwith the values that you stored in a text file in Task 1. -
Make a copy of the
config.toml.examplefile and rename the configuration file toconfig.toml.cp config.toml.example config.tomlOpen the
config.tomlfile in a text editor and enter values for the following parameters in the[deployment.online.parameters]section:url: Add the watsonx.ai URL based on your region.model_id: Replace the default value with the ID of a foundation model that is available in your region.
Task 2d. Run the agent locally
You can run the agent locally and interact with the agent through a terminal-based chat application.
Use the following command to run the agent:
watsonx-ai template invoke "show me the latest arxiv papers on the model context protocol"
Check your progress
The following image shows the answers provided by the agent.

Task 3: Deploy and test the agent
To preview this task, watch the video beginning at 03:37.
Task 3a. Deploy the agent
Deploy the agent as an AI service to IBM Cloud with the following command:
watsonx-ai service new
Check your progress
The following image shows that the agent deployed successfully.

Task 3b. Test the agent
Test the agent by sending inference requests to the deployed AI service with the following command:
watsonx-ai service invoke 'Hello, how can you help me?'
Check your progress
The following image shows the answers provided by the deployed agent.

Troubleshooting
| Issue | Solution |
|---|---|
ModuleNotFoundError |
Make sure PYTHONPATH is set correctly |
| IBM Cloud API errors | Double-check the credentials in the .env and config.toml files |
poetry install fails |
Make sure Python version 3.11 or later is installed and pipx is working |
Task 3c. Preview the agent in the dashboard
Once an agent is deployed to watsonx.ai, you can find the API endpoint to connect to the agent from a remote location or directly interact with the agent using the built-in chat interface. Follow these steps to use the agent through the chat interface in the watsonx user interface:
-
From the Navigation Menu
, choose Deployments.
-
Open the deployment space that you created in Task 1.
-
Click the Deployments tab.
-
Open the deployment you created in Task 3a.
-
Notice the private and public API endpoint of the agent.
-
Click the Preview tab. If you don't see the Preview tab, then follow these steps to enable the tab:
- Click the View AI service info icon
.
- For the Tags field, click the Edit icon
.
- Type
wx-agent. - Click Save.
- Click the View AI service info icon
-
In the chat interface, you can ask the same questions as you did when running the agent locally, for example:
show me a list of arxiv papers about deepseek.The answer includes a list of papers published on ArXiv that mention DeepSeek. You can also see what tools the agent called to retrieve this information.
Check your progress
The following image shows the answers provided by the deployed agent in the deployment space.

Next Steps
- Explore the watsonx.ai Python SDK documentation.
- Browse more examples in the watsonx-developer-hub GitHub repository.
- Reach out to us on Discord if you have any questions or want to share feedback.
Additional resources
- View more videos.
- Find sample data sets and notebooks to gain hands-on experience refining data in the Resource hub.