If you’d like to keep track of how your CustomGPT project is performing—like how many pages are being crawled and indexed—this guide is for you! Below, you’ll learn how to create a CustomGPT project, then retrieve its stats (think page counts, credits used, total words indexed, etc.) without using the UI, just our RAG API. Let’s jump right in.
1. Introduction
In this section, we’ll explain what you can expect from this guide:
- Setting Up the Environment: We’ll connect to the CustomGPT RAG API with an RAG API token.
- Creating a Project: We’ll tell the RAG API what we want our project to be called and which sitemap to use.
- Retrieving Project Stats: We’ll show how to fetch data like how many pages were crawled, indexed, and more.
- Running & Testing: We’ll share tips on how to run the notebook step by step.
- Troubleshooting Common Issues: We’ll discuss simple fixes for potential problems.
- Conclusion: We’ll wrap it all up with a quick summary of what you’ve learned.
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_Project_Stats.ipynb
2. Setting Up the Environment
Here, we’ll connect to the CustomGPT RAG API. You’ll see how to specify your RAG API token and set up the headers needed for authentication.
api_endpoint = 'https://app.customgpt.ai/api/v1/'
api_token = 'ADD_YOUR_API_TOKEN_HERE'
headers = {
'Content-type': 'application/json',
'Authorization': 'Bearer ' + api_token
}
import requests
import json
What’s Happening Here?
- api_endpoint: The base URL for all RAG API calls.
- api_token: Your personal key for accessing the CustomGPT service—replace ‘
ADD_YOUR_API_TOKEN_HERE
‘ with your real token. - headers: The essential data for requests. It includes the Content-type (JSON) and your Authorization header to prove you’re allowed to use the RAG API.
Get Your RAG API Key
To get your RAG 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.
Once you’ve got the environment set up, it’s time to create a CustomGPT project.
3. Creating a Project
Next, we’ll create a project and connect it to a sitemap so that CustomGPT can crawl and index pages from that sitemap.
# 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)
What’s Happening Here?
- We specify a name (project_name) and a sitemap_path` that points to pages we want to index.
- We send a POST request to /projects, which tells CustomGPT, “Create a new project for me using this sitemap.”
- The response typically returns a JSON with important details, including the project ID.
Once your project is created, you’re only one step away from getting detailed stats about how it’s doing.
4. Retrieving Project Stats
In this section, we’ll show how to grab the project ID from the creation step and then fetch stats about pages crawled, indexed, and more.
data = json.loads(create_project.text)["data"]
project_id = data["id"]
url = api_endpoint + 'projects' + f"/{project_id}" + '/stats'
project_stats = requests.request('GET', url, headers=headers)
print(project_stats.text)
What’s Happening Here?
- We parse the JSON from our create_project response and get the id of the newly created project.
- We then call the /stats endpoint for that specific project ID (projects/{project_id}/stats).
- We send a GET request and print the output. The output includes valuable data like:
- pages_found: How many pages the sitemap discovered.
- pages_crawled: How many pages have been processed.
- pages_indexed: How many pages made it into the project’s index.
- crawl_credits_used: How many credits your crawling process consumed.
- query_credits_used: Credits spent on user queries.
- total_words_indexed: The total word count across indexed pages.
Now that you can pull these statistics, you have visibility into how your project is performing.
5. Running and Testing the Notebook
In this section, we’ll make sure everything executes smoothly and confirm that you can see the project stats both in the notebook output and your CustomGPT dashboard.
Step-by-Step Execution
- Run Each Cell: Start from the top (RAG API setup) and move down. Watch for any error messages in each cell.
- Monitor the Outputs:
- Project Creation: Check the printout of the POST request to ensure your project was created.
- Stats Retrieval: Confirm that the stats data includes your project’s indexed pages, words, and more.
Verifying on CustomGPT.ai
- Log in to your dashboard at CustomGPT.ai.
- Look for your newly created project.
- Review the stats and project details to confirm everything matches what you see in your notebook output.
If all is good, you should see the stats for your project reflected in both places.
6. Troubleshooting Common Issues
Even straightforward tasks sometimes run into bumps. Here are a few typical issues and how to fix them:
- Invalid RAG API Token: Double-check that api_token is spelled correctly and active.
- JSON Parsing Errors: Use print() on the raw JSON response before parsing to ensure it’s valid JSON.
- Missing Stats: If the stats show zero or null, ensure your sitemap is valid and that crawling had time to complete. You might need to wait a bit or refresh the stats after the crawl finishes.
- Network or Timeout Errors: Check your internet connection, or retry if CustomGPT.ai is experiencing high load.
For more in-depth help, consult the official CustomGPT.ai documentation or community forums.
7. Conclusion
Congratulations! You’ve just:
- Created a new CustomGPT project using a sitemap.
- Retrieved detailed stats—like how many pages were found, indexed, and how many words got stored.
- Monitored everything both via RAG API calls in your notebook and within your CustomGPT dashboard.
These statistics provide a transparent view into how well your project is indexing the content. Whether you’re building a chatbot, knowledge base, or any AI-driven tool, having these metrics on hand can help you fine-tune your approach and optimize for better results.
If you have any questions or run into any hurdles, don’t hesitate to reach out via CustomGPT’s official documentation or the community support channels. Happy building and analyzing your projects with CustomGPT!