Perplexity icon

Perplexity

Interact with Perplexity AI API for search-grounded AI responses

Overview

This node integrates with the Perplexity AI API to generate chat completions based on user-provided messages and parameters. It is designed to produce search-grounded AI responses, leveraging various models optimized for different research and reasoning tasks. The node supports multimodal inputs including text and images, allowing rich conversational contexts.

Common scenarios where this node is beneficial include:

  • Conducting deep research or expert-level information synthesis.
  • Generating reasoned answers with chain-of-thought explanations.
  • Performing advanced search queries with grounding in external data.
  • Creating interactive chatbots that can handle text and image inputs.
  • Producing structured or formatted AI-generated content using JSON schema or regex constraints.

Practical example: A user wants to ask a complex question about climate change and receive a detailed, well-reasoned answer supported by recent academic sources and relevant images. They select the "Sonar Deep Research" model, provide their query as a user message, and optionally include images to illustrate the context. The node returns a comprehensive, grounded response.

Properties

Name Meaning
Model The AI model to use for generating the completion. Options include:
- Sonar Deep Research (expert-level research)
- Sonar Reasoning Pro (advanced reasoning with chain of thought)
- Sonar Pro (advanced search grounding)
- Sonar (lightweight, faster)
- R1-1776 (uncensored, factual)
Messages The conversation messages to generate a completion for. Each message includes:
- Role (System, User, Assistant)
- Content type (Text only or Text with Images)
- Text content
- Optional images (via HTTPS URL or base64), with format and type specified
Additional Options Various parameters controlling generation behavior:
- Frequency Penalty (penalizes repeated tokens)
- Max Tokens (max length of output)
- Presence Penalty (penalizes new tokens based on presence)
- Stream (stream partial results)
- Temperature (randomness control)
- Top P (nucleus sampling diversity)
Response Format Constraints on the response format:
- Type (Text, JSON Schema, Regex)
- JSON Schema (for structured output)
- Regex Pattern (to match output format)
Search Filters Filters to refine search grounding:
- Date Range Start/End
- Search Context Size (Concise or Detailed)
- Search Domain Filter (Academic, Reddit, YouTube, etc.)
- Search Recency Filter (Hour, Day, Week, Month)
- User Location (for localized results)
Image Options Controls inclusion and filtering of images in search results and responses:
- Include Images (boolean)
- Image Filter (All, Photos, Graphics, Clipart)
- Image Size Filter (All, Small, Medium, Large)

Output

The node outputs a JSON object representing the AI-generated chat completion. The structure typically includes:

  • json: The main field containing the completion result, which may be plain text or structured data depending on the response format selected.
  • If images are included in the response, they appear as URLs or base64-encoded data embedded within the content array.
  • Binary data output is not explicitly indicated; image data is handled as base64 strings or URLs within the JSON content.

Dependencies

  • Requires an API key credential for authenticating with the Perplexity AI API.
  • Network access to https://api.perplexity.ai endpoint.
  • No other external dependencies are indicated.

Troubleshooting

  • Common issues:

    • Invalid or missing API key will cause authentication errors.
    • Providing improperly formatted messages or images (e.g., invalid base64 data or broken URLs) may lead to request failures.
    • Exceeding token limits or setting incompatible parameter values might cause errors or truncated responses.
    • Using unsupported response formats without proper schema or regex may result in validation errors.
  • Error messages and resolutions:

    • Authentication failed: Verify that the API key credential is correctly configured and valid.
    • Invalid request body: Check message formatting, especially the structure of multimodal content and required fields.
    • Rate limit exceeded: Reduce request frequency or upgrade API plan if applicable.
    • Response validation error: Ensure JSON schema or regex patterns are correctly defined and match expected output.

Links and References

Discussion