How to Connect n8n to Perplexity AI
Learn how to connect n8n with Perplexity AI by generating an API key and using the Perplexity node to query language models in your workflows.
How to Connect n8n to Perplexity AI
Integrating Perplexity AI into your n8n workflows allows you to leverage its powerful, search-augmented language models. This tutorial will show you how to get a Perplexity API key and use the official n8n node to send queries and receive structured JSON responses.
Prerequisites
- An n8n workflow (a manual trigger is fine for testing).
- A Perplexity AI account.
- You must add billing information and credits to your Perplexity account to use the API.
Step 1: Get Your Perplexity API Key
To connect n8n to Perplexity, you first need to generate an API key from your account settings.
- Log in to your Perplexity AI account.
- Navigate directly to your account's API settings page: perplexity.ai/account/api.
- Before generating a key, you must add funds to your account. The API is a paid service, so add a small amount (e.g., $5) to get started.
- Once you have added credits, go to the "API Keys" section.
- Click "Generate" to create a new key. Give it a descriptive name, like
n8n-api-key. - Copy the generated key immediately. For security reasons, Perplexity will not show you the key again.
⚠️ Important: Treat your API key like a password. Do not share it publicly.
Step 2: Add and Configure the Perplexity Node in n8n
Now, you can add the Perplexity node to your workflow and configure it with your API key.
- In your n8n workflow, add a new node and search for "Perplexity". Select the official node.
- The only action available is "Message a Model", which should be selected by default.
- In the "Credential" field, select "Create New".
- A dialog will appear asking for an "API Key".
- Paste the API key you copied from your Perplexity account settings.
- Click "Save".
Step 3: Send a Test Message
With the credential configured, you can now test the connection by sending a prompt to a model.
- In the Perplexity node settings:
- Model: Select a model to use. The
sonarmodels are generally faster and more cost-effective for general tasks. - Message > Content: Enter the prompt you want to send. For example:
What is the current weather in Sydney, Australia?
- Model: Select a model to use. The
- Leave the other options as default.
- Click "Execute Node".
If the connection is successful, the node will execute and return a JSON object. This object contains the model's response, citations, and the search results it used to generate the answer, which you can use in subsequent nodes in your workflow.