
Watch the demo video at the top for a live demonstration as you follow along! (coming soon)
1. Introduction
Hi there! In this tutorial, we’ll guide you through the process of updating the settings for a particular agent (or “project” as we sometimes call it) using the CustomGPT RAG API. Whether you’re looking to change your chatbot’s default prompt, update its avatar, background image, or example questions, this step-by-step tutorial will help you understand each part of the process. We’ll cover everything from setting up your environment and creating a project to retrieving and updating project settings in detail.
Make sure you have read our Getting Started with CustomGPT.ai for New Developers blog to get an overview of the entire platform.
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.
2. Setting Up the Environment
Before diving into the main code, let’s configure our environment in Google Colab. This includes specifying the API endpoint, inserting your API token, and importing the necessary libraries.
# setup API URL and API Token
api_endpoint = 'https://app.customgpt.ai/api/v1/'
api_token = 'ADD_YOUR_API_TOKEN_HERE'
headers = {
'Content-type': 'application/json',
'Authorization': 'Bearer ' + api_token
}
# imports
import requests
import jsonWhat This Does:
- API Endpoint & Token:
- Sets the base URL (api_endpoint) for all your API calls.
- Uses your API token (api_token) to authenticate your requests. Replace the placeholder with your actual token.
- Sets the base URL (api_endpoint) for all your API calls.
- Headers:
- Defines HTTP headers that specify you’re sending JSON data and include the authentication bearer token.
- Defines HTTP headers that specify you’re sending JSON data and include the authentication bearer token.
- Imports:
- Imports the requests library for making HTTP requests.
- Imports the json library to encode and decode JSON data.
- Imports the requests library for making HTTP requests.
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 as you work through how CustomGPT.ai works. 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.
With the environment ready, let’s verify you have everything set up by checking the prerequisites.
3. Prerequisites
Before you proceed, make sure you have:
- CustomGPT.ai Account: Sign up and log in at CustomGPT.ai.
- API Key: Generate your API token from your account dashboard.
- Basic Python Knowledge: Familiarity with Python and REST APIs.
- Google Colab: We’re using Google Colab, so you don’t need any local setup!
Now that you’ve confirmed your prerequisites, we can move on to creating an agent before adding a file to it.
4. Creating an Agent (Project)
Even though the code uses the term “project,” many of us refer to these as “agents,” including in this project settings walkthrough. In this step, you create an agent using a sitemap as the content source.
**Create a project for the account**
# Give a name to your project
project_name = 'Example ChatBot using Sitemap'
sitemap_path = 'https://adorosario.github.io/small-sitemap.xml'
payload = json.dumps({
"project_name": project_name,
"sitemap_path": sitemap_path
})
url = api_endpoint + 'projects'
create_project = requests.request('POST', url, headers=headers, data=payload)
print(create_project.text)Key Details:
- Agent Details:
- project_name: The name you want to assign to your agent.
- sitemap_path: The URL of the sitemap that provides the content for your agent.
- project_name: The name you want to assign to your agent.
- Payload Creation:
- Converts the agent details into a JSON string required by the API.
- Converts the agent details into a JSON string required by the API.
- POST Request:
- Sends the payload to the CustomGPT API’s projects endpoint to create your agent.
- Sends the payload to the CustomGPT API’s projects endpoint to create your agent.
- Output:
- Prints the JSON response containing details about the newly created agent (for example, its unique “id”).
- Prints the JSON response containing details about the newly created agent (for example, its unique “id”).
After creating your agent, the next step is to retrieve its current settings.
5. Retrieving Current Project Settings
Once your agent is created, you can retrieve its settings to see the default configuration. These settings include the chatbot’s avatar, background, default prompt, example questions, and language.
**Get Project settings**
data = json.loads(create_project.text)["data"]
project_id = data["id"]
# Get the project settings
url = api_endpoint + 'projects' + f"/{project_id}" + '/settings'
project_settings = requests.request('GET', url, headers=headers)
print(project_settings.text)Key Details:
- Extracting Agent ID:
- The code parses the JSON response from the previous step and extracts the id of the agent.
- The code parses the JSON response from the previous step and extracts the id of the agent.
- Building the Settings URL:
- Combines the base URL with the agent’s ID and the /settings endpoint.
- Combines the base URL with the agent’s ID and the /settings endpoint.
- GET Request:
- Sends a GET request to fetch the current settings of your agent.
- Sends a GET request to fetch the current settings of your agent.
- Output:
- Prints the settings, which by default might show values like:
{
"data": {
"chatbot_avatar": "",
"chatbot_background": "",
"default_prompt": "Ask Me Anything ...",
"example_questions": null,
"response_source": "default",
"chatbot_msg_lang": "en",
"remove_branding": false
},
"status": "success"
}With the current settings in view, we can now proceed to update them.
6. Updating Project Settings
In this step, you will update your agent’s settings by uploading new images for the avatar and background, changing the default prompt, setting example questions, and modifying the chatbot’s message language.
**Update Project Settings**
from google.colab import files
if 'Content-type' in headers.keys():
del headers['Content-type']
# Give a new default prompt
default_prompt = 'Example ChatBot using Sitemap'
# Upload new avatar image file
uploaded_file = files.upload()
file_content = next(iter(uploaded_file.values()))
chatbot_avatar_binary = file_content
# Upload new background image file
uploaded_file_2 = files.upload()
file_content_2 = next(iter(uploaded_file_2.values()))
chatbot_background_binary = file_content_2
payload = {
"chat_bot_avatar": chatbot_avatar_binary,
"chat_bot_bg": chatbot_background_binary,
"default_prompt": (None, default_prompt),
"example_questions[0]": (None, 'Test1'),
"example_questions[1]": (None, 'Test2'),
"response_source": (None, "default"),
"chatbot_msg_lang": (None, "ur")
}
url = api_endpoint + 'projects' + f'/{project_id}' + '/settings'
update_project_settings = requests.request('POST', url, headers=headers, files=payload)
print(update_project_settings.text)
# Retrieve updated settings to confirm changes
url = api_endpoint + 'projects' + f"/{project_id}" + '/settings'
project_settings = requests.request('GET', url, headers=headers)
print(project_settings.text)Key Details:
- Adjust Headers:
- Removes the “Content-type” header if it exists. This is necessary since the payload for updating settings uses multipart/form-data (which is handled automatically by the files parameter).
- Removes the “Content-type” header if it exists. This is necessary since the payload for updating settings uses multipart/form-data (which is handled automatically by the files parameter).
- Default Prompt:
- Sets the new default_prompt value to update your agent’s prompt.
- Sets the new default_prompt value to update your agent’s prompt.
- Uploading Files:
- The code uses files.upload() from Google Colab to allow you to upload a new avatar image and a new background image.
- The uploaded files are stored in variables (chatbot_avatar_binary and chatbot_background_binary).
- The code uses files.upload() from Google Colab to allow you to upload a new avatar image and a new background image.
- Payload Construction:
- Constructs a payload as a dictionary. Unlike previous JSON payloads, this payload includes file data and key-value pairs for other settings.
- For textual fields that don’t involve files (like default_prompt, example_questions, etc.), tuples with (None, value) are used.
- Constructs a payload as a dictionary. Unlike previous JSON payloads, this payload includes file data and key-value pairs for other settings.
- POST Request to Update Settings:
- Sends the update request to the /settings endpoint for your specific agent.
- Sends the update request to the /settings endpoint for your specific agent.
- Output Confirmation:
- Prints a success message indicating the settings have been updated.
- Retrieves the updated settings by sending a GET request again, which should display the new avatar URL, background URL, updated prompt, example questions, and language settings.
- Prints a success message indicating the settings have been updated.
After updating the settings, such as when updating an agent’s name, you should see confirmation in the output that your changes have been saved.
7. Troubleshooting Common Issues
If you run into any issues during these steps, here are some common troubleshooting tips:
- Invalid API Token:
- Make sure you have replaced ‘ADD_YOUR_API_TOKEN_HERE’ with your actual API token.
- Make sure you have replaced ‘ADD_YOUR_API_TOKEN_HERE’ with your actual API token.
- JSON or Payload Formatting Errors:
- Ensure your JSON and multipart/form-data payloads are correctly formatted.
- Ensure your JSON and multipart/form-data payloads are correctly formatted.
- File Upload Problems:
- If files are not uploading, check your file sizes and formats to ensure they meet the API requirements.
- If files are not uploading, check your file sizes and formats to ensure they meet the API requirements.
- Connection Issues:
- Verify your internet connection and confirm that the API endpoint is accessible.
- Verify your internet connection and confirm that the API endpoint is accessible.
If the problem persists, refer to the official CustomGPT documentation or ask for help in the community forum.
8. Conclusion
Congratulations! In this guide, you learned how to:
- Set up your Google Colab environment with the CustomGPT API.
- Create an agent using a sitemap as the content source.
- Retrieve your agent’s current settings.
- Update the project settings by uploading new images, changing the default prompt, setting example questions, and modifying the chatbot’s message language.
This step-by-step process empowers you to customize and update your chatbot’s settings as needed, ensuring it remains aligned with your requirements. If you have any questions or need further assistance, feel free to check the CustomGPT documentation or join our community for support.
Happy coding, and enjoy enhancing your chatbot experience with CustomGPT!
Related Resources
These resources expand on agent settings, sharing controls, and the broader CustomGPT.ai ecosystem.
- Get Agent Settings — Learn how to retrieve the current configuration for a specific agent using the SDK.
- Update Agent Share Link — See how to modify an agent’s sharing link through the CustomGPT.ai RAG API.
- CustomGPT.ai Integrations — Explore available integrations that connect CustomGPT.ai with your existing tools and workflows.
Frequently Asked Questions
Why should I update agent settings through the API instead of editing them manually?
“CustomGPT.ai knowledge source API is specific enough that nothing off-the-shelf comes close. So I built it myself. Kudos to the CustomGPT.ai team for building a platform with the API depth to make this integration possible.” — Joe Aldeguer, IT Director, Society of American Florists. Use the API when you need repeatable changes across agents or environments, version control for prompt and branding updates, or automation around settings such as the default prompt, avatar, background image, and example questions.
How do I safely use my own API key when updating agent settings?
Store the key in a server-side environment variable or secret manager, and send it in the `Authorization: Bearer YOUR_API_KEY` header. Save the secret somewhere safe when you create it, because it is shown only once; if you lose it, you need to generate a new key. The platform is SOC 2 Type 2 certified, but your own storage, rotation, and access controls still matter.
Can I update an agent’s settings with PHP instead of Python?
Yes. The settings workflow is API-based, not Python-only. The supported SDK list includes PHP, so you can send the same authenticated JSON request from PHP with cURL or Guzzle instead of using the Python `requests` example. The key requirements are the base API URL, JSON headers, a Bearer token, and the project or agent identifier for the settings request.
Do I need to retrieve current project settings before I update them?
Yes, if you want a safer update. Retrieve the current settings first so you can inspect the existing default prompt, avatar, background image, and example questions before changing anything. That makes it easier to update only the fields you intend to change instead of overwriting other settings by accident.
How do I keep settings synced across multiple agents or environments?
Overture Partners reduced training time from 13 weeks to 2 weeks by making 23 years of knowledge across 400+ documents accessible to 200+ employees. When you need that kind of consistency at scale, treat agent settings as versioned configuration: keep a canonical JSON file for shared prompt and branding fields, store environment-specific values separately, and run the same update script for each target agent so settings do not drift.
Why does my agent settings update call return 401, 403, or 404?
Start with the basics the API expects: the correct base URL (`https://app.customgpt.ai/api/v1/`), a valid `Authorization: Bearer …` header, JSON content type, and the right project or agent identifier. A 401 usually points to a missing or invalid token, while 403 or 404 often mean the request is targeting the wrong resource or one your key cannot access. A practical check is to test the retrieve-settings request first; if that fails, the update request will usually fail for the same reason.
Does updating an agent through the API affect deployed channels too?
“They’ve officially cracked the sub-second barrier, a breakthrough that fundamentally changes the user experience from merely ‘interactive’ to ‘instantaneous’.” — Bill French, Technology Strategist. If the same agent is connected to an embed widget, live chat, search bar, API, or MCP deployment, updating that agent’s settings changes the configuration those deployments use. Channel-specific connection steps are separate from the settings update itself.

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