CustomGPT.ai API

Getting started with CustomGPT's API is quick and easy.

👍

TL;DR: Don't like reading documentation? Jump straight into our cookbooks on GitHub.

This quickstart guide aims to facilitate the process of getting you prepared for your first API call. If you are looking for our application, visit https://app.customgpt.ai/


Overview

As a whole, getting started with the CustomGPT API goes as follows:

  1. Create an Account or Log In
  2. Acquire your API Key
  3. Create a Project
  4. Create a Conversation
  5. Send a Message to the Conversation

This guide will walk you through the above workflow in a bit more detail. Feel free to look around our documentation hub for more information on any part listed.

Step 1: Create an Account or Log In

To use the CustomGPT website and API, you'll need to sign up for an account.

Sign up or log in here.

For more information, see our guide on creating an account and logging in.

🔒

Shhh!

It is important to keep your password private and not share it with anyone.


Step 2: Acquiring the API key

  1. From the app, click on the circle in the top right corner of the project dashboard and select the "My Profile" option from the dropdown menu that appears.
  2. Select the API tab and press the Create API Key button to generate a new API key.

🚧

Warning

  1. Make sure to take note of this key when it is created, as you will not get a chance to see it again without deleting it and creating a new key.
  2. Please ensure to keep your API key secure and confidential to prevent unauthorized access and potential security breaches.

Step 3: Create a Project

Authentication to the API is performed via HTTP Basic Auth. To authenticate with CustomGPT API endpoints, you must provide the API Key in the header, as shown below.

'authorization: Bearer Your_API_KEY' 

For example, you will use the POST - Create new project endpoint to create a new project. In this scenario, you can send an API request by adding your API Key in the Authentication header and the sitemap you wish to use as a data source in the sitemap_path as shown below:

curl --request POST \
     --url 'https://app.customgpt.ai/api/v1/projects' \
     --header 'accept: application/json' \
     --header 'authorization: Bearer Your_API_KEY' \
     --header 'content-type: application/json' \
     --data '
{
  "project_name": "Test",
  "sitemap_path": "https://example.com/sitemap.xml"
}
'

If you require assistance, or have additional feedback on the API or its documentation, reach out to [email protected]


Step 4: Create a Conversation

A conversation object represents a forum for communication between a user and the Agent. Conversations can be created every time a new message is sent, or messages can be sent to an existing conversation via the sessionID.

curl --request POST \
     --url https://app.customgpt.ai/api/v1/projects/projectID/conversations \
     --header 'accept: application/json' \
     --header 'authorization: Bearer Your_API_KEY' \
     --header 'content-type: application/json' \
     --data '
{
  "name": "New Conversation Name"
}
'

Step 5: Send a Message

Now that a conversation has been created, you can send a message to that conversation. The response you will receive is the response from your AI Agent. To send a message to the conversation, you will need the sessionID and the projectID.

curl --request POST \
     --url https://app.customgpt.ai/api/v1/projects/ProjectID/conversations/SessionID/messages \
     --header 'accept: application/json' \
     --header 'authorization: Bearer API-KEY' \
     --header 'content-type: application/json' \
     --data '
{
  "response_source": "default",
  "prompt": "Hello world"
}
'