Access Perplexity API In n8n To Scrape Live Website Data Through HTTP Request Authorization 🤖
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
🤖 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.
🔗 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.
🔍 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
💡Perplexity API
💡HTTP request
💡API key
💡JSON
💡Automation sequences
💡Research builds
💡Rate limits
💡Pricing tier
💡Citations
💡Images
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
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
Browse More Related Video
Automating Has NEVER BEEN Easier - No code and Low Code Tools Every Business Owner Should Use (2024)
Perplexica: How to Install this Free AI Search Engine, Locally?
Notion and iOS Shortcuts - Add Item To Database using the API
AutoGen Studio Tutorial - NO CODE AI Agent Builder (100% Local)
Learn 80% of Perplexity in under 10 minutes!
Adding JWT Authentication & Authorization in ASP.NET Core
5.0 / 5 (0 votes)