How to create and host (for free!) a custom GPT using RAW
ChatGPT has significantly transformed our interaction with technology, providing a conversational interface for intricate tasks. A key recent feature is the ability to tailor Generative Pre-trained Transformers (GPTs) for a wide range of applications, from personal assistance to specialized professional functions. This capability is further enhanced by integrating external knowledge through HTTP endpoint invocations. RAW plays a pivotal role in this development, enabling the straightforward creation of versatile and effective endpoints. These endpoints can be seamlessly and transparently integrated with customized GPTs.
With RAW, you can develop capabilities in the form of endpoints, transform them into AI assistants embodied as GPTs, and distribute them worldwide.
To follow this guide, you need a RAW account which you can create and use for free here.
How Does It Work?
Creating a Custom GPT: A Step-by-Step Guide
Follow these steps to create a custom GPT tailored to your specific needs:
- Come Up with an Idea: Start by brainstorming a unique concept. Your idea could range from a culinary mentor or a gaming strategist to an animal care consultant. Consider creating a GPT for personal use, limited distribution among a select group, or even for public access.
- Develop Endpoints with RAW: In this phase, you will establish endpoints using RAW. These endpoints serve as the primary data sources or services that your ChatGPT will interact with.
- Create a New GPT: Begin by accessing the ChatGPT user interface to start the creation of your new GPT model. This step involves integrating the OpenAPI specifications of the endpoints you created with RAW. Conveniently, RAW auto-generates these specifications to facilitate smooth integration.
- Launch and Experience Your Customized GPT: After setting up everything, it's time to launch and explore the capabilities of your bespoke GPT creation!
Example: Creating an Endpoint for ISS Coordinates in RAW
Context
The end goal is to create a GPT that offers information about the whereabouts of the International Space Station (ISS), in the form of the country name and/or city above which ISS passes by at an altitude of 370–460 kilometers. Let's call this GPT ISS tracker. Users can ask: where is ISS now?
and your GPT would reply with: ISS files over Paris right now
Develop Endpoints with RAW
Let's walk through the process of creating an endpoint that provides information about the ISS coordinates.
First, we should create a free account in RAW:
Once you login to RAW, you should head up to the 'Workspace' section as shown below.
Then, click on 'Add +' to create a new endpoint and choose a new 'Blank Endpoint' as shown below. You could also choose an existing template, but for this example, let's start blank and write the code ourselves.
Write the endpoint code
Now that you have a blank endpoint, let's start writing some code.
Step 1: Write the code
In RAW, endpoints are written in Snapi, a simple-to-use programming language specifically created specifically for building APIs. You will see this is very simple to create.
Let's copy/paste the following code for our endpoint (see figure, as step '1'):
let
iss = Json.InferAndRead("http://api.open-notify.org/iss-now.json"),
latitude = iss.iss_position.latitude,
longitude = iss.iss_position.longitude,
response = "Ground point coordinates for ISS are " + latitude + "° North, " + longitude + "° East"
in
response
This API simply retrieves the coordinates of the ground point of ISS, in the form of a plain text, such as "Ground point coordinates for ISS are 5.7802° North, 72.1912° East"
.
Step 2: Edit the metadata
ChatGPT needs to know when to use your endpoint. The endpoint metadata (shown in the figure as step '4') is important for this, as it helps the system determine when to use your endpoint. You can either manually populate title and description fields or let RAW decide what's best using its internal AI assistant. Clicking on the robot icons next to the two fields, we get these values:
- Title: Get ISS coordinates.
- Description: Retrieves the current latitude and longitude of the International Space Station (ISS) and returns a response with the coordinates.
Here is how the completed endpoint looks like:
Step 3: Test the code
Next, let's test the code. Click on the play button and you will have a live preview of the result of calling the last line of the code.
Step 4: Choose the final URL
You can choose the exact path where your API will be hosted. You can just use the default or choose a different URL. In our case, we specified: <base_url>/iss/location
Step 5: Deploy the endpoint live!
We are almost done. Now click to "Deploy" your endpoint.
Congratulations, your API is now published!
It will be served right away and visible in the API Catalog as well.
Create a New GPT
After deploying your endpoint, the next step is to create your new GPT within the ChatGPT UI. The official documentation can be found here. In the following sections, we will walk through the necessary steps using our International Space Station (ISS) tracker example as a case study.
Step 1: Enter GPT creation mode
In ChatGPT UI, click on Explore and then choose Create a GPT
.
Step 2: Configure GPT
Configuring your GPT is a crucial step in tailoring it to your specific needs. Here’s how you can do it:
-
Name Your GPT: Choose a name that is both descriptive and easy to remember. This will help users to identify the purpose of your GPT model. For instance, "ISS Tracker Chatbot" clearly indicates its function.
-
Description: Write a detailed description of what your GPT does. Include information about its functionality, intended use, and any unique features or capabilities it possesses. For example, "This GPT model provides real-time location updates of the International Space Station (ISS), including overflight details over cities and countries."
-
Instructions: Provide clear instructions on your GPT. These are vital to control the exact GPT behavior. In our example, we restrict the ISS GPT to reply in a specific way, use the underlying RAW service and boost its output by transforming coordinates to specific country and city, if possible. Below you will see the exact
You are a GPT programmed to report the name of the country and, if possible, the city that the International Space Station (ISS) is currently flying over.
Limit your responses to queries specifically about the ISS's location. In the event of irrelevant questions, respond kindly and appropriately.
Utilize the endpoint provided in the OpenAPI specification, which yields the ISS's ground point coordinates. Convert these coordinates into the names of the country and, if possible, the city. Use the response format: "Right now, the ISS is flying over {<city>, <country> | <country>}". If asked whether the ISS is flying over a specific location, like New York, USA, answer with 'yes' or 'no' as applicable.
- Conversation starters: Examples for the user to start the conversation with your GPT. For example, "Where is the ISS right now?" or "Is the ISS flying over New York, USA?"
.
Step 3: Connect your RAW endpoint with the GPT
Import OpenAPI spec
First click on Create new action
.
Then import the OpenAPI scpefication of your newly created RAW endpoint. First you need to generate it, so go back to RAW Catalog and click on OpenAPI Spec
.
Choose Copy URL. Now, this URL is copied in your clipboard.
Go back to Create new action and then click on Import from URL
Paste the copied URL to the GPT action screen:
After pasting the URL, you'd see the processed ChatGPT, along with the available operations.
Specify Authentication
Note that you have the ability to specify the authentication types or schemes.
There are three choices for authentication:
- None: No authentication is required.
- API Key: This method involves a unique key that is used to authenticate requests to your GPT. It's a simple yet effective way to control access. When using an API Key, the requester must include this key in their requests to gain access. Apart from the actual value of the API Key, you have to specify the
- OAuth: OAuth is a more complex authentication method that allows for secure and limited access. It's typically used for scenarios where you need to authenticate and authorize users from external systems without exposing credentials. This is the best way to provide personalized experiences and make the most powerful actions available to users.
For more details regarding GPT authentication, please refer to the official documentation here. In our example, we select None for simplicity.
RAW currently supports None and API Key authentication. OAuth authentication is expected to be supported in the near future!
Define Privacy Policy
Specify the URL of your service's privacy policy, which applies to your endpoints. Ensure that your policies are in alignment with OpenAI's usage policies. In our example, we reference the RAW Privacy Policy. However, for public GPTs, it's important to specify a privacy policy unique to your service.
This policy can also be provided through RAW, using it as an additional endpoint!
Test your GPT
After completing the GPT configuration, you can test your GPT and respective RAW endpoint, before publishing it. This is an actual test of your GPT integrating with the RAW endpoint, in a sandbox environment. If we enter the question "Is the ISS flying over New York, USA?", we will see the details of the internal invocation to our RAW endpoint:
This is an excellent way to debug more complex interactions with multiple internal endpoints.
Save and share
After thoroughly testing your GPT, it’s time to save and publish it. Click on Save to proceed to the final step where you can control access to your GPT. There are three access options to choose from:
-
Personal Use: This setting is ideal if you intend to use the GPT exclusively for yourself. It ensures that your GPT remains private and is not accessible to others.
-
Private Access: This option allows all ChatGPT users to access your GPT, but only if they have the specific URL. Upon selecting this option, you will receive a unique link. You can then share this link with your selected network or specific individuals who you want to grant access to.
-
Public Access: Choosing this makes your GPT accessible to all ChatGPT users. When opting for public access, it is mandatory to specify a privacy policy, as mentioned earlier. This policy should outline how user data will be handled and protected. Additionally, you are required to select a Category for your GPT. Categories help users to easily find and understand the purpose of your GPT.
Remember, the option you choose impacts who can interact with your GPT and how it can be used. It’s important to consider the nature of your GPT and your intended audience when making this decision.
Step 4: Now, you're all set to interact with your new customized GPT!
This is the home screen for your custom GPT:
Here, you have two options: you can either select one of the pre-defined conversation starters or type your specific question in the designated text area. Let's go ahead and use the first conversation starter: "Where is the ISS right now?"
Upon initiating the query, instead of directly receiving an answer, you will be prompted to grant permission for your GPT to access the RAW endpoint that was created earlier. This prompt involves the autogenerated hostname assigned to you upon your registration with RAW. If you prefer to use a vanity domain name instead of the autogenerated one, you can make a request by contacting RAW support.
After you allow traffic from your domain, the GPT will proceed to provide the answer:
It's important to note that the conversation with your ISS tracker doesn't have to stop here. You can continue to ask follow-up questions or inquire about different aspects related to the ISS. For example, you might ask about the speed or altitude of the ISS:
Caveats and Considerations
-
Endpoint Descriptions: The description for each endpoint is a critical component. It should be clear and concise, offering a snapshot of the endpoint's functionality. Additionally, it is important to keep these descriptions within 300 characters to comply with ChatGPT's requirements. This constraint ensures that the descriptions are succinct yet informative enough for users to understand the endpoint's purpose at a glance.
-
RAW Plan: RAW offers various plans, each tailored to different usage needs. The default Starter plan includes certain limitations, such as a cap on the number of endpoint calls per minute. If your project requires more extensive use, consider opting for higher-tier plans, which provide expanded capabilities and fewer restrictions. Detailed information about the various plans and what they entail can be found here. This will help you choose a plan that aligns best with your project requirements.
-
Authentication: When it comes to integrating private RAW endpoints with your GPT, setting up API Keys within the RAW platform is necessary. This step is crucial for maintaining the security and integrity of your data. It's worth noting that private RAW endpoints are a feature of the Pro plan and higher. These plans not only offer enhanced security options like private endpoints but also provide additional features that can be beneficial for more advanced or commercial projects.
In conclusion, RAW offers a streamlined platform to enhance the capabilities of ChatGPT. By allowing the integration of custom data sources and services, it opens up new avenues for developers to explore and leverage the full potential of conversational AI in various applications.
Advanced GPT Application: Analyzing Company Stock Prices in Relation to News Sentiment
For a more advanced GPT use-case, refer to Measuring the Impact of News Sentiment on Company Stock Prices.