Update Agent Sharing and Get Agent Share Link Using CustomGPT.ai’s RAG API’s Python SDK – A Detailed Tutorial

Author Image

Written by: Priyansh Khodiyar

Update Agent Sharing and Get Agent Share Link Using CustomGPT.ai’s RAG API’s Python SDK

Want to let the world test your CustomGPT chatbot, embed it in a web page, or pop it up as a floating widget? This guide shows you how to toggle the sharing flag and get agent share link, <iframe> snippet, and chat‑JS code—entirely in Python.

We’ll move step‑by‑step:

  1. Install & authenticate the CustomGPTs RAG APIs Python SDK.
  2. Spin up a quick demo project (agent) from a sitemap
  3. Enable sharing with a single API call
  4. Retrieve the share URL + embed/widget snippets
  5. Optionally disable sharing again
  6. Wrap up with FAQs and next steps

If you’re new to the platform, first sign up and skim Getting Started with CustomGPT.ai.
For full reference, see the API docs and our GitHub Cookbook notebook.

Prerequisites

RequirementDetails
API KeyMust include sharing‑management scope (generate under Settings → API Tokens).
Project IDThe agent you want to share; in this demo we create one on the fly.
Python 3 & customgpt‑clientInstall with pip install customgpt-client (Google Colab or local).

Once these are set, we can jump into code.

1 – Install & Authenticate the SDK

We begin by installing the SDK and setting our API token. This authenticates every subsequent call.

# Install the CustomGPT SDK

!pip install customgpt-client

# Import the SDK interface

from customgpt_client import CustomGPT

CustomGPT.api_key = "YOUR_API_TOKEN"   # ← Replace with your real token

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.

Next up: let’s create a quick demo project so we have something to share.

2 – Create a Demo Project from a Sitemap

A small sitemap gives us instant content and makes testing easier.

project_name = "Example ChatBot using Sitemap"

sitemap_path = "https://adorosario.github.io/small-sitemap.xml"

create_project = CustomGPT.Project.create(

    project_name = project_name,

    sitemap_path = sitemap_path

)

print("Project creation response:", create_project)

project_id = create_project.parsed.data.id

print("Project ID:", project_id)
  • Why a sitemap? It’s a quick way to feed multiple URLs into your bot.
  • Why print the response? To confirm creation and capture project_id.

Project ready? Great—let’s toggle the sharing flag.

3 – Enable Public Sharing in One Call

Instead of digging into settings, we can flip is_shared directly via Project.update.

update_project = CustomGPT.Project.update(

    project_id = project_id,

    is_shared  = 1          # 1 = public / 0 = private

)

print("Sharing Enabled:", update_project.status)  # Expect "success"
  • is_shared = 1 makes the bot publicly accessible instantly.
  • The same call returns the share artifacts, so we can extract them next.

Sharing is on—time to fetch the goodies!

4 – Get agent share link, <iframe> Snippet, and Chat‑JS Widget

With sharing enabled, pull the link and code snippets right from the update response.

details = update_project.parsed.data

print("=== Public Share Details ===")

print("Direct URL:", details.shareable_link)      # Opens full‑screen chat

print("\n<iframe> Embed:\n", details.embed_code)  # Inline anywhere

print("\nChat JS Widget:\n", details.live_chat_code)  # Floating bubble
AssetIdeal Use
Direct URLQuick demos, Slack links, stakeholder reviews
Embed CodeDrop into any HTML section; style with CSS
Live Chat CodeAdds a floating chat bubble across your site

Need to lock it down later? Let’s see how to disable sharing.

5 – Disable Sharing (Optional Cleanup)

Toggle sharing off the same way—set is_shared back to 0.

CustomGPT.Project.update(

    project_id = project_id,

    is_shared  = 0          # Flip back to private

)

print("Public access disabled.")

Within seconds, the public URL returns a 404, and embed/widget snippets stop loading new sessions.

With the full share lifecycle covered, let’s close out with common issues and next steps.

6 – Troubleshooting & FAQs

Common Issues

ProblemFix
Invalid API tokenRe‑check CustomGPT.api_key; regenerate if expired.
Project ID not foundConfirm project_id is copied exactly from the creation response.
Widget not appearingEnsure your site CSP allows scripts from https://cdn.customgpt.ai.
Immediate 404 after enablingWait a few seconds; sharing propagates almost instantly.

Frequently Asked Questions

Does sharing burn extra credits?

No—credits are based on message tokens, not visibility.

Can I style the iframe?

Absolutely—wrap it in a div and apply CSS (width, border, etc.).

Difference between iframe vs. chat‑JS?

Iframe is inline content; chat‑JS injects a floating bubble.

Add analytics?

Surround the iframe or listen to widget events with your own JS.

7 – Conclusion

In this tutorial you:

  1. Installed & authenticated the CustomGPT Python SDK
  2. Spun up a demo project from a sitemap
  3. Enabled public sharing with a single update call
  4. Retrieved the direct link, iframe embed, and chat‑widget code
  5. Disabled sharing when finished testing

Armed with these snippets, you can demo your bot to anyone or drop it onto any website in seconds.

For more examples, explore:

Happy coding—and happy sharing!

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.