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

Josh Pocock
22 Jun 202413:10

Summary

TLDRIn this video, Josh Pook demonstrates how to integrate Perplexity's API into n8n, an open-source automation tool similar to Zapier and Make.com. He guides viewers through setting up an HTTP node in n8n to perform a POST request for chat completions with Perplexity, explaining the process of adding headers and body parameters. Josh also highlights the benefits of using Perplexity for real-time data and research in automation workflows, comparing it favorably to other AI APIs. The video concludes with a test of the setup and a note on the current limitations of accessing citations and images through the API.

Takeaways

  • 😀 Josh Pook is the presenter of the video, focusing on integrating Perplexity's API into n8n for automation sequences.
  • 🤖 n8n is an open-source alternative to Zapier and Make.com for automation, which can be self-hosted to avoid costs.
  • 🔗 There is no native Perplexity node in n8n, but it can be integrated using HTTP requests.
  • 📚 The main action available with Perplexity's API is 'chat completions', which is straightforward to implement.
  • 🌐 The API endpoint for chat completions is provided, and a POST HTTP request is used for the integration.
  • 🔑 Authentication for the API is done using a header with a Bearer token, which requires an API key from the Perplexity account.
  • 📝 The video includes instructions on setting up the HTTP node in n8n with the correct headers and body for the request.
  • 📈 Perplexity offers different models with varying parameters and capabilities, including the ability to perform online searches.
  • 💰 The pricing for using Perplexity's API is discussed, with a cost of $5 per thousand requests for the 'large' model.
  • 🚫 Currently, features like citations and images are in a closed beta and not fully available to all users.
  • 🔍 The video demonstrates a test of the integration, showing how to ask questions and request data from Perplexity.

Q & A

  • What is the main purpose of the video by Josh Pook?

    -The main purpose of the video is to demonstrate how to connect Perplexity's API into n8n node modules and scenarios for automation sequences.

  • What is n8n and how does it relate to Perplexity?

    -n8n is an open-source automation workflow tool, similar to Zapier and Make.com, which can be self-hosted. The video shows how to integrate Perplexity's API into n8n despite n8n not having a native Perplexity node.

  • Why would someone choose to self-host n8n?

    -Self-hosting n8n is beneficial because it is open source, which means there are no costs associated with using it, making it ideal for those with extensive automation needs.

  • What is the primary action available with Perplexity's API according to the video?

    -The primary action available with Perplexity's API is 'chat completions', which is used for generating responses based on input prompts.

  • How does one make an API call to Perplexity's API for chat completions?

    -An API call to Perplexity's chat completions is made using a POST HTTP request to the provided URL with the necessary headers and JSON body parameters.

  • What are some of the body parameters that can be included in a request to Perplexity's API?

    -Some of the body parameters include 'max_tokens', 'temperature', 'top_p', 'return_citation', and 'return_images', which allow customization of the API response.

  • What is the significance of the 'return_citations' and 'return_images' parameters in the API request?

    -The 'return_citations' and 'return_images' parameters, when included, instruct the API to provide citations and images along with the chat completion response, adding depth to the information provided.

  • How can one obtain the API key needed for authentication with Perplexity's API?

    -To obtain the API key, one must go to their Perplexity account settings, navigate to the API section, ensure they have credits, and then generate an API key.

  • What are the different models supported by Perplexity's API as mentioned in the video?

    -The supported models include 'llama 3', 'sonar small 32k', 'chat 32k', 'online 32k', and models with 7 billion and 8 billion parameters.

  • What is the current status of accessing citations and images through Perplexity's API?

    -As of the video's recording, accessing citations and images through Perplexity's API is limited and in closed beta, with access granted to users who apply and describe their use case.

  • How does Perplexity's API differ from other AI APIs like OpenAI's in terms of research capabilities?

    -Perplexity's API is noted for its ability to perform online searches and provide live, accurate data, making it superior for research purposes compared to other AI APIs like OpenAI's.

Outlines

00:00

🤖 Introducing Perplexity API Integration with n8n

Josh Pook introduces a tutorial on integrating the Perplexity API into n8n, an open-source automation tool similar to Zapier and Make.com. He highlights the benefits of self-hosting n8n and mentions that Perplexity does not have a native n8n node. The video will guide viewers on setting up an HTTP request to utilize Perplexity's chat completion feature within n8n workflows. The process involves using the API endpoint for chat completions, setting up headers for JSON acceptance and content type, and crafting the JSON body for the request.

05:01

🔗 Configuring Perplexity API with n8n HTTP Node

The tutorial continues with a step-by-step guide on configuring the Perplexity API within the n8n HTTP node. It includes creating a generic credential for the API key, setting request headers to accept JSON and specify the content type as application/json. The JSON body is then detailed, with parameters such as 'model' and 'messages' that can be customized according to the API documentation. The video also touches on the possibility of using different models and the option to enable online search capabilities for more accurate and up-to-date information.

10:04

🔍 Testing Perplexity API with Citations and Images

In the final part of the script, Josh tests the Perplexity API integration by sending a request to find out an interesting news event from the previous day, with the expectation of receiving citations and images. However, upon investigation, it's revealed that access to citations and images is currently in closed beta and not fully available to all users. The feature requires users to apply for access by filling out a form. The video concludes with a reminder about the benefits of using Perplexity for research and the potential of its API for obtaining live and accurate data, differentiating it from other AI APIs like OpenAI.

Mindmap

Keywords

💡n8n

n8n is an open-source automation workflow tool that serves as an alternative to platforms like Zapier and Make.com. It allows users to create automated sequences for various tasks without the need for coding. In the video, the host discusses how to integrate Perplexity's API into n8n for enhanced functionality, such as search and research capabilities within automation sequences.

💡Perplexity API

The Perplexity API is a tool that provides advanced search and chat completion functionalities. It is highlighted in the video as a service that can be integrated into n8n to add intelligent search capabilities to automation workflows. The API is demonstrated to be used for tasks like retrieving current news and information, with the potential for citation and image retrieval.

💡HTTP request

An HTTP request is a message sent from a client to a server to request access to a resource. In the context of the video, the host explains how to set up an HTTP request within n8n to communicate with the Perplexity API, specifically using a POST method to send data and receive responses.

💡API key

An API key is a unique code that identifies a user or calling program to an API. In the script, the host mentions generating an API key from the Perplexity account, which is then used to authenticate requests to the Perplexity API within the n8n automation workflow.

💡JSON

JSON (JavaScript Object Notation) is a lightweight data-interchange format that is easy for humans to read and write and for machines to parse and generate. The video script describes using JSON to structure the body of the HTTP request sent to the Perplexity API, including parameters for customization like 'max tokens' and 'temperature'.

💡Automation sequences

Automation sequences refer to a series of actions or steps that are automatically executed in a specific order. The video's main theme revolves around setting up such sequences in n8n, enhanced by integrating the Perplexity API to perform tasks like searching and retrieving information.

💡Research builds

Research builds in the context of the video refer to the creation of automated workflows designed for gathering and processing information for research purposes. The integration of the Perplexity API into n8n is positioned as a way to improve these builds by providing up-to-date and accurate data.

💡Rate limits

Rate limits are restrictions put in place by APIs to control the amount of data or number of requests a user can make within a certain time frame. The script mentions checking rate limits for the Perplexity API, indicating an awareness of these constraints when building automation workflows.

💡Pricing tier

A pricing tier refers to the different levels of service or access offered by a product or service at varying costs. The video mentions n8n having a pricing tier for those who want the service to be hosted, with self-hosting being an open-source and cost-free alternative.

💡Citations

Citations are references to the sources of information used in a piece of work. In the video, the host expresses interest in the Perplexity API's ability to return citations, which would provide the origins of the information retrieved, although it is later clarified that this feature is in beta and not fully available.

💡Images

The term 'images' in the script refers to the potential for the Perplexity API to return visual data along with the information requested. The host demonstrates setting up the API request to include image retrieval, although it is noted that this feature is also part of the beta program and not yet widely accessible.

Highlights

Josh Pook demonstrates how to integrate Perplexity's API into n8n for automation sequences.

n8n is an open-source alternative to Zapier and Make.com for self-hosted automation.

n8n lacks a native Perplexity node, but integration is possible through custom methods.

Make.com offers a native Perplexity module with options for chat completion or API calls.

The Perplexity API primarily supports chat completions with a single action.

An HTTP POST request is used to interact with the Perplexity API at a specific endpoint.

Example body parameters for the API request are detailed, including max tokens and temperature settings.

The video includes a tutorial on setting up an HTTP node in n8n for API requests.

Instructions on creating and using API keys for authentication with Perplexity are provided.

Headers for the API request include 'Accept' and 'Content-Type' set to 'application/json'.

The body of the API request is formatted in JSON with specific parameters detailed.

Different models of Perplexity are discussed, including the large parameter and online models.

The video mentions the capability of the online model to perform searches as part of its responses.

Rate limits and pricing for the Perplexity API are discussed, highlighting the cost per thousand requests.

The video tests the setup by asking a question and expecting a precise and concise answer with citations and images.

Citations and images through the Perplexity API are currently in closed beta and not fully available.

The video concludes with a mention of the author's book 'Client Acquisition Code' and a call to join the STRI community.

Transcripts

play00:01

what's going on everybody Josh pook here

play00:03

and in today's video I'm going to show

play00:05

you how you can easily connect

play00:08

perplexities API into your

play00:11

n8n node modules and scenarios so you

play00:14

can actually use perplexity to shoot

play00:17

search the rep do research Etc when

play00:19

you're building out your automation

play00:20

sequences in NN you don't have to worry

play00:23

about that Na and doesn't have a native

play00:26

perplexity node just like how make does

play00:28

make.com or you can do this All In na

play00:32

we're going to dive into it let's Dive

play00:34

Right

play00:37

[Music]

play00:43

In All right so really quickly before I

play00:46

get in if you're not familiar with n8n

play00:47

it's an alternative to zapier and

play00:49

make.com yes there is a pricing tier

play00:52

here if you want them to host it I

play00:55

personally self-host it and once you

play00:57

self-host it it is open source so you

play00:59

don't have to pay

play01:00

for it which is one of the benefits and

play01:02

if you're using you know a lot of

play01:04

automations it's definitely something I

play01:05

would recommend looking into I did about

play01:08

three videos the last couple days um the

play01:10

main one I would suggest on checking out

play01:12

is showing you how to host it on your

play01:14

own VPS all right giving you the exact

play01:16

command prompts Etc it's a bit longer of

play01:19

a video it's about 30 40 minutes um but

play01:21

it's going to show you how to get set up

play01:22

so you don't have to worry about it in

play01:24

the future um make.com I love still

play01:27

using make.com but um yeah this is you

play01:30

know here's the pricing here and if you

play01:33

go into

play01:34

make.com the good thing is they do have

play01:36

a native perplexity module so if I go

play01:39

like this for example perplexity you

play01:42

really have two options you can create a

play01:43

chat completion or make an API call

play01:45

which is literally the same pretty much

play01:47

just as an

play01:48

HTTP um and yeah so that is the same

play01:52

thing that we're going to be doing in

play01:54

n8n so I'll leave the uh perplexity um

play02:00

documents in the description below so

play02:01

you can actually go and see them as well

play02:04

but essentially there's really a few

play02:06

things that we're going to look at here

play02:07

so right here this is the API reference

play02:10

and there is literally only one um

play02:13

action that you can do which is chat

play02:16

completions all right so it makes it

play02:19

very simple all we're going to be doing

play02:21

is a post HTTP request to this link

play02:24

right here https

play02:26

corand api. perplexity a/ chat for/

play02:31

completions all right um you'll see some

play02:35

example body parameters here different

play02:38

things you can add here um objects you

play02:42

can add different things like Max tokens

play02:45

temperature top P return citation o this

play02:48

is

play02:50

cool so this is actually cool I like

play02:53

this return

play02:54

citations uh return images this is cool

play02:57

I didn't know you could do this um

play02:59

stream determines server so there's

play03:02

different options you can potentially

play03:04

use and if you go over here to the

play03:07

language you can see like the shell so

play03:09

you get the Cur request here if you want

play03:11

to do this on the shell you can see the

play03:13

headers right here so we're going to use

play03:15

a header that is an accept Json uh so

play03:19

we're just accept Json application Json

play03:23

and then content type application Json

play03:26

and then once we do that we're just

play03:27

going to go to the Json right here and

play03:29

add this into our body within Ann so

play03:32

it's very simple I'm going to show you

play03:33

exactly how to do it from scratch so

play03:37

just for testing purposes I'm just uh

play03:39

putting the trigger as in N when

play03:42

clicking test workflow so once we click

play03:44

test workflow we'd be able to see this

play03:47

and what you're going to do is you're

play03:48

going to add an HTTP node so I'll show

play03:52

you what that looks like we would just

play03:54

go here and click

play03:55

HTTP we do an HTTP request and we put it

play04:00

to a post all right then we would go

play04:04

back to

play04:05

our perplexity

play04:08

documentation and we are going to grab

play04:11

this URL right here or chat

play04:14

completions and we're going to paste

play04:16

that URL here authentification so um we

play04:20

will use generic credential

play04:25

type um and then for your generic off

play04:27

type you're going to use a header off

play04:30

and then um I could select my perplexity

play04:34

authorization that I already have just

play04:36

for purposes of this video I'll show you

play04:38

what it looks like so you would go

play04:40

create new you can change your name here

play04:43

um here you would just put

play04:45

off

play04:47

authorization in the name and then in

play04:50

the value you're just going to put

play04:53

be like that oh wait you can't see so

play04:56

you're going to write

play04:57

bear like that and then you're going to

play05:00

do a space and then you're going to go

play05:02

over to your perplexity account you

play05:04

would have to go here and uh or go click

play05:07

on the the gear icon to go to your

play05:09

settings then you click on

play05:12

API make sure you have some credits uh

play05:15

uploaded um so you're going to have to

play05:18

buy credits I think it gives you $5 of

play05:20

free credits every month you should be

play05:22

good then you're going to generate an

play05:23

API key these are hidden right now just

play05:25

for the purposes of this video you're

play05:27

going to copy that API key

play05:30

and then when you're over here say if

play05:33

this was my API key like this I would

play05:35

just take this so it's bare with a space

play05:37

in between then your API key and you

play05:40

would just paste that for the value and

play05:42

then you would click save okay so I'm

play05:43

not going to do that we're going to

play05:45

close and I'm just going to use my my

play05:48

actual perplexity

play05:49

authorization okay next we are going to

play05:53

send some headers like I showed you so

play05:55

we're going to come here we're going to

play05:57

go here and we're going to grab

play06:01

accept come here paste in that first

play06:05

name come back and grab Json

play06:10

application paste that in add another

play06:13

parameter same value right

play06:16

there and content type right

play06:20

here boom okay and then we're going to

play06:24

select send

play06:26

body and we're going to be sending

play06:30

Json and specify body type is going to

play06:33

be using

play06:35

Json and then we're just going to come

play06:37

to Json here and you could just copy

play06:40

this so if you make changes over on this

play06:42

side like if I added a top P right here

play06:45

um maximum is one if I added a top P you

play06:49

can see that it actually shows over here

play06:52

but I'm not going to do any of that you

play06:53

could play around and add different

play06:55

stuff here and it's going to show up

play06:57

over here in the Json we're just going

play07:00

to copy

play07:02

this and we're going to come over here

play07:06

and paste this into the

play07:08

body like so now a few different things

play07:11

you could change the model and if you go

play07:14

over into the API docs and then you

play07:17

click on guides and click on supported

play07:19

models you'll see the supported models

play07:21

so we got the perplexity models like

play07:24

llama 3 sonar small 32k chat 32k online

play07:30

32k and then the 7 billion parameter so

play07:33

we have a 70 billion parameter and the 8

play07:35

billion parameter um

play07:37

32k and online and chat so we'll go

play07:41

ahead if I'm not already using this one

play07:43

we'll use this the biggest

play07:48

parameter yeah so we'll use the large

play07:50

parameter and the online so online

play07:53

allows it of course so you can um you

play07:56

leverage search you this will be really

play07:57

good for research sh research builds and

play08:00

stuff like that which I'll show you more

play08:02

um in the future on this channel so make

play08:03

sure to subscribe to stay tuned for

play08:05

those builds um and then there are open

play08:08

source models too so if you want to use

play08:10

these hugging face ones like llama

play08:12

38b instruct 7 uh 370b instruct and

play08:18

87b instruct contacts lengths show right

play08:22

here all right so I guess for the online

play08:25

for this one so actually it's not that

play08:27

bad so the online does have a bit

play08:29

smaller contacts length but not that bad

play08:33

and let's just see rate limits you can

play08:35

check out some of these uh more

play08:38

information here about rate

play08:40

limits we got right here as well as

play08:44

pricing so you can see the different

play08:47

pricing here we're at the large so we're

play08:51

the same as the small five bucks per

play08:54

thousand uh requests so pretty solid

play08:58

pricing and this allows you of course

play09:00

like I said to do online searching

play09:02

through the API which is useful you

play09:05

can't really do this uh at this quality

play09:07

of you know uh research with things like

play09:09

chat GPT a through the API and

play09:12

perplexity is just the best I've seen

play09:14

for researching in general right so here

play09:17

we could set you could set as many as

play09:19

you want we're going to set you know you

play09:20

can set your system role and your your

play09:23

message this one for example is just be

play09:25

precise and con uh precise and concise

play09:28

and then role user how many stars are

play09:31

there in the galaxy we could change this

play09:33

to like

play09:35

um what

play09:38

is

play09:39

um something

play09:43

interesting that

play09:45

happened

play09:47

yesterday in the news so this will show

play09:51

and um tell me

play09:55

what date and time it

play10:00

happened with sources so let's see how

play10:03

this does so we're just basically

play10:06

telling it to be precise and concise

play10:08

asking this question and we want it to

play10:10

return citations and images so let's go

play10:12

ahead and test

play10:14

this executing so we got it back let's

play10:18

check it out um yesterday on June 21st

play10:23

2024 Taylor Swift reunited with Prince

play10:26

William at the era tour in London

play10:30

all right

play10:33

um

play10:35

okay one thing I'm curious about is

play10:37

where we would actually see the

play10:41

citations and

play10:43

the okay so I just searched perplexity

play10:45

can I access citations and images when

play10:47

accessing the perplexity API So

play10:49

currently citations and images through

play10:51

perplexity API is limited and not fully

play10:52

available to all users here are some key

play10:55

points uh regarding these features close

play10:57

beta so basically it's saying is close

play10:59

en Clos beta uh users interested in this

play11:02

feature need to apply for Access by

play11:04

filling in a form and describing their

play11:05

use

play11:07

case yeah so essentially unless you know

play11:10

unless it's been recently updated unless

play11:12

this is wrong guess you can't access the

play11:15

citations and images yet even though it

play11:18

says that here I guess it's just CU it's

play11:20

in beta um oh yeah if you if if I if

play11:25

maybe if you're watching this in the

play11:26

future you can at this point or maybe

play11:29

I'm just missing something here so if

play11:30

you if I am let me know in the comments

play11:31

down below but from what I see here as

play11:34

well as what perplexity is saying um

play11:36

it's saying that you can't do it yet

play11:37

unless you're in the beta program which

play11:39

I think would be nice I may even apply

play11:41

through that form to see if I can get

play11:43

access to the citations because I like

play11:46

knowing where this information comes

play11:48

from uh I like to fact check if I'm

play11:50

leveraging things as well as to like uh

play11:53

just nice to know um in general but

play11:56

either way this is a lot better than

play11:58

when you're doing re research um than

play12:00

just using the open AI API because you

play12:02

can get live data accurate data and um

play12:06

really good stuff so other than that

play12:07

guys I hope you got some value from this

play12:09

video if you did make sure to drop a

play12:10

like below and if you're new to this

play12:11

channel make sure to subscribe we upload

play12:13

videos every single day on AI news AI

play12:16

tutorials how to leverage automation

play12:18

make.com

play12:20

n excuse me go highle marketing Etc how

play12:24

to grow your business and also too if

play12:26

you haven't already joined our free stri

play12:28

community sh community.com link for that

play12:31

will be down below we have about 750

play12:33

members I believe in our Facebook and

play12:35

Discord channel so Facebook group and

play12:38

then also to guys check out my book

play12:39

client acquisition code it's an in-depth

play12:41

book showing you how to get clients

play12:43

leveraging AI for your business if

play12:45

you're in B2B if you're uh AI Enthusiast

play12:48

uh entrepreneur Etc marketing agency

play12:50

coach consultant definitely want to

play12:52

check out that book link for that will

play12:53

be in down below other than that guys I

play12:55

will see you in tomorrow's video keep

play12:57

hustling keep grinding and of course

play12:59

accelerate your stride take care

Rate This

5.0 / 5 (0 votes)

Ähnliche Tags
AI Integrationn8n ModulesAutomation GuideAPI TutorialPerplexity APIResearch ToolWorkflow AutomationTech TutorialInnovative TechAPI Key SetupJSON Request
Benötigen Sie eine Zusammenfassung auf Englisch?