
Watch the demo video at the top of the post for a live walkthrough of this tutorial! (coming soon)
1. Introduction
Hi there! In this tutorial, we’ll show you how to delete an agent (or “project” as many of us refer to it) using the CustomGPT RAG APIs Python SDK. This guide is designed for developers who want to learn how to programmatically remove a project from their account. We’ll walk through the process step by step, explaining every line of code in detail so you fully understand how it works.
Make sure you have read our Getting Started with CustomGPT.ai for New Developers blog to get an overview of how the CustomGPT.ai platform works.
By the end, you’ll be able to programmatically inspect where your chatbot’s content comes from. For full API reference, see the CustomGPT API docs.
Code – https://github.com/Poll-The-People/customgpt-cookbook/blob/main/examples/SDK_Delete_a_project.ipynb
2. Setting Up the Environment
Before you begin, you need to install the CustomGPT Python SDK. This SDK simplifies your work by providing Pythonic interfaces to the CustomGPT API.
!pip install customgpt-client
What This Does:
- Installation:
This command installs the customgpt-client package from PyPI, allowing you to access the API using Python objects and methods.
With the SDK installed, let’s move on to creating a project (agent) using a sitemap, before getting into deleting an agent page.
3. Creating Your Custom Chat Bot Using a Sitemap
In this step, we’ll create a project (agent) using a sitemap as the content source. Even though our code calls it a project, we often refer to these as agents, especially when managing tasks like deleting a page from your agent.
# Import the CustomGPT SDK from the customgpt_client package.
from customgpt_client import CustomGPT
# Set your API token. Replace "YOUR_API_TOKEN" with your actual API token.
CustomGPT.api_key = "YOUR_API_TOKEN"
# Define the name of your project (agent). This is the title of your chatbot.
project_name = 'Example ChatBot using Sitemap'
# Define the sitemap URL which provides the content source for your chatbot.
sitemap_path = 'https://adorosario.github.io/small-sitemap.xml'
# Create the project (agent) using the SDK.
# The create method takes the project name and sitemap_path as parameters.
create_project = CustomGPT.Project.create(project_name=project_name, sitemap_path=sitemap_path)
# Print the response from the API which includes details about the created project.
print(create_project)Get API keys
To get your API key, there are two ways:
Method 1 – Via Agent
- Agent > All Agents.
- Select your agent and go to deploy, click on the API key section and create an API.
Method 2 – Via Profile section.
- Go to profile (top right corner of your screen)
- Click on My Profile
- You will see the screen something like this (below screenshot). Here you can click on “Create API key”, give it a name and copy the key.
Please save this secret key somewhere safe and accessible. For security reasons, You won’t be able to view it again through your CustomGPT.ai account. If you lose this secret key, you’ll need to generate a new one.
Detailed Explanation:
- Import Statement:
- from customgpt_client import CustomGPT: Imports the main class from the SDK so you can interact with the API.
- from customgpt_client import CustomGPT: Imports the main class from the SDK so you can interact with the API.
- Setting the API Key:
- CustomGPT.api_key = “YOUR_API_TOKEN”: Assigns your API token to the SDK. Replace the placeholder with your real token for authentication.
- CustomGPT.api_key = “YOUR_API_TOKEN”: Assigns your API token to the SDK. Replace the placeholder with your real token for authentication.
- Defining Variables:
- project_name and sitemap_path are defined to set up your project. These values determine your chatbot’s title and the URL from which it pulls its content.
- project_name and sitemap_path are defined to set up your project. These values determine your chatbot’s title and the URL from which it pulls its content.
- Creating the Project:
- CustomGPT.Project.create(…) calls the SDK method to create a new project. This method sends your project details (name and sitemap path) to the CustomGPT API.
- CustomGPT.Project.create(…) calls the SDK method to create a new project. This method sends your project details (name and sitemap path) to the CustomGPT API.
- Printing the Response:
- print(create_project) displays the API’s response, which contains information about your newly created project including its unique ID.
- print(create_project) displays the API’s response, which contains information about your newly created project including its unique ID.
Now that we’ve created your project, it’s time to delete it using the SDK.
4. Deleting a Project
Once you have created a project, including something like a WordPress site management agent, you might need to delete an agent, for example, if it was just a test project or if you need to clean up your account. The following code demonstrates how to do this using the SDK.
# Extract the project ID from the response of the project creation.
# The 'parsed' property contains the parsed JSON response, and 'data.id' holds the unique project identifier.
project_id = create_project.parsed.data.id
# To make sure that the project is sharable before deletion,
# sometimes additional steps are needed, such as updating sharing status.
# However, in this example, we proceed directly to deletion.
# Use the CustomGPT SDK to delete the project.
# The delete method takes the project_id as a parameter.
project_deleted = CustomGPT.Project.delete(project_id=project_id)
# Print the response from the API which confirms the project has been deleted.
print(project_deleted)Detailed Explanation:
- Extracting the Project ID:
- project_id = create_project.parsed.data.id:
- This line parses the response from the project creation call to retrieve the unique identifier (id) of your project.
- Accessing parsed.data.id gives you the project ID, which is necessary to perform further actions, such as deletion.
- This line parses the response from the project creation call to retrieve the unique identifier (id) of your project.
- project_id = create_project.parsed.data.id:
- Deleting the Project:
- project_deleted = CustomGPT.Project.delete(project_id=project_id):
- Calls the SDK’s delete method, passing the extracted project ID.
- This method sends a deletion request to the API, effectively removing the project from your account.
- Calls the SDK’s delete method, passing the extracted project ID.
- project_deleted = CustomGPT.Project.delete(project_id=project_id):
- Printing the Deletion Response:
- print(project_deleted):
- Outputs the response, which should indicate that the project has been successfully deleted (typically with a confirmation flag like “deleted”: true).
- Outputs the response, which should indicate that the project has been successfully deleted (typically with a confirmation flag like “deleted”: true).
- print(project_deleted):
With these steps, you’ve successfully deleted a project using the CustomGPT Python SDK.
5. Conclusion
Congratulations! In this guide, you learned how to:
- Install and set up the CustomGPT Python SDK.
- Create a custom chatbot (project/agent) using a sitemap as the content source.
- Extract the project ID from the API response.
- Delete the project using the SDK and confirm the deletion.
These steps provide a clear and straightforward process to manage your projects programmatically. The CustomGPT SDK streamlines API interactions and makes it easier to integrate chatbot functionalities into your applications.
If you have any questions or need further assistance, feel free to consult the official CustomGPT documentation or join our developer community for support.
Happy coding, and enjoy building your chatbot solutions with CustomGPT!.
Frequently Asked Questions
What is the difference between an agent and a project when deleting with the Python SDK?
In the SDK workflow, u0022agentu0022 and u0022projectu0022 refer to the same chatbot resource. If you see project terminology in code or responses, you are still working with the same agent you created or want to delete. That naming detail helps prevent confusion when you script create and delete actions.
What exactly gets removed when I delete an agent?
Barry Barresi described a u0022custom-built Theory of Change AIM GPT agent on the CustomGPT.ai platform. Rapidly Develop a Credible Theory of Change with AI-Augmented Collaboration.u0022 In this SDK workflow, deleting an agent means removing that specific project or agent resource from your account. The documented materials do not say that agent deletion also revokes API keys or performs other account-level cleanup, so treat those as separate tasks unless another API method confirms otherwise.
How can I safely automate agent deletion in Python scripts or CI pipelines?
For automated deletion, the supported essentials are API key-based authentication and careful key handling. You can create the key from an agent’s Deploy area or from My Profile, then save it somewhere safe and accessible because you will not be able to view it again later. If you lose the key, generate a new one before rerunning your script.
Can I delete multiple test or demo agents programmatically?
Brendan McSheffrey of The Kendall Project said, u0022We love CustomGPT.ai. It’s a fantastic Chat GPT tool kit that has allowed us to create a ‘lab’ for testing AI models. The results? High accuracy and efficiency leave people asking, ‘How did you do it?’ We’ve tested over 30 models with hundreds of iterations using CustomGPT.ai.u0022 For that kind of test environment, Python-based deletion supports scripted cleanup workflows, but the provided materials do not document a bulk-delete endpoint or batch SDK call. Check the linked API reference before assuming multiple agents can be removed in one request.
Do I need the project ID to delete an agent, or is the name enough?
The available SDK details here do not specify whether deletion takes a project name, a project ID, or another identifier. The safest next step is to check the API reference and use the exact identifier required by the SDK method, especially if you create multiple similar agents.
What is the safest way to manage API keys for deletion scripts?
SOC 2 Type 2 certification indicates independently audited security controls, but you still need to protect your own secret carefully. Generate the API key either from an agent’s Deploy section or from My Profile, store it somewhere safe and accessible, and treat it as a one-time-view secret. If you lose the key, you will need to create a new one.
Do I need to open the dashboard to delete an agent, or can I do it entirely in Python?
Stephanie Warlick said, u0022Check out CustomGPT.ai where you can dump all your knowledge to automate proposals, customer inquiries and the knowledge base that exists in your head so your team can execute without you.u0022 For deletion, you can work entirely in Python once you already have a valid API key. The dashboard is mentioned as a place to create the key, but the remove-agent workflow itself is designed to be programmatic through the SDK.
Related Resources
If you’re planning beyond API workflows, this page adds useful context for larger-scale implementation.
- Enterprise AI Deployment — Explore how CustomGPT.ai supports secure, scalable AI deployments for enterprise teams and production use cases.

Priyansh is Developer Relations Advocate who loves technology, writer about them, creates deeply researched content about them.