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:
- Install & authenticate the CustomGPTs RAG APIs Python SDK.
- Spin up a quick demo project (agent) from a sitemap
- Enable sharing with a single API call
- Retrieve the share URL + embed/widget snippets
- Optionally disable sharing again
- 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
Requirement | Details |
API Key | Must include sharing‑management scope (generate under Settings → API Tokens). |
Project ID | The agent you want to share; in this demo we create one on the fly. |
Python 3 & customgpt‑client | Install 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
- 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.
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
Asset | Ideal Use |
Direct URL | Quick demos, Slack links, stakeholder reviews |
Embed Code | Drop into any HTML section; style with CSS |
Live Chat Code | Adds 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
Problem | Fix |
Invalid API token | Re‑check CustomGPT.api_key; regenerate if expired. |
Project ID not found | Confirm project_id is copied exactly from the creation response. |
Widget not appearing | Ensure your site CSP allows scripts from https://cdn.customgpt.ai. |
Immediate 404 after enabling | Wait 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:
- Installed & authenticated the CustomGPT Python SDK
- Spun up a demo project from a sitemap
- Enabled public sharing with a single update call
- Retrieved the direct link, iframe embed, and chat‑widget code
- 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:
- GitHub Cookbook notebook – Update Project Sharing example
- API documentation – CustomGPT API Reference
Happy coding—and happy sharing!
Priyansh is Developer Relations Advocate who loves technology, writer about them, creates deeply researched content about them.