Get Settings for a Particular Project Using CustomGPT RAG API – A Step-by-Step Guide

Watch the embedded video at the top of this post for a live demo and explanation! (coming soon)

1. Introduction

Hey there! In this guide, we’re going to walk through a Google Colab notebook that uses the CustomGPT RAG API to get settings for a specific project. (By the way, we now call these “agents” in our discussion, even though the code still says “project.”) You’ll learn how to set up your environment, create an agent using a sitemap, and finally, retrieve its settings like the default prompt, avatar, background, and more. Let’s get started!

Make sure you have read our Getting Started with CustomGPT.ai for New Developers blog to get an overview of the entire platform.

Get the cookbook link here – https://github.com/Poll-The-People/customgpt-cookbook/blob/main/examples/Get_Settings_for_a_particular_project.ipynb

2. Setting Up the Environment

Before we jump into creating our agent, we need to set up our workspace. In our notebook, we’ll define the RAG API endpoint, add our RAG API token, and import the libraries we need.

The Code:

# 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 json

What’s Happening, Line by Line:

  • Line 1: We define the base URL for the CustomGPT RAG API. All our RAG API calls will start with this endpoint.
  • Line 2: Here, we set our RAG API token. Make sure to replace ‘ADD_YOUR_API_TOKEN_HERE‘ with your actual token.
  • Lines 4-6: We create a dictionary called headers that tells the RAG API what type of data we’re sending (application/json) and includes our authorization token.
  • Lines 8-9: We import the requests library to help make HTTP calls and json to handle JSON data. These are essential for interacting with the RAG API.

Get Your RAG API Key

To get your RAG API key, there are two ways:

Method 1 – Via Agent

  1. Agent > All Agents.
  2. Select your agent and go to deploy, click on the API key section and create an API. 

Method 2 – Via Profile section.

  1. Go to profile (top right corner of your screen)
  2. Click on My Profile
  3. 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.

Now that our environment is set up, let’s check out what you’ll need before you run any code.

3. Prerequisites to Use CustomGPT RAG APIs

Before you dive in, make sure you have the following:

  • CustomGPT.ai Account: Sign up and log in at CustomGPT.ai.
  • RAG API Key: Generate your RAG API token from your account dashboard.
  • Basic Python Knowledge: Familiarity with Python and REST APIs will help you follow along.
  • Google Colab: We’ll use Google Colab to run the notebook—no local setup required!

4. Get Your RAG API Key

For those interested in Retrieval Augmented Generation (RAG) methods, your RAG API key is your gateway to all the cool stuff CustomGPT offers. Your token not only authenticates your requests but also ensures you have the permissions to manage your agents. Make sure you’ve copied your key correctly before moving forward.

5. Creating an Agent (Project) for Your Account

Now we’re ready to create an agent. Even though the code uses the term “project,” think of it as creating your chatbot’s workspace. We’ll use a sitemap URL as the content source for our agent.

The Code:

# 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)

Line-by-Line Explanation:

  • Comment & Line 2-3: We set the name of our agent (project_name) and define a sitemap URL (sitemap_path). This sitemap serves as a source for our agent’s content.
  • Line 5-7: The payload is created by converting our project details into JSON format. This is what we send to the RAG API to tell it what our agent should be.
  • Line 9: We build the full URL by appending ‘projects’ to our ARAG PI endpoint.
  • Line 11: We use the requests.request() method to send a POST request. This creates the agent on the CustomGPT platform using the details we provided.
  • Line 12: The response from the RAG API is printed. If everything goes well, you’ll see a JSON output with details like the agent’s ID.

Once your agent is created and you see the sample output (for example, an ID like 524), we can move on to retrieving its settings.

6. Getting the Settings for Your Agent

Now that our agent is up and running, let’s fetch its settings. These settings include things like the default prompt, chatbot avatar, background, and language settings.

The Code:

data = json.loads(create_project.text)["data"]

project_id = data["id"]

# Get the project settings

url = api_endpoint + 'projects' + f"/{project_id}" + '/settings'

project_pages = requests.request('GET', url, headers=headers)

print(project_pages.text)

Line-by-Line Explanation:

  • Line 1: We start by parsing the JSON output from our agent creation step using json.loads(). This converts the text response into a Python dictionary.
  • Line 2: We extract the agent’s unique ID from the dictionary and store it in project_id. This ID tells the RAG API which agent’s settings to fetch.
  • Line 4: We build a new URL that targets the settings endpoint for our specific agent by inserting the project_id into the URL.
  • Line 6: A GET request is made to this URL to retrieve the settings of our agent.
  • Line 7: Finally, we print out the settings. You should see output similar to this:
{"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"}

Great! You now know how to create an agent and fetch its settings. Next, let’s cover what to do if things don’t work as expected.

7. Troubleshooting Common Issues

Even with clear instructions, you might run into some issues. Here are a few common ones and how to fix them:

  • Invalid RAG API Token: Make sure you’ve replaced ‘ADD_YOUR_API_TOKEN_HERE’ with your real RAG API token and that it’s still active.
  • JSON Parsing Errors: If you see errors when converting the RAG API response, print out the raw response to check its structure. This helps ensure you’re accessing the correct keys.
  • Connection Problems: Ensure your internet connection is stable and that the RAG API endpoint URL is correct.
  • Unexpected Outputs: If the response doesn’t match the sample output, double-check your payload and URL formatting.

If you’re still stuck, refer to the official CustomGPT documentation or join the community support forum for help.

Conclusion

Awesome job! In this guide, we covered how to:

  • Set up your Google Colab environment to work with the CustomGPT RAG API.
  • Create an agent (originally called a project) using a sitemap as the content source.
  • Retrieve the settings for your agent, such as default prompts, avatars, backgrounds, and language preferences.

By following this step-by-step approach, you now have the tools to manage your agent’s configuration easily. Whether you’re building a chatbot for fun or for a real-world application, having access to these settings helps ensure your bot behaves just the way you want.

If you have any questions or need further assistance, feel free to check out the CustomGPT documentation or ask in our community. Happy coding, and enjoy creating your custom chatbot solutions with CustomGPT!

Build a Custom GPT for your business, in minutes.

Deliver exceptional customer experiences and maximize employee efficiency with custom AI agents.

Trusted by thousands of organizations worldwide

Related posts

1 Comment


Avatar photo
Slope Game
April 9, 2025 at 9:17 pm
Reply

This guide is fantastic for setting up CustomGPT! I especially appreciate the clear, step-by-step instructions. Integrating this with a project could be fun, almost like building a complex level in Slope Game, where each step needs precise execution. The explanation of API key retrieval is very helpful. Looking forward to trying this out.


Leave a reply

Your email address will not be published. Required fields are marked *

*

3x productivity.
Cut costs in half.

Launch a custom AI agent in minutes.

Instantly access all your data.
Automate customer service.
Streamline employee training.
Accelerate research.
Gain customer insights.

Try 100% free. Cancel anytime.