Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 41 additions & 2 deletions apps/docs/content/docs/integrations/perplexity.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Perplexity
description: Use Perplexity AI for chat and search
description: Use Perplexity AI for chat, search and agent runs
integration:
type: "perplexity"
color: "#20808D"
Expand All @@ -15,7 +15,7 @@ Use [Perplexity](https://www.perplexity.ai) to generate chat responses with web

## Use the block [#usage-instructions]

Generate completions using Perplexity AI chat models or perform web searches with advanced filtering.
Generate completions using Perplexity AI chat models, perform web searches with advanced filtering, or run Perplexity and third-party models with built-in web search and URL fetch through the Agent API.

## Actions

Expand Down Expand Up @@ -82,4 +82,43 @@ Get ranked search results from Perplexity's continuously refreshed index with ad

</ReferenceDetails>

### Perplexity Agent

Run a Perplexity or third-party model through the Perplexity Agent API with built-in web search and URL fetch, returning the answer, its sources and usage

<ReferenceDetails>

#### Input

| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `content` | string | Yes | The question or task for the agent |
| `model` | string | Yes | Agent API model \(e.g., "anthropic/claude-opus-5-5", "openai/gpt-5.5"\) |
| `systemPrompt` | string | No | Instructions that guide the agent behavior |
| `web_search` | boolean | No | Let the agent search the web \(default: true\) |
| `fetch_url` | boolean | No | Let the agent fetch the full content of URLs \(default: false\) |
| `max_steps` | number | No | Maximum number of agent steps, including tool calls \(e.g., 3\) |
| `max_tokens` | number | No | Maximum number of output tokens to generate \(e.g., 1024, 4096\) |
| `apiKey` | string | Yes | Perplexity API key |

#### Output

| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `content` | string | The answer produced by the agent |
| `model` | string | Model used for the run |
| `status` | string | Final status of the run \(completed, or incomplete when a limit was reached\) |
| `sources` | array | Web search results the agent used |
| ↳ `title` | string | Title of the source |
| ↳ `url` | string | URL of the source |
| ↳ `snippet` | string | Excerpt of the source content |
| ↳ `date` | string | Publication date of the source |
| ↳ `last_updated` | string | Date the page was last updated in Perplexity's index |
| `usage` | object | Token usage information |
| ↳ `input_tokens` | number | Number of input tokens |
| ↳ `output_tokens` | number | Number of output tokens |
| ↳ `total_tokens` | number | Total number of tokens used |

</ReferenceDetails>


81 changes: 74 additions & 7 deletions apps/sim/blocks/blocks/perplexity.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { PerplexityIcon } from '@/components/icons'
import { AuthMode, type BlockConfig, type BlockMeta, IntegrationType } from '@/blocks/types'
import { mapperOperation } from '@/blocks/utils'
import { mapperOperation, toolCallArg } from '@/blocks/utils'

export const PerplexityBlock: BlockConfig = {
type: 'perplexity',
name: 'Perplexity',
description: 'Use Perplexity AI for chat and search',
description: 'Use Perplexity AI for chat, search and agent runs',
longDescription:
'Generate completions using Perplexity AI chat models or perform web searches with advanced filtering.',
'Generate completions using Perplexity AI chat models, perform web searches with advanced filtering, or run Perplexity and third-party models with built-in web search and URL fetch through the Agent API.',
authMode: AuthMode.ApiKey,
docsLink: 'https://docs.sim.ai/integrations/perplexity',
category: 'tools',
Expand All @@ -23,6 +23,10 @@ export const PerplexityBlock: BlockConfig = {
{ text: 'Answer', field: 'content', core: true },
{ text: 'using', field: 'model' },
],
perplexity_agent: [
{ text: 'Research the web for', field: 'content', core: true },
{ text: 'using', field: 'agentModel' },
],
perplexity_search: [
{ text: 'Search the web for', field: 'query', core: true },
{ text: 'within', field: 'search_domain_filter' },
Expand All @@ -39,6 +43,7 @@ export const PerplexityBlock: BlockConfig = {
options: [
{ label: 'Chat', id: 'perplexity_chat' },
{ label: 'Search', id: 'perplexity_search' },
{ label: 'Agent', id: 'perplexity_agent' },
],
value: () => 'perplexity_chat',
},
Expand All @@ -48,15 +53,15 @@ export const PerplexityBlock: BlockConfig = {
title: 'System Prompt',
type: 'long-input',
placeholder: 'System prompt to guide the model behavior...',
condition: { field: 'operation', value: 'perplexity_chat' },
condition: { field: 'operation', value: ['perplexity_chat', 'perplexity_agent'] },
},
{
id: 'content',
title: 'User Prompt',
type: 'long-input',
placeholder: 'Enter your prompt here...',
required: true,
condition: { field: 'operation', value: 'perplexity_chat' },
condition: { field: 'operation', value: ['perplexity_chat', 'perplexity_agent'] },
},
{
id: 'model',
Expand Down Expand Up @@ -85,7 +90,44 @@ export const PerplexityBlock: BlockConfig = {
title: 'Max Tokens',
type: 'short-input',
placeholder: 'Maximum number of tokens',
condition: { field: 'operation', value: 'perplexity_chat' },
condition: { field: 'operation', value: ['perplexity_chat', 'perplexity_agent'] },
},
// Agent operation inputs
{
id: 'agentModel',
title: 'Model',
type: 'combobox',
placeholder: 'Type or select a model...',
options: [
{ label: 'Claude Opus 5.5', id: 'anthropic/claude-opus-5-5' },
{ label: 'GPT-5.5', id: 'openai/gpt-5.5' },
],
value: () => 'anthropic/claude-opus-5-5',
required: true,
condition: { field: 'operation', value: 'perplexity_agent' },
},
{
id: 'web_search',
title: 'Web Search',
type: 'switch',
defaultValue: true,
condition: { field: 'operation', value: 'perplexity_agent' },
},
{
id: 'fetch_url',
title: 'Fetch URLs',
type: 'switch',
description: 'Let the agent read the full content of URLs',
condition: { field: 'operation', value: 'perplexity_agent' },
mode: 'advanced',
},
{
id: 'max_steps',
title: 'Max Steps',
type: 'short-input',
placeholder: '3',
condition: { field: 'operation', value: 'perplexity_agent' },
mode: 'advanced',
},
// Search operation inputs
{
Expand Down Expand Up @@ -191,14 +233,16 @@ Return ONLY the date string in MM/DD/YYYY format - no explanations, no quotes, n
},
],
tools: {
access: ['perplexity_chat', 'perplexity_search'],
access: ['perplexity_chat', 'perplexity_search', 'perplexity_agent'],
config: {
tool: (params) => {
switch (params.operation) {
case 'perplexity_chat':
return 'perplexity_chat'
case 'perplexity_search':
return 'perplexity_search'
case 'perplexity_agent':
return 'perplexity_agent'
default:
return 'perplexity_chat'
}
Expand Down Expand Up @@ -231,6 +275,21 @@ Return ONLY the date string in MM/DD/YYYY format - no explanations, no quotes, n
return searchParams
}

if (mapperOperation(params, context) === 'perplexity_agent') {
const maxSteps = params.max_steps ? Number.parseInt(params.max_steps) : undefined
const maxTokens = params.max_tokens ? Number.parseInt(params.max_tokens) : undefined
return {
apiKey: params.apiKey,
model: params.agentModel ?? toolCallArg(context, params.model),
content: params.content,
systemPrompt: params.systemPrompt,
web_search: params.web_search,
fetch_url: params.fetch_url,
max_steps: Number.isFinite(maxSteps) ? maxSteps : undefined,
max_tokens: Number.isFinite(maxTokens) ? maxTokens : undefined,
}
}

// Chat params (default)
const chatParams = {
apiKey: params.apiKey,
Expand Down Expand Up @@ -267,6 +326,11 @@ Return ONLY the date string in MM/DD/YYYY format - no explanations, no quotes, n
search_recency_filter: { type: 'string', description: 'Recency filter' },
search_after_date: { type: 'string', description: 'After date filter' },
search_before_date: { type: 'string', description: 'Before date filter' },
// Agent operation inputs
agentModel: { type: 'string', description: 'Agent API model' },
web_search: { type: 'boolean', description: 'Enable web search' },
fetch_url: { type: 'boolean', description: 'Enable URL fetch' },
max_steps: { type: 'string', description: 'Maximum agent steps' },
// Common
apiKey: { type: 'string', description: 'Perplexity API key' },
},
Expand All @@ -277,6 +341,9 @@ Return ONLY the date string in MM/DD/YYYY format - no explanations, no quotes, n
usage: { type: 'json', description: 'Token usage' },
// Search outputs
results: { type: 'json', description: 'Search results array' },
// Agent outputs
status: { type: 'string', description: 'Agent run status' },
sources: { type: 'json', description: 'Web sources the agent used' },
},
}

Expand Down
2 changes: 1 addition & 1 deletion apps/sim/tools/generated/tool-ids.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/sim/tools/generated/tool-metadata.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/sim/tools/generated/tool-outputs.ts

Large diffs are not rendered by default.

Loading