🚀 Mastering Custom GPT Actions: Integrate External APIs Like a Pro! - Ultimate Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey there welcome this is going to be such an in-depth tutorial that shows you everything that you need to know in order to use GPT actions to their complete potential I'm going to show you everything about GPT actions we'll start by taking a look at the layout of a GPT action we'll take a look at all the required parameters and then finally we'll take a look at authentication I'm going to show you all the different possible types of authentication that you might need to set up to allow GPT to use your own API with its own specific type of authentication so this is information that I've not been able to find on any of the YouTube videos that I've watched so I'm super excited that I get to record this for you guys so if you're just here to learn sit back and enjoy and if you're actually going to follow along then you can go ahead and open up chat GPT head over to the gpts and let's get started guys now once you're in your GPT store what you want is you want to already have a GPT set up so my GPT here is simply a cinema Scout it's just meant to find helpful movies and I have this custom instruction in the description if you're not yet W us with how to create gpts I've already recorded a video on that you'll find it in the description but if you've already figured that out and you just want to learn how to set up actions this is the perfect video for you so let's go ahead and move on once you have the GPT set up what you want to do is you want to make sure that the GPT has code interpreter capabilities also activated and then we can go ahead and start to create an action the layout of an action is quite easy to get your head around but sometimes it can be tricky especially if it's your first time doing it I'll make this window bigger just so we can see everything that's in here so the schema here is just a j definition it starts by defining the open API that we're using and then it defines some information for the general action that you're creating so this is information about the exact endpoint that you're building not just the route not just the specific route that might have specific information but the entire endpoint what's the whole endpoint for and then we provide servers within this endpoint so these are the servers that we'll be communicating with and this is going to be your own custom server if you want to use it I'll show you everything that you need to know in this video to be able to use your own own custom server in here because it is a bit tricky and I've not seen too many places where they teach this nice so then the paths are the routes of the endpoint so if you wanted to get specific information from a URL you would need to provide this in this path over here then obviously we Define the type of API endpoint that we're contacting here so is it a get endpoint is it a post endpoint we Define that over here and then we have a description so this description is to do with the exact path that you've defined the description is really helpful with letting the GPT know what this path is full so you want to write that as detailed as you can and there's no token limit with the length of the description the operation ID will appear among the actions and this is what you call the action going forward then parameters so this is very important but we'll go ahead and leave it out for now but just to make it as clear as possible the parameters list is just a list of objects that will be sent by GPT to the endpoint and that's pretty much all you need to know now these other things are required the components and the schemers that stuff is required but we don't actually need that too much while contacting our API now the that we understand the general schema let's go ahead and get started with setting up our API so while setting this up I'm going to assume that you're using this on your own API to provide you with as much information as you might need while solving this problem on your end but the API that I'm going to be using is the movie DB API so this API is a little bit more complicated than other apis but everything that I'm going to show in this video will make it clear on exactly how you should set it up if you're using your own API nice so what you want to do is you want to find the url for your API in this in case I'm using this URL over here and I'll leave it linked in the description in case you're using your own URL you just want to make sure that you have that handy and then we're going to use Postman to figure out exactly how our request should look so before you try to put your request into GPT into chat GPT you should know exactly what it should look like because the things in JP can get a little bit confusing particularly when the model keeps failing so before you put it in there just make sure you use postm to figure out exactly how your request should look so this is the link that I'm using for my end point and you can see clearly the URL is this URL followed by this particular route which helps me to get the trending movies for today perfect now the URL is actually followed by a parameters option which will contain my API key and this API key is required in this exact format other API are required in other formats and I'm going to visit all formats in this video but this particular API is required as a parameter that is included within the URL and this is the value so this is my own API key if you're following along make sure you get your own API key from the movie database or an API key from any interface that you're using now once you figured out exactly how your request should look try it in Postman so for me I'm going to send my request and you can see I actually get back a valid reply now for other endpoints the authorization might be handled in headers or inside an authorization list like this one or inside parameters so once you've figured this out in Postman it gives you a good environment to go ahead and set this up inside of your custom gpts and I'm going to show you an absolute cheat code on how to make sure your gpts work correctly with handling your API key in which we combine both the authorization within the GPT interface and also an instruction so let's go ahead and get started now once we figured out how our API is going to work we just want to come back here and we want to edit our action schema I've already gone ahead and figured this out before time because I don't want to keep you here waiting while I type all this out but these are the changes that I've made so the information is get movie information this is general information for this particular URL retrieves movie information from the movie DB API the version number doesn't really matter and then the URL is the beginning URL so not the entire URL not the route not everything just the beginning URL for the API so for me it's api. thememovie d.org perfect now the paths Define the individual actions that your model can take to get information from this URL and each path is defined as a string which determines the route to your particular endpoint and then a bunch of information about what's needed by that particular route inside of char is I include it under the parameters now after you're done defining a path you need to define the description again like I said the description is really really important and then the operation ID so the operation ID is what CH GPT will call this particular action and then now the parameters so for me because I'm including my API key within the URL in this fion it's actually needed here as a parameter so I'm just going to call it name API key and then query then I give it a description so here I just say the API key for our user is it quired yes it is and its type is a string again you can have multiple Parts here so in case I wanted to be able to get trending movies for the week I could also do that in here now once this is defined you'll notice that inside of this layout I'm not actually giving it the value of my API key such as this and this is where the real superpower of being able to use both actions and instructions will come in handy so if we head back you'll see that inside of my instruction there's actually nothing in here but I'm going to add an instruction that lets the GPT know exactly what the AP I key that it needs to fill in here is all right so inside of the instructions I've now added a new instruction that lets the GPT know exactly how to use my action this is a real superpower because really gives you an unlimited capacity to customize how the GPT deals with your API endpoints so I've just added it here as action information I'm just saying when performing the get trending movies today action and as I'll show you soon this is the exact name of the action that we defined the value of the parameter API key is and then I specify my API and then I go ahead to let it know that it should always use this as the value for that parameter and the user should never be able to make a change what this parameter is so this is just in case a user tried to say well use this as the API key now because I've let the model know it will never actually allow that to be changed I'm going to go ahead and close that and so back here in our actions we can actually see that the action is called get trending movies today that's perfect so it will be able to refer to it and then inside the API key here as we saw earlier I've not specified the default value but it will always know how to use it as that value so that's how you authenticate if you're using an API key that is included in the URL like this but there's other authentication types that you might need to deal with for your own API so let's go ahead and look at those so at the bottom here there's the authentication item here and I'm just going to go ahead and click edit and the first authentication type they have is an API key so this API key whether it contains a bar or it's just a custom API key is the API key that is going to be used if you need to include your authentication within your headers so you can see here inside of the headers I've I've included a value here called authorization and then its value is beer and then a space and then a long number here indicating the bearer of this particular request and so if that's how your request looks in Postman then that's when you want to use this and as you can see here you're just specifying the API key and if you're using a bearer then you use a Bearer in that case now oth again is for other authentication types and this is probably if you're using something like Google Firebase you might need to use this and again you just want want to enter your information here and charity will be able to correctly authenticate but for me because my LPI key is directly included within the URL I'm just going to leave it to none and then I'll go ahead and save and those are all the authentication types that you might want to use so you just need to find out which authentication type you have you primarily again do this in Postman like I've said and then once you have it set up you come here and you use the action definition and also you use the instruction to make sure that your GPT gets this right every single time there's no way to fail with this technique and so now we're going to go back so once we're done now we can go ahead and test out my API so I'm just going to ask it a basic question I'm just going to say what's a popular movie for a group night out so I'm going to send that and now it's taking its time to reply and you can see it's already it's immediately now talking to my API it just wants me to confirm that I want to send that information I will send it and it successfully talked to it so the API replies with 10 currently trending movies and then the model is going to go ahead and modify its reply and give me something that's relevant to me let's take a look though at the API request that it's made so you can see in the API request that it's made it's included the API key directly within the URL and it's actually specified the API key that I told it to use and so that's why it's able to actually get a reply from this API otherwise this would have actually failed so this has been a very in-depth look into how to set up chat GPT actions hopefully this helps you with sorting out authorization on your own API this is one of the trickier things and if you actually did enjoy this video make sure you guys hit the Subscribe button so you don't miss out on future videos I will catch you soon hope you have a good time peace out
Info
Channel: AIA
Views: 17,895
Rating: undefined out of 5
Keywords:
Id: -D_0ZTSFQ5s
Channel Id: undefined
Length: 10min 30sec (630 seconds)
Published: Sun Nov 12 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.