# Perplexity AI

Perplexity AI provides conversational AI models for generating human-like text responses

- **Category:** artificial intelligence
- **Auth:** API_KEY
- **Composio Managed App Available?** N/A
- **Tools:** 6
- **Triggers:** 0
- **Slug:** `PERPLEXITYAI`
- **Version:** 20260323_00

## Tools

### Create Async Chat Completion

**Slug:** `PERPLEXITYAI_CREATE_ASYNC_CHAT_COMPLETION`

Create an async chat completion request. Same as /chat/completions but designed for long-running tasks like sonar-deep-research. Returns immediately with a request_id that can be used to poll for results. Async jobs have a 7-day TTL. Use this action when you need to run resource-intensive queries that take longer than typical synchronous requests. The response includes a request ID that can be used to retrieve results later.

#### Input Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `request` | object | Yes | Chat completion request object with model and messages |
| `idempotency_key` | string | No | Optional key to ensure idempotent requests |

#### Output

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `data` | string | Yes | Data from the action execution |
| `error` | string | No | Error if any occurred during the execution of the action |
| `successful` | boolean | Yes | Whether or not the action execution was successful or not |

### Create Chat Completion

**Slug:** `PERPLEXITYAI_CREATE_CHAT_COMPLETION`

Perplexity AI Chat Completions endpoint using Sonar models. Provides web-grounded conversational AI responses with optional citations. The model searches the web to provide accurate, up-to-date answers with sources. Supports various models optimized for different use cases: - sonar: Fast, cost-effective for simple queries - sonar-pro: Enhanced quality for complex questions - sonar-reasoning-pro: Advanced reasoning capabilities Features include: - Web search grounding for accurate, current information - Citations showing sources for claims - Streaming responses for real-time interaction - Configurable temperature, top_p, and other generation parameters Note: presence_penalty and frequency_penalty cannot be used simultaneously.

#### Input Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `model` | string ("sonar" | "sonar-pro" | "sonar-reasoning-pro" | "sonar-reasoning" | "llama-3.1-sonar-small-128k-online" | "llama-3.1-sonar-large-128k-online" | "llama-3.1-sonar-small-128k-chat" | "llama-3.1-sonar-large-128k-chat") | No | The name of the model to use for generating completions. Options include sonar, sonar-pro, sonar-reasoning-pro, and more. For more information see https://docs.perplexity.ai/guides/model-cards |
| `top_k` | integer | No | Limits the number of highest-probability tokens to consider for generation. Set to 0 to disable. |
| `top_p` | number | No | Nucleus sampling threshold. Controls the cumulative probability of tokens to sample from. Lower values restrict to higher probability tokens, higher values allow more diversity. |
| `stream` | boolean | No | Whether to stream the response incrementally using server-sent events. When true, the response is streamed as delta chunks. |
| `messages` | array | Yes | A list of messages comprising the conversation. Each message must have a role (system, user, or assistant) and content. The conversation typically starts with a system message (optional), followed by alternating user and assistant messages. |
| `max_tokens` | integer | No | The maximum number of tokens to generate. Sum of max_tokens and prompt tokens should not exceed the model's context window limit. If unspecified, generation continues until stop token or context window end. |
| `temperature` | number | No | Controls generation randomness. Lower values (near 0) make output more deterministic, while higher values (near 2) increase randomness. Recommended for factual tasks: 0-0.3. For creative tasks: 0.7-1.0. |
| `return_images` | boolean | No | Whether to include images in the model's response. Image feature is in closed beta. |
| `presence_penalty` | number | No | Penalty for new tokens based on whether they appear in the text. Positive values encourage topic variety. Mutually exclusive with frequency_penalty. |
| `return_citations` | boolean | No | Whether to include citations in the model's response. When enabled, citations are provided as sources for the answer. |
| `frequency_penalty` | number | No | Multiplicative penalty for new tokens based on their frequency. Positive values reduce repetition. Mutually exclusive with presence_penalty. |
| `search_context_size` | string | No | The search context size determines how much context is used for search queries. Options: 'small', 'medium', 'large', 'xlarge'. |
| `return_related_questions` | boolean | No | Whether to return related questions at the end of the response. Helps users explore related topics. |

#### Output

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `data` | string | Yes | Data from the action execution |
| `error` | string | No | Error if any occurred during the execution of the action |
| `successful` | boolean | Yes | Whether or not the action execution was successful or not |

### CreateEmbeddings

**Slug:** `PERPLEXITYAI_CREATE_EMBEDDINGS`

Generate vector embeddings for independent texts (queries, sentences, documents). This action takes one or more input texts and generates vector embeddings using Perplexity AI's embedding models. Embeddings are useful for semantic search, similarity matching, and machine learning downstream tasks. Supported models: - pplx-embed-v1-0.6b: Smaller, faster model (1024 dimensions) - pplx-embed-v1-4b: Larger, more accurate model (2560 dimensions) The output embeddings are base64-encoded for efficient transmission. Use the dimensions parameter to reduce embedding size for faster processing when full precision is not required (Matryoshka representation).

#### Input Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `input` | string | Yes | Input text to embed, encoded as a string or array of strings. Maximum 512 texts per request. Each input must not exceed 32K tokens. All inputs in a single request must not exceed 120,000 tokens combined. Empty strings are not allowed. |
| `model` | string ("pplx-embed-v1-0.6b" | "pplx-embed-v1-4b") | Yes | The embedding model to use. pplx-embed-v1-0.6b is smaller and faster, while pplx-embed-v1-4b is larger and more accurate. |
| `dimensions` | integer | No | Number of dimensions for output embeddings (Matryoshka). Range: 128-1024 for pplx-embed-v1-0.6b, 128-2560 for pplx-embed-v1-4b. Defaults to full dimensions (1024 or 2560). |
| `encoding_format` | string ("base64_int8" | "base64_binary") | No | Encoding format for embeddings output. |

#### Output

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `data` | string | Yes | Data from the action execution |
| `error` | string | No | Error if any occurred during the execution of the action |
| `successful` | boolean | Yes | Whether or not the action execution was successful or not |

### Execute Agent

**Slug:** `PERPLEXITYAI_EXECUTE_AGENT`

Agent API - Orchestrates multi-step agentic workflows with built-in tools (web search, URL fetching), reasoning, and multi-model support. Use this action when you need to run complex queries that benefit from automatic web search, URL fetching, and multi-step reasoning. The agent can automatically decide when to use tools and how to synthesize responses. Supports various models including OpenAI models (e.g., gpt-5.2) and Perplexity's sonar models. Configure tools like web_search to enable automatic information gathering.

#### Input Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `input` | string | Yes | The user's input/query to process |
| `model` | string | Yes | Model identifier to use for the agent (e.g., 'openai/gpt-5.2', 'sonar') |
| `tools` | array | No | List of tools to enable. Currently supports web_search with optional filters |
| `preset` | string | No | Preset configuration name (e.g., 'pro-search') |
| `instructions` | string | No | System instructions to guide the agent's behavior |
| `response_format` | object | No | Response format configuration for structured JSON output. |

#### Output

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `data` | string | Yes | Data from the action execution |
| `error` | string | No | Error if any occurred during the execution of the action |
| `successful` | boolean | Yes | Whether or not the action execution was successful or not |

### PerplexityAISearch

**Slug:** `PERPLEXITYAI_PERPLEXITY_AI_SEARCH`

Perplexity Ai Search interfaces with Perplexity AI to perform search queries and return responses from a range of models. This action manages requests to Perplexity AI and processes the resulting completions, which may include text, citations, and images based on selected models and settings. Key features include: Autoprompting to enhance and refine queries, choice of AI models for various content and performance requirements, temperature settings to manage response randomness, Top K and Top P filters to fine-tune response generation. Beta features include citations and images in results, and response streaming for dynamic interaction. Note: The parameters 'presence_penalty' and 'frequency_penalty' are mutually exclusive and cannot be used simultaneously.

#### Input Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `model` | string ("sonar" | "sonar-pro" | "sonar-reasoning-pro") | No | The name of the model to use for generating completions. Choose a model based on the desired balance between performance and resource usage. For more information check https://docs.perplexity.ai/guides/model-cards |
| `top_k` | integer | No | Limits the number of high-probability tokens to consider for generation. Set to 0 to disable. For e.g 0, 40, 80 |
| `top_p` | number | No | Nucleus sampling threshold, controlling the token selection pool based on cumulative probability. For e.g 0.1, 0.9, 1.0 |
| `stream` | boolean | No | Whether to stream the response incrementally using server-sent events.  For e.g True, False |
| `max_tokens` | integer | No | The maximum number of tokens to generate. Sum of max_tokens and prompt tokens should not exceed the model's context window limit. Unspecified leads to generation until stop token or context window end. For e.g 100, 150, 200 |
| `temperature` | number | No | Controls generation randomness, with 0 being deterministic and values approaching 2 being more random. For e.g 0.0, 0.7, 1.5 Use values near 0 for factual or structured tasks; higher values suit creative tasks. |
| `userContent` | string | Yes | The user's Content for asking questions or providing input. For e.g How many stars are there in our galaxy? Do not include sensitive personal data (e.g., contact details, identifiers); restrict to non-sensitive attributes like roles, industries, or skills. |
| `return_images` | boolean | No | Whether to include images in the model's response. Image generation feature is in closed beta. For e.g True, False |
| `systemContent` | string | No | The system's content for specifying instructions to guide the model's behavior. For example: 'Be precise and concise.', 'Be elaborate and descriptive.' If omitted, the default system prompt is used; both systemContent and userContent must be present for a valid request. |
| `presence_penalty` | number | No | Penalty for new tokens based on their current presence in the text, encouraging topic variety. Mutually exclusive with the 'frequency_penalty' parameter. For example: -2.0, 0.0, 2.0. |
| `return_citations` | boolean | No | Whether to include citations in the model's response. Citations feature is in closed beta. For e.g True, False When enabled, the synthesized answer appears in the narrative output while sources are in separate citations/search_results fields — do not conflate the two. |
| `frequency_penalty` | number | No | Multiplicative penalty for new tokens based on their frequency in the text to avoid repetition. Mutually exclusive with the 'presence_penalty' parameter. For example: 0.5, 1.0, 1.5. |

#### Output

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `data` | string | Yes | Data from the action execution |
| `error` | string | No | Error if any occurred during the execution of the action |
| `successful` | boolean | Yes | Whether or not the action execution was successful or not |

### Perplexity Search (Raw Results)

**Slug:** `PERPLEXITYAI_SEARCH`

Search API (Raw Results, No LLM) - Returns ranked web results directly from Perplexity's index without LLM processing. Faster and cheaper when you don't need a generated answer. Use this action when you need raw web search results without AI-generated summaries. Supports advanced filtering by date, domain, language, and geographic location.

#### Input Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `query` | string | Yes | A search query. Can be a single string or a list of strings for multi-query search. |
| `country` | string | No | Country code to filter search results by geographic location. For example: 'US', 'GB', 'DE'. |
| `max_tokens` | integer | No | Maximum total tokens of webpage content returned. Must be between 1 and 1000000. |
| `max_results` | integer | No | Maximum number of search results to return. Must be between 1 and 20. |
| `search_after_date` | string | No | Filter content published after this date. Format: MM/DD/YYYY (e.g., '01/15/2024'). |
| `search_before_date` | string | No | Filter content published before this date. Format: MM/DD/YYYY (e.g., '12/31/2024'). |
| `max_tokens_per_page` | integer | No | Maximum tokens retrieved from each webpage. |
| `search_domain_filter` | array | No | List of domains/URLs to limit search results to. Maximum 20 items. |
| `search_recency_filter` | string ("day" | "week" | "month" | "year") | No | Filter for search recency. |
| `search_language_filter` | array | No | ISO 639-1 language codes to filter results by language. Maximum 10 items (e.g., ['en', 'es', 'fr']). |
| `last_updated_after_filter` | string | No | Filter content last updated after this date. Format: MM/DD/YYYY (e.g., '01/15/2024'). |
| `last_updated_before_filter` | string | No | Filter content last updated before this date. Format: MM/DD/YYYY (e.g., '12/31/2024'). |

#### Output

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `data` | string | Yes | Data from the action execution |
| `error` | string | No | Error if any occurred during the execution of the action |
| `successful` | boolean | Yes | Whether or not the action execution was successful or not |
