# Perplexity Search

**Action ID:** `perplexity_search`

## Description

Search the web and get AI-powered answers using Perplexity's advanced search models. This node provides real-time information retrieval combined with AI reasoning to deliver accurate, cited answers to your queries.

## Provider

**Perplexity**

## Connection

| Name                  | Description                                      | Required | Category   |
| --------------------- | ------------------------------------------------ | :------: | ---------- |
| Perplexity Connection | The Perplexity connection to use for the search. |     ✓    | perplexity |

## Input Parameters

| Name        | Type   | Required | Default | Description                                                                                                                                |
| ----------- | ------ | :------: | ------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| prompt      | string |     ✓    | -       | The prompt to send to Perplexity                                                                                                           |
| model       | string |     -    | sonar   | The model to use for chat completion. Available options: sonar, sonar-pro                                                                  |
| temperature | number |     -    | 0.7     | Controls randomness in the response. Higher values make the output more random, lower values make it more deterministic. Range: 0.0 to 1.0 |

<details>

<summary>View JSON Schema</summary>

```json
{
  "description": "Perplexity search node input.",
  "properties": {
    "prompt": {
      "title": "Prompt",
      "type": "string",
      "description": "The prompt to send to Perplexity."
    },
    "model": {
      "title": "Model",
      "type": "string",
      "enum": ["sonar", "sonar-pro"],
      "default": "sonar",
      "description": "The model to use for chat completion."
    },
    "temperature": {
      "title": "Temperature",
      "type": "number",
      "default": 0.7,
      "minimum": 0.0,
      "maximum": 1.0,
      "description": "Controls randomness in the response. Higher values make the output more random, lower values make it more deterministic."
    }
  },
  "required": [
    "prompt"
  ],
  "title": "PerplexitySearchInput",
  "type": "object"
}
```

</details>

## Output Parameters

| Name     | Type | Description                  |
| -------- | ---- | ---------------------------- |
| response | any  | The response from Perplexity |

<details>

<summary>View JSON Schema</summary>

```json
{
  "description": "Perplexity search node output.",
  "properties": {
    "response": {
      "title": "Response",
      "description": "The response from Perplexity."
    }
  },
  "required": [
    "response"
  ],
  "title": "PerplexitySearchOutput",
  "type": "object"
}
```

</details>

## How It Works

This node sends your prompt to Perplexity's AI search service, which searches the web in real-time for relevant information and processes it through advanced language models to generate accurate, cited answers. The response includes both the AI-generated answer and citations to source materials.

## Usage Examples

### Example 1: Current Events Search

**Input:**

```
prompt: "What are the latest developments in artificial intelligence?"
model: "sonar"
temperature: 0.5
```

**Output:**

```
response: {
  "answer": "Recent developments in AI include...",
  "citations": [
    {"title": "Latest AI Breakthroughs", "url": "https://example.com/ai-news"},
    {"title": "AI Research Updates", "url": "https://example.com/research"}
  ]
}
```

### Example 2: Technical Question with Pro Model

**Input:**

```
prompt: "How do I implement OAuth 2.0 authentication in Python?"
model: "sonar-pro"
temperature: 0.3
```

**Output:**

```
response: {
  "answer": "OAuth 2.0 implementation steps:\n1. Install required libraries...",
  "code_examples": [
    {"language": "python", "code": "..."}
  ],
  "citations": [
    {"title": "OAuth 2.0 Documentation", "url": "https://example.com/oauth"}
  ]
}
```

### Example 3: Product Research

**Input:**

```
prompt: "Compare the best laptop models available in 2024 for programming"
model: "sonar"
temperature: 0.6
```

**Output:**

```
response: {
  "answer": "Top programming laptops in 2024:\n1. MacBook Pro...",
  "comparisons": [
    {"model": "MacBook Pro", "specs": {...}, "price": "$1999"},
    {"model": "ThinkPad", "specs": {...}, "price": "$1299"}
  ],
  "citations": [
    {"title": "Best Laptops 2024", "url": "https://example.com/reviews"}
  ]
}
```

## Common Use Cases

* **Research Assistance**: Get comprehensive, cited answers to research questions
* **Current Events Awareness**: Stay updated on breaking news and latest developments
* **Technical Documentation**: Find and summarize technical solutions and best practices
* **Product Research**: Compare products and gather pricing and specification information
* **Market Intelligence**: Research competitor products and industry trends
* **Academic Research**: Find scholarly articles and research papers on specific topics
* **Real-time Data**: Get current information that may not be available in training data

## Error Handling

| Error Type           | Cause                                                       | Solution                                                 |
| -------------------- | ----------------------------------------------------------- | -------------------------------------------------------- |
| Authentication Error | Invalid or missing Perplexity API key                       | Verify your Perplexity connection is properly configured |
| Invalid Model        | Model name doesn't exist or access not granted              | Use only 'sonar' or 'sonar-pro' models                   |
| Network Error        | Cannot reach Perplexity servers or search the web           | Check internet connection and Perplexity service status  |
| Rate Limit Exceeded  | Too many requests in a short period                         | Implement delays between requests or upgrade your plan   |
| Empty Response       | Search returned no results or answer could not be generated | Rephrase the prompt to be more specific                  |
| Timeout              | Request took too long to process                            | Simplify the prompt or try again with reduced complexity |

## Notes

* **Model Selection**: Choose 'sonar' for standard searches and 'sonar-pro' for more complex analysis requiring deep reasoning.
* **Temperature Control**: Lower temperature (0.0-0.3) for factual, deterministic responses. Higher temperature (0.7-1.0) for more creative exploration.
* **Citations**: Perplexity includes source citations for transparency and fact-checking.
* **Real-time Search**: This node searches the current web, so it provides up-to-date information beyond training data cutoffs.
* **Specific Prompts**: More specific and detailed prompts yield better results. Include context and any constraints.
* **Cost Optimization**: The standard 'sonar' model is cost-effective for most searches. Reserve 'sonar-pro' for complex queries.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.agenticflow.ai/reference/nodes/perplexity_search.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
