[This is Part 1 of a Multi-Part Series on the CustomGPT.ai API]
In the dynamic world of technology, the API serves as bridges connecting otherwise disconnected software systems. Short for “Application Programming Interfaces,” these APIs are like digital negotiators, establishing a set of rules—or “contracts”—that allow for the smooth exchange of information.
They simplify complexity, much like a messaging app does when you text a friend: you type your message, press send, and it’s delivered, all without needing to know the technicalities of the transmission process.
APIs work under a similar premise. They’re the invisible messengers, relaying requests and responses back and forth between applications and systems. These “contracts” ensure that all parties involved agree on how to structure the requests and what to expect in response, making it possible for different software to integrate and function as a cohesive unit without the end-user having to manage or even understand the underlying code and protocols.
Universal API Access Across All Plans ????
At CustomGPT.ai, we stand firm in the belief that the power of AI should be readily accessible to all, regardless of the plan you choose. This is why we’ve made our API available across all our subscription tiers – Basic, Standard, Premium, and Enterprise. Our conviction is that by granting every customer this level of access, we’re not just opening a door to advanced technology; we’re providing a gateway to endless possibilities.
Understanding the CustomGPT.ai API
CustomGPT.ai API connects different software systems to chat with each other, similar to how your messenger apps share information.
The cool part? As mentioned above, every CustomGPT.ai plan (Basic, Standard, Premium, and Enterprise) comes with access to this API, making it available to everyone.
It means you can smoothly connect CustomGPT.ai with your existing tools and processes, making your operations smarter and more efficient.
But wait, there’s more – if you’re into integrating apps, CustomGPT.ai has a handy Zapier app that links the API with over 5,000+ different systems. This fantastic flexibility is why API access is part of all CustomGPT.ai plans. It’s about giving you the power to make your technology work better together, effortlessly.
To further explore CustomGPT.ai API let’s have a look at how you can programmatically build a chatbot and query it. In this article, we will help you create your CustomGPT.ai account, get your API key, and make your first API call. Let’s get started!
CustomGPT.ai API: A Step-by-Step Guide to Building and Querying Your Chatbot
Create CustomGPT.ai account
To set up your CustomGPT.ai account, you need to follow a few steps:
- Go to the CustomGPT website and click on sign up.
- Click on create an account.
- Now fill the blocks with the required information such as your Name and Email.
- Click on Signup and your account will be created.
Get your API key
- To get your API key go to your profile and click on API.
- Now click on the Create API key.
- And your API key will be generated. You have to save this key somewhere safe because CustomGPT.ai takes security and privacy as its priority. So, the key will not be visible to your CustomGPT.ai account.
- In some cases, if you lose your API key, you can generate a new API key.
Make your First API Call
Now let’s have a look at how you can build and query your chatbot programmatically using CustomGPT.ai API.
Step 1: Select your environment
In this post, I am using Jupyter Notebook. It’s a free web-based tool you can use to write and run your Python code. Alternatively, you could other free tools, like Google Collab, Kaggle or even on your command line. Sign up for an account before continuing.
Step 2: Install all the dependencies
Use !pip install customgpt client to download all the dependencies.
Now Run this command in Jupyter Notebook and it will download and install the necessary files for using the CustomGPT.ai API through Python code.
Step 3: Use your CustomGPT.ai API key
The next step is to import the CustomGPT.ai class from the customgpt-client library.
- from customgpt_client import CustomGPT
- CustomGPT.api_key = “YOUR_API_TOKEN”
In ‘YOUR API TOKEN’, place the actual API key. That we generated from the CustomGPT.ai account.
Step 4: Creating Chatbot using CustomGPT.ai API
The next step is to create a chatbot using a sitemap.
The above code is creating a chatbot project using the CustomGPT.ai API. Here’s a simple explanation:
Project Name: The variable project_name gives a name to the chatbot project, in this case, it’s named ‘Example ChatBot using Sitemap.’
Sitemap: The variable sitemap_path specifies the sitemap on which the chatbot will be trained.
Create Project: The CustomGPT.Project.create function create the chatbot with the given chatbot name and sitemap_path.
Print Result: The print(create_project) line displays the result of creating the project. It includes information about the project status and project_id details.
In simple terms, this code sets up a chatbot project named ‘Example ChatBot using Sitemap’ and uses a specific sitemap to help the chatbot understand the content of a website. The print statement shows the result of this setup.
I am creating a chatbot by giving it the name My Assistant and using the sitemap of an entrepreneur’s website to train my chatbot.
After running the lines of code with Name and Sitemap, the chatbot is successfully created. You can see the generated response after running the code. This generated response also contains your project_id.
Step 5: Check if the Chatbot is Created/Active
Now it’s time to check if the chatbot is active or not. To do this enter your project_id that we get from previous generated responses and place it in the following lines of code.
Write your project_id like this
- project_id = 12778
Check if the chatbot is active using the `is_chat_active` flag in the project detail response
- get_project = CustomGPT.Project.get(project_id=project_id)
- project_data = get_project.parsed
- is_chat_active = project_data.data.is_chat_active
print(is_chat_active)
- If the chatbot is Active the print function then generates the answer as True and if the chatbot is not active the responses generated will be False
Now run the code to check if the chatbot ‘My Assistant’ is active or not.
The response generated is True which shows that chatbot My Assistant is working. You can also see in the CustomGPT.ai interface that the chatbot is created.
You can also see the sitemap that I used in my Python code to generate the chatbot.
Let’s Recap!
Whew! We covered a lot of ground. We’ve covered what APIs are and how they work, introduced you to CustomGPT.ai’s API, and walked you through the initial steps of creating a chatbot—from setting up your account to crafting your first chatbot with a sitemap.
You’ve seen how accessible and straightforward it is to start integrating AI into your operations with CustomGPT.ai!
In Part Two, we’ll explore querying your chatbot and the nuances of streaming responses. Plus, we’ll break down the request and response structure for clear communication with your CustomGPT.ai chatbot.
See you in the next post!