How To Integrate Perplexity AI API with Zapier Automations β
Other Videosπ
2024-06-13
Transcript β
[00:00] in today's video we're going to be learning how to take perplexity AI API and connect it to a no code solution like zapier we'll learn how to start using the API key and begin leveraging it within zapier's user interface and within all of our automation flows furthermore this video is going to give you context of how to leverage this API in any context whether you're developing software or integrating the API let's jump into today's video Welcome Back y'all in today's video let's learn how to start leveraging perplexity AI I received a comment asking me to do this so we're doing this you watch my videos
[00:30] go ahead and leave a comment for any type of topic when it comes to this kind of stuff I'll make sure I get to it and try to make a video on it let's jump in to start off here we're just going to go to our settings click that right there once we're in our settings we're going to go to API and all you need to do from here is simply create a key so you're going to hit generate I've already generated my API key so I don't need to generate another one and no don't try to use that one that's going to be deleted by the end of this video so you can actually no go ahead go ahead try that and see what happens but it won't work furthermore while using perplexity ai's API we actually get $5 of free credit to
[01:01] start off so let's go ahead and see how we can do this by the end of this video you're going to learn how to leverage this as a web hook I'm going to explain why we're using web hook and I'm also going to include the code in the comment down below so make sure to leave a like while using perplexities API we currently have the ability to access one of their endpoints called chat completion this is kind of like having a conversation with perplexity but we're accessing it through API now which definitely makes sense think of this as chat completion for Gemini chat completion for open AI this is specific to perplexity AI though yes I'm saying AI a lot ai ai EI EO so this is how you
[01:35] send data in the context of their API don't worry I'm going to show you how to do it within zep's UI we have a couple of options that we need to make sure we fill out within the payload payload in this context is the data we're sending to this endpoint first go ahead and choose the model you want to use in the context of this payload there's a ton of different models to choose from we're going to use llama today furthermore we're going to identify the system instructions and the user instructions think of the system instructions as like this is how you operate this is your context so a very simple one is your output should be precise and concise and
[02:07] then the user content is the request how many stars are there in the galaxy how long is the United States of America in Miles stuff like that now if you want to see a full video on how to AI prompt engineer no matter the model check out that video right there it goes in depth with the correct ways of approaching the system instructions and the correct ways of approaching the user instructions now that we have an idea of how to approach this endpoint let's do it let's go ahead and create a new zap here everything I'm about to show you right now can be applied to other automation platforms such as make and pipe dream this is just
[02:37] specifically how we're going to do it within zapier's UI on top of that the web hook itself can be applied to any type of software you're developing so in order just to show you that it works and how to work it we're just going to add a dummy trigger here called a scheduler just so we can get access to the action in the web hook itself so I'm just going to set up some dummy variables here this isn't relevant this is basically whatever launches off your automation that's when that becomes comes relevant for now we're just going to go and test this trigger perfect now let's get to the fun part the web hook so why are we using a web hook Corbin because right now it doesn't integrate within zapier's
[03:09] ecosystem flawlessly where we provide an API key and then we can always reference it so in order to reference complexity API in zapier as of now is through web hooks it's kind of the whole point of this platform as if they didn't integrate with the platform we would need to reference all these apps with with the API key every single time but they make it easy if it integrates fall with the platform so for right now it doesn't so we're going have to do a web hook we choose web Hook by zap you here we're going to do an event of custom request most of the times you're doing web hooks within zapier you're going to choose custom requests because the fact
[03:41] that your payloads are going be pretty big most of the time let's go to actions here and this is where going to fill in all the relevant information I'll leave the payload in the comment down below let's go fill out everything else let's walk you through step by step what my line of thinking is so it's easier for you to do future API endpoints no matter the context right off the bat we have a couple options here first we got to fill out the method now there is a ton of different methods to choose from in today's video though we're just going to do a post the reason we're doing post and this is going to be us sending a payload is because of the fact
[04:11] that if you look in their API documentation it's requesting post one thing down now we have to actually tell it where to push this data where are we sending the data and that's going to be the endpoint here which it provides as well we're going to copy come over here and paste two things down now we get to the data itself so a lot of times times the data you don't need to provide all this craziness here you typically only need to provide very very specific points like this part here and then also authorization tokens to make our lives easy let's go and just grab the example
[04:42] data here I'm go ahead and simply grab this and hit copy it's always a great idea to start off example data just to see if like it's even connected and it works I'mma paste once we have pasted it here simply add whatever information you care about so if you want to choose a different model choose a different model so maybe we want 32k online maybe we want 70b instruct choose for the system we can change it here put anything here make sure it stays within the quotation marks that's important and then obviously we can change the underlying message now if you're familiar with zapier and you know how it works that means that we can take previous inputs
[05:14] and use it as data inputs here or previous outputs and use it as data outputs inputs here if I can speak if you really want to get familiar with zapier and all of its capabilities I'll go ahead and leave a playlist right here it's over like 80 videos long everything you do with AI and automation super in-depth stuff let's keep going here that is our payload now we got our payload we're going to go ahead and add some headers the first relevant header you're going to add is the content type this is going to tell basically the Endo how the data is being structured and received so for us it's just going to be
[05:44] application Json because this is Json now the last part which is probably the most important part is our key what gives us the ability to access this endpoint and actually receive an output to do so for this context or this type of API endpoint we're going to use authorization this is where your your API key comes into play this is how it knows to charge you this is how it identifies you when ask accessing it for messages so simply copy this or hit that little copy button you're going to paste it in here but we're going to add one other thing when it comes to this kind of authorization it's a bear authorization no not a bear it doesn't
[06:16] want to e your honey we're going to add the bear here out a space and we're going to go now we have the key to access this endpoint if I hit continue here based off this message how many stars are in the galaxy we should see an output here test in Step there we go we got the amount of tokens used and we got our answer there are approximately between 100 and 400 billion stars in the Milky Way galaxy that covers how we connect perplexity API and zapier you can use that same type of logic to connect it to your software build out web hooks that way
[06:47] that goes everything we need to know in today's video so make sure you leave a like it's completely free check out that AI prompt engineering video if you actually want to know how to leverage the system instructions and the user instructions in any context and I'll see you in the next video these are two random videos based off your choosing could be good could be bad it's all based off your clicks and YouTube's outgo that's my face and I'll see you in the next video