perplexity

n8n node for Perplexity AI API integration

Package Information

Released: 6/16/2025
Downloads: 96 weekly / 348 monthly
Latest Version: 0.2.0
Author: kungfu321

Documentation

Banner image

n8n-nodes-perplexity

This is an n8n community node that integrates with the Perplexity AI API. It allows you to use Perplexity's search-grounded AI models in your n8n workflows.

Perplexity AI provides real-time search-grounded AI responses using various models including Sonar, Sonar Pro, and specialized research models.

Installation

Follow the installation guide in the n8n community nodes documentation.

Community Nodes (Recommended)

  1. Go to Settings > Community Nodes.
  2. Select Install.
  3. Enter n8n-nodes-perplexity in Enter npm package name.
  4. Agree to the risks of using community nodes: select I understand the risks of installing unverified code from a public source.
  5. Select Install.

After installing the node, you can use it like any other node in your workflows.

Manual Installation

To get started install the package in your n8n root directory:

npm install n8n-nodes-perplexity

For Docker-based deployments add the following line before the font installation command in your n8n Dockerfile:

RUN cd /usr/local/lib/node_modules/n8n && npm install n8n-nodes-perplexity

Credentials

You need to configure Perplexity API credentials to use this node:

  1. Create a new credential of type Perplexity API
  2. Enter your Perplexity API key

Supported Operations

Chat Completion

Generate AI responses using Perplexity's search-grounded models.

Available Models

  • Sonar Deep Research (sonar-deep-research): Comprehensive, expert-level research with detailed reports
  • Sonar Reasoning Pro (sonar-reasoning-pro): Premier reasoning with Chain of Thought powered by DeepSeek R1
  • Sonar Pro (sonar-pro): Premier search offering with advanced query support
  • Sonar (sonar): Lightweight and cost-effective search-grounded responses
  • R1-1776 (r1-1776): Uncensored, unbiased version of DeepSeek R1

Parameters

Required:

  • Model: Choose from available Perplexity models
  • Messages: Array of conversation messages with roles (system, user, assistant)
    • Text Only: Simple text messages
    • Multi-modal: Text with images (base64 or HTTPS URLs)

Optional:

  • Max Tokens: Maximum number of tokens to generate (default: 1000)
  • Temperature: Controls randomness (0-2, default: 0.7)
  • Top P: Controls diversity via nucleus sampling (0-1, default: 1)
  • Stream: Enable streaming responses (default: false)
  • Presence Penalty: Penalize new tokens based on presence (-2 to 2, default: 0)
  • Frequency Penalty: Penalize tokens based on frequency (-2 to 2, default: 0)
  • Search Filters: Domain filtering, date ranges, user location, context size
  • Image Options: Include images, filter by type and size

Response Format

Configure structured output formats:

  • Text: Default text response
  • JSON Schema: Structured JSON output with schema validation
  • Regex: Output matching a specific regex pattern

Usage Examples

Basic Chat Completion

{
  "model": "sonar-pro",
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful AI assistant."
    },
    {
      "role": "user", 
      "content": "What are the latest developments in AI?"
    }
  ]
}

Research Query

{
  "model": "sonar-deep-research",
  "messages": [
    {
      "role": "user",
      "content": "Provide a comprehensive analysis of renewable energy trends in 2024"
    }
  ],
  "max_tokens": 2000
}

Structured JSON Output

{
  "model": "sonar",
  "messages": [
    {
      "role": "user",
      "content": "Extract key information about Apple Inc."
    }
  ],
  "response_format": {
    "type": "json_schema",
    "json_schema": {
      "schema": {
        "type": "object",
        "properties": {
          "company_name": {"type": "string"},
          "founded": {"type": "string"},
          "headquarters": {"type": "string"},
          "ceo": {"type": "string"}
        }
      }
    }
  }
}

Advanced Search with Filters

{
  "model": "sonar-pro",
  "messages": [
    {
      "role": "user",
      "content": "What are the latest AI research papers on transformer models?"
    }
  ],
  "searchFilters": {
    "search_domain_filter": ["academic"],
    "search_recency_filter": "week",
    "search_context_size": "detailed"
  },
  "imageOptions": {
    "include_images": true,
    "image_filter": "graphics"
  }
}

Multi-modal with Images

{
  "model": "sonar-pro",
  "messages": [
    {
      "role": "user",
      "contentType": "multimodal",
      "textContent": "Can you describe this image and tell me what you see?",
      "images": {
        "imageValues": [
          {
            "imageType": "url",
            "imageUrl": "https://example.com/path/to/image.jpg"
          }
        ]
      }
    }
  ]
}

Base64 Image Upload

{
  "model": "sonar-pro",
  "messages": [
    {
      "role": "user",
      "contentType": "multimodal",
      "textContent": "Analyze this screenshot for any issues",
      "images": {
        "imageValues": [
          {
            "imageType": "base64",
            "imageFormat": "png",
            "base64Data": "iVBORw0KGgoAAAANSUhEUgAA..."
          }
        ]
      }
    }
  ]
}

Features

  • ✅ Full Perplexity API support
  • ✅ All available models (Sonar, Sonar Pro, Deep Research, R1-1776)
  • ✅ Conversation history with multiple message roles
  • ✅ Advanced parameters (temperature, top_p, penalties)
  • ✅ Structured output formats (JSON Schema, Regex)
  • ✅ Streaming support
  • ✅ Search domain filtering (Academic, YouTube, Reddit, Wolfram Alpha, etc.)
  • ✅ Date range and recency filtering
  • ✅ User location-based search
  • ✅ Search context size control
  • ✅ Image search and filtering options
  • ✅ Multi-modal support (text + images)
  • ✅ Base64 image upload (PNG, JPEG, WEBP, GIF up to 5MB)
  • ✅ HTTPS URL image references
  • ✅ Built-in credential testing
  • ✅ Comprehensive error handling

API Reference

This node is built according to the Perplexity API documentation. For detailed API information, visit:

Important Notes

Image Upload Limitations

  • Base64 images: Maximum 5MB per image
  • Supported formats: PNG, JPEG, WEBP, GIF
  • HTTPS URLs: Must be publicly accessible and point directly to image files
  • Model compatibility: sonar-deep-research does not support image input
  • Structured outputs: Image and regex cannot be used together in the same request

Search Filters

  • Domain filters work with all Sonar models
  • Academic filter provides research-focused results
  • Date range filters help find recent or historical information
  • User location enables localized search results

Compatibility

  • n8n version: 1.0.0+
  • Node.js version: 20.15+

Resources

License

MIT

Discussion