Get Page Metadata Using CustomGPT.ai RAG API’s Python SDK – A Comprehensive Tutorial

Author Image

Written by: Priyansh Khodiyar

Get Page Metadata Using CustomGPT.ai RAG API’s Python SDK

Watch the demo video at the top for a live walkthrough as you follow along! (coming soon)

1. Introduction

Hey there! In this tutorial, we’ll explore how to fetch and update page metadata for your chatbot agent using the CustomGPTs RAG APIs Python SDK implementation. Instead of calling the raw REST endpoints, we’ll leverage the SDK’s Pythonic interface to:

  1. Install and configure the SDK
  2. Create an agent from an uploaded file
  3. List the agent’s pages and grab a page ID
  4. Retrieve that page’s metadata (like its title)
  5. Update the page’s metadata

By the end, you’ll see how simple it is to manage page metadata entirely in Python.

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.

Code – https://github.com/Poll-The-People/customgpt-cookbook/blob/main/examples/SDK_GetPageMetadata.ipynb

2. Prerequisites

Before you begin, make sure you have:

  • CustomGPT.ai Account: Signed up and logged in at CustomGPT.ai.
  • API Key: Generated your API token under your dashboard’s API settings.
  • Python Environment: Google Colab, Jupyter Notebook, or any Python 3 environment.
  • Basic Python Knowledge: Comfortable installing packages, importing modules, and reading JSON-like objects.

Get API keys

To get your 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.
Create API

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.

With those ready, let’s install the SDK.

3. Setting Up the SDK

First up, install the customgpt-client package and set your API key:

# Install the CustomGPT SDK so you can call its high‑level methods
!pip install customgpt-client
# Import the main SDK class
from customgpt_client import CustomGPT
# Authenticate all SDK calls by setting your API token
CustomGPT.api_key = "YOUR_API_KEY"  # ← Replace with your real token
  • pip install pulls in the SDK from PyPI.
  • from customgpt_client import CustomGPT gives you access to all the SDK’s functions.
  • CustomGPT.api_key = … ensures every method you call is authenticated.

Now that the SDK is configured, let’s create our chatbot agent.

4. Creating a Chatbot from a File

Instead of a sitemap, we’ll upload a document file as the source for our chatbot. Google Colab makes file uploads easy:

from google.colab import files
from customgpt_client.types import File
# 1) Upload a file interactively from your local machine
uploaded_file = files.upload()  
# 2) Extract the binary content of the uploaded file
file_content = next(iter(uploaded_file.values()))
print("Uploaded file bytes:", file_content[:20], "...")
# 3) Give your agent a name
project_name = 'Example ChatBot from File'
# 4) Create the agent by passing the File object to the SDK
create_project = CustomGPT.Project.create(
    project_name=project_name,
    file=File(payload=file_content, file_name='Yes.doc')
)
# 5) Print the SDK response to verify creation
print("Project creation response:", create_project)
  • files.upload() opens a file picker in Colab.
  • File(payload=…, file_name=…) wraps your file bytes and filename for the SDK.
  • CustomGPT.Project.create sends both parameters to create your agent.

Once the agent exists, pages will be generated as it ingests the file. Let’s grab one.

5. Retrieving a Project Page

Next, we pull the list of pages your agent created and select one page ID:

# 1) Extract the new agent’s ID
project_id = create_project.parsed.data.id
print("Project ID:", project_id)
# 2) Fetch all pages for this project
project_page = CustomGPT.Page.get(project_id=project_id)
# 3) Parse out the list of pages
pages_data = project_page.parsed.data.pages.data
print("Pages list:", pages_data)
# 4) Grab the first page’s ID
page_id = pages_data[0].id
print("Selected page ID:", page_id)
  • CustomGPT.Page.get returns a structured object containing pages.data, an array of pages.
  • We pick the first page by indexing [0] and retrieve its .id.

Now that we have a page_id, we can inspect its metadata.

6. Getting Page Metadata

To see details like the page’s title, call the metadata endpoint:

# 1) Fetch metadata for that specific page
page_metadata = CustomGPT.PageMetadata.get(
    project_id=project_id,
    page_id=page_id
)
# 2) Parse the returned metadata object
metadata = page_metadata.parsed.data
print("Full metadata:", metadata)
# 3) Print just the title field
print("Page title:", metadata.title)
  • CustomGPT.PageMetadata.get retrieves attributes like title, description, and any custom fields.
  • The parsed .data object holds these values, which you can print or manipulate as needed.

Great—now let’s update that title.

7. Updating Page Metadata

With the metadata in hand, you can update fields in a single call. Here’s how to change the page’s title:

# 1) Call the update method with a new title
updated_metadata = CustomGPT.PageMetadata.update(
    project_id=project_id,
    page_id=page_id,
    title='Vanka'
)
# 2) Parse and print the updated data
updated_data = updated_metadata.parsed.data
print("Updated metadata:", updated_data)
  • CustomGPT.PageMetadata.update sends a PATCH/PUT under the hood to update only the provided fields.
  • You get back the new metadata object so you can confirm the change.

8. Troubleshooting Common Issues

  • Empty pages.data:
    If no pages appear, give the agent a moment to process the file or re-run the conversation creation step.
  • Invalid Token Errors:
    Double‑check CustomGPT.api_key is set correctly.
  • Permission Denied:
    Ensure your API token has the right scopes to read and update metadata.
  • Network Problems:
    Verify your connection and that app.customgpt.ai is reachable.

If you’re still stuck, the CustomGPT SDK docs and community forum are great resources.

9. Conclusion

Congratulations! In this comprehensive tutorial, you learned how to:

  1. Install and configure the CustomGPT Python SDK.
  2. Create a chatbot agent from an uploaded file.
  3. Retrieve the agent’s pages and select a page ID.
  4. Fetch page metadata such as the title.
  5. Update the page metadata in a single SDK call.

With these steps, you can fully manage page metadata for your chatbot projects programmatically. Happy coding, and enjoy building powerful chatbots with CustomGPT!

Make Money With AI

Join our Partner Programs!

Boost your reputation, drive revenue and grow your business with CustomGPT.ai.

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

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.