Video14 min watch

Access Perplexity API In n8n To Scrape Live Website Data Through HTTP Request Authorization 🤖

Links from the video

Transcript

2,125 words

What's going on everybody Josh pook here and in today's video I'm going to show you how you can easily connect perplexities API into your n8n node modules and scenarios so you can actually use perplexity to shoot search the rep do research Etc when you're building out your automation sequences in NN you don't have to worry about that Na and doesn't have a native perplexity node just like how make does make.com or you can do this All In na we're going to

Dive into it let's Dive Right [Music] In All right so really quickly before I get in if you're not familiar with n8n it's an alternative to zapier and make.com yes there is a pricing tier here if you want them to host it I personally self-host it and once you self-host it it is open source so you don't have to pay for it which is one of the benefits and if you're using you know a lot of automations it's definitely something I

Would recommend looking into I did about three videos the last couple days um the main one I would suggest on checking out is showing you how to host it on your own VPS all right giving you the exact command prompts Etc it's a bit longer of a video it's about 30 40 minutes um but it's going to show you how to get set up so you don't have to worry about it in the future um make.com I love still using make.com

But um yeah this is you know here's the pricing here and if you go into make.com the good thing is they do have a native perplexity module so if I go like this for example perplexity you really have two options you can create a chat completion or make an API call which is literally the same pretty much just as an HTTP um and yeah so that is the same thing that we're going to be doing in n8n so I'll leave the

Uh perplexity um documents in the description below so you can actually go and see them as well but essentially there's really a few things that we're going to look at here so right here this is the API reference and there is literally only one um action that you can do which is chat completions all right so it makes it very simple all we're going to be doing is a post HTTP request to this link right here https corand api. perplexity a/

Chat for/ completions all right um you'll see some example body parameters here different things you can add here um objects you can add different things like Max tokens temperature top P return citation o this is cool so this is actually cool I like this return citations uh return images this is cool I didn't know you could do this um stream determines server so there's different options you can potentially use and if you go over here to the language you can see

Like the shell so you get the Cur request here if you want to do this on the shell you can see the headers right here so we're going to use a header that is an accept Json uh so we're just accept Json application Json and then content type application Json and then once we do that we're just going to go to the Json right here and add this into our body within Ann so it's very simple I'm going to show you

Exactly how to do it from scratch so just for testing purposes I'm just uh putting the trigger as in N when clicking test workflow so once we click test workflow we'd be able to see this and what you're going to do is you're going to add an HTTP node so I'll show you what that looks like we would just go here and click HTTP we do an HTTP request and we put it to a post all right then we would go

Back to our perplexity documentation and we are going to grab this URL right here or chat completions and we're going to paste that URL here authentification so um we will use generic credential type um and then for your generic off type you're going to use a header off and then um I could select my perplexity authorization that I already have just for purposes of this video I'll show you what it looks like so you would go create new you can change

Your name here um here you would just put off authorization in the name and then in the value you're just going to put be like that oh wait you can't see so you're going to write bear like that and then you're going to do a space and then you're going to go over to your perplexity account you would have to go here and uh or go click on the the gear icon to go to your settings then you click on API

Make sure you have some credits uh uploaded um so you're going to have to buy credits I think it gives you $5 of free credits every month you should be good then you're going to generate an API key these are hidden right now just for the purposes of this video you're going to copy that API key and then when you're over here say if this was my API key like this I would just take this so it's bare with a space

In between then your API key and you would just paste that for the value and then you would click save okay so I'm not going to do that we're going to close and I'm just going to use my my actual perplexity authorization okay next we are going to send some headers like I showed you so we're going to come here we're going to go here and we're going to grab accept come here paste in that first name come back and grab

Json application paste that in add another parameter same value right there and content type right here boom okay and then we're going to select send body and we're going to be sending Json and specify body type is going to be using Json and then we're just going to come to Json here and you could just copy this so if you make changes over on this side like if I added a top P right here um maximum is one if I added

A top P you can see that it actually shows over here but I'm not going to do any of that you could play around and add different stuff here and it's going to show up over here in the Json we're just going to copy this and we're going to come over here and paste this into the body like so now a few different things you could change the model and if you go over into the API docs and then you click

On guides and click on supported models you'll see the supported models so we got the perplexity models like llama 3 sonar small 32k chat 32k online 32k and then the 7 billion parameter so we have a 70 billion parameter and the 8 billion parameter um 32k and online and chat so we'll go ahead if I'm not already using this one we'll use this the biggest parameter yeah so we'll use the large parameter and the online so online allows it of course

So you can um you leverage search you this will be really good for research sh research builds and stuff like that which I'll show you more um in the future on this channel so make sure to subscribe to stay tuned for those builds um and then there are open source models too so if you want to use these hugging face ones like llama 38b instruct 7 uh 370b instruct and 87b instruct contacts lengths show right here all right so I guess

For the online for this one so actually it's not that bad so the online does have a bit smaller contacts length but not that bad and let's just see rate limits you can check out some of these uh more information here about rate limits we got right here as well as pricing so you can see the different pricing here we're at the large so we're the same as the small five bucks per thousand uh requests so pretty solid pricing and this

Allows you of course like I said to do online searching through the API which is useful you can't really do this uh at this quality of you know uh research with things like chat GPT a through the API and perplexity is just the best I've seen for researching in general right so here we could set you could set as many as you want we're going to set you know you can set your system role and your your message this one for

Example is just be precise and con uh precise and concise and then role user how many stars are there in the galaxy we could change this to like um what is um something interesting that happened yesterday in the news so this will show and um tell me what date and time it happened with sources so let's see how this does so we're just basically telling it to be precise and concise asking this question and we want it to return citations and

Images so let's go ahead and test this executing so we got it back let's check it out um yesterday on June 21st 2024 Taylor Swift reunited with Prince William at the era tour in London all right um okay one thing I'm curious about is where we would actually see the citations and the okay so I just searched perplexity can I access citations and images when accessing the perplexity API So currently citations and images through perplexity API is limited and not fully

Available to all users here are some key points uh regarding these features close beta so basically it's saying is close en Clos beta uh users interested in this feature need to apply for Access by filling in a form and describing their use case yeah so essentially unless you know unless it's been recently updated unless this is wrong guess you can't access the citations and images yet even though it says that here I guess it's just CU it's in beta um oh

Yeah if you if if I if maybe if you're watching this in the future you can at this point or maybe I'm just missing something here so if you if I am let me know in the comments down below but from what I see here as well as what perplexity is saying um it's saying that you can't do it yet unless you're in the beta program which I think would be nice I may even apply through that form to see if

I can get access to the citations because I like knowing where this information comes from uh I like to fact check if I'm leveraging things as well as to like uh just nice to know um in general but either way this is a lot better than when you're doing re research um than just using the open AI API because you can get live data accurate data and um really good stuff so other than that guys I hope you got some value

From this video if you did make sure to drop a like below and if you're new to this channel make sure to subscribe we upload videos every single day on AI news AI tutorials how to leverage automation make.com n excuse me go highle marketing Etc how to grow your business and also too if you haven't already joined our free stri community sh community.com link for that will be down below we have about 750 members I believe in our Facebook and Discord

Channel so Facebook group and then also to guys check out my book client acquisition code it's an in-depth book showing you how to get clients leveraging AI for your business if you're in B2B if you're uh AI Enthusiast uh entrepreneur Etc marketing agency coach consultant definitely want to check out that book link for that will be in down below other than that guys I will see you in tomorrow's video keep hustling keep grinding and of course accelerate your stride take care

Latest from the blog

View all