Skip to content

Commit be71b07

Browse files
feat(perplexity): add Agent operation backed by the Perplexity Agent API
1 parent 6ee1d0d commit be71b07

12 files changed

Lines changed: 522 additions & 19 deletions

File tree

‎apps/docs/content/docs/integrations/perplexity.mdx‎

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Perplexity
3-
description: Use Perplexity AI for chat and search
3+
description: Use Perplexity AI for chat, search and agent runs
44
integration:
55
type: "perplexity"
66
color: "#20808D"
@@ -15,7 +15,7 @@ Use [Perplexity](https://www.perplexity.ai) to generate chat responses with web
1515

1616
## Use the block [#usage-instructions]
1717

18-
Generate completions using Perplexity AI chat models or perform web searches with advanced filtering.
18+
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.
1919

2020
## Actions
2121

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

8383
</ReferenceDetails>
8484

85+
### Perplexity Agent
86+
87+
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
88+
89+
<ReferenceDetails>
90+
91+
#### Input
92+
93+
| Parameter | Type | Required | Description |
94+
| --------- | ---- | -------- | ----------- |
95+
| `content` | string | Yes | The question or task for the agent |
96+
| `model` | string | Yes | Agent API model \(e.g., "anthropic/claude-opus-5-5", "openai/gpt-5.5"\) |
97+
| `systemPrompt` | string | No | Instructions that guide the agent behavior |
98+
| `web_search` | boolean | No | Let the agent search the web \(default: true\) |
99+
| `fetch_url` | boolean | No | Let the agent fetch the full content of URLs \(default: false\) |
100+
| `max_steps` | number | No | Maximum number of agent steps, including tool calls \(e.g., 3\) |
101+
| `max_tokens` | number | No | Maximum number of output tokens to generate \(e.g., 1024, 4096\) |
102+
| `apiKey` | string | Yes | Perplexity API key |
103+
104+
#### Output
105+
106+
| Parameter | Type | Description |
107+
| --------- | ---- | ----------- |
108+
| `content` | string | The answer produced by the agent |
109+
| `model` | string | Model used for the run |
110+
| `status` | string | Final status of the run \(completed, or incomplete when a limit was reached\) |
111+
| `sources` | array | Web search results the agent used |
112+
| ↳ `title` | string | Title of the source |
113+
| ↳ `url` | string | URL of the source |
114+
| ↳ `snippet` | string | Excerpt of the source content |
115+
| ↳ `date` | string | Publication date of the source |
116+
| ↳ `last_updated` | string | Date the page was last updated in Perplexity's index |
117+
| `usage` | object | Token usage information |
118+
| ↳ `input_tokens` | number | Number of input tokens |
119+
| ↳ `output_tokens` | number | Number of output tokens |
120+
| ↳ `total_tokens` | number | Total number of tokens used |
121+
122+
</ReferenceDetails>
123+
85124

‎apps/sim/blocks/blocks/perplexity.ts‎

Lines changed: 74 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { PerplexityIcon } from '@/components/icons'
22
import { AuthMode, type BlockConfig, type BlockMeta, IntegrationType } from '@/blocks/types'
3-
import { mapperOperation } from '@/blocks/utils'
3+
import { mapperOperation, toolCallArg } from '@/blocks/utils'
44

55
export const PerplexityBlock: BlockConfig = {
66
type: 'perplexity',
77
name: 'Perplexity',
8-
description: 'Use Perplexity AI for chat and search',
8+
description: 'Use Perplexity AI for chat, search and agent runs',
99
longDescription:
10-
'Generate completions using Perplexity AI chat models or perform web searches with advanced filtering.',
10+
'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.',
1111
authMode: AuthMode.ApiKey,
1212
docsLink: 'https://docs.sim.ai/integrations/perplexity',
1313
category: 'tools',
@@ -23,6 +23,10 @@ export const PerplexityBlock: BlockConfig = {
2323
{ text: 'Answer', field: 'content', core: true },
2424
{ text: 'using', field: 'model' },
2525
],
26+
perplexity_agent: [
27+
{ text: 'Research the web for', field: 'content', core: true },
28+
{ text: 'using', field: 'agentModel' },
29+
],
2630
perplexity_search: [
2731
{ text: 'Search the web for', field: 'query', core: true },
2832
{ text: 'within', field: 'search_domain_filter' },
@@ -39,6 +43,7 @@ export const PerplexityBlock: BlockConfig = {
3943
options: [
4044
{ label: 'Chat', id: 'perplexity_chat' },
4145
{ label: 'Search', id: 'perplexity_search' },
46+
{ label: 'Agent', id: 'perplexity_agent' },
4247
],
4348
value: () => 'perplexity_chat',
4449
},
@@ -48,15 +53,15 @@ export const PerplexityBlock: BlockConfig = {
4853
title: 'System Prompt',
4954
type: 'long-input',
5055
placeholder: 'System prompt to guide the model behavior...',
51-
condition: { field: 'operation', value: 'perplexity_chat' },
56+
condition: { field: 'operation', value: ['perplexity_chat', 'perplexity_agent'] },
5257
},
5358
{
5459
id: 'content',
5560
title: 'User Prompt',
5661
type: 'long-input',
5762
placeholder: 'Enter your prompt here...',
5863
required: true,
59-
condition: { field: 'operation', value: 'perplexity_chat' },
64+
condition: { field: 'operation', value: ['perplexity_chat', 'perplexity_agent'] },
6065
},
6166
{
6267
id: 'model',
@@ -85,7 +90,44 @@ export const PerplexityBlock: BlockConfig = {
8590
title: 'Max Tokens',
8691
type: 'short-input',
8792
placeholder: 'Maximum number of tokens',
88-
condition: { field: 'operation', value: 'perplexity_chat' },
93+
condition: { field: 'operation', value: ['perplexity_chat', 'perplexity_agent'] },
94+
},
95+
// Agent operation inputs
96+
{
97+
id: 'agentModel',
98+
title: 'Model',
99+
type: 'combobox',
100+
placeholder: 'Type or select a model...',
101+
options: [
102+
{ label: 'Claude Opus 5.5', id: 'anthropic/claude-opus-5-5' },
103+
{ label: 'GPT-5.5', id: 'openai/gpt-5.5' },
104+
],
105+
value: () => 'anthropic/claude-opus-5-5',
106+
required: true,
107+
condition: { field: 'operation', value: 'perplexity_agent' },
108+
},
109+
{
110+
id: 'web_search',
111+
title: 'Web Search',
112+
type: 'switch',
113+
defaultValue: true,
114+
condition: { field: 'operation', value: 'perplexity_agent' },
115+
},
116+
{
117+
id: 'fetch_url',
118+
title: 'Fetch URLs',
119+
type: 'switch',
120+
description: 'Let the agent read the full content of URLs',
121+
condition: { field: 'operation', value: 'perplexity_agent' },
122+
mode: 'advanced',
123+
},
124+
{
125+
id: 'max_steps',
126+
title: 'Max Steps',
127+
type: 'short-input',
128+
placeholder: '3',
129+
condition: { field: 'operation', value: 'perplexity_agent' },
130+
mode: 'advanced',
89131
},
90132
// Search operation inputs
91133
{
@@ -191,14 +233,16 @@ Return ONLY the date string in MM/DD/YYYY format - no explanations, no quotes, n
191233
},
192234
],
193235
tools: {
194-
access: ['perplexity_chat', 'perplexity_search'],
236+
access: ['perplexity_chat', 'perplexity_search', 'perplexity_agent'],
195237
config: {
196238
tool: (params) => {
197239
switch (params.operation) {
198240
case 'perplexity_chat':
199241
return 'perplexity_chat'
200242
case 'perplexity_search':
201243
return 'perplexity_search'
244+
case 'perplexity_agent':
245+
return 'perplexity_agent'
202246
default:
203247
return 'perplexity_chat'
204248
}
@@ -231,6 +275,21 @@ Return ONLY the date string in MM/DD/YYYY format - no explanations, no quotes, n
231275
return searchParams
232276
}
233277

278+
if (mapperOperation(params, context) === 'perplexity_agent') {
279+
const maxSteps = params.max_steps ? Number.parseInt(params.max_steps) : undefined
280+
const maxTokens = params.max_tokens ? Number.parseInt(params.max_tokens) : undefined
281+
return {
282+
apiKey: params.apiKey,
283+
model: params.agentModel ?? toolCallArg(context, params.model),
284+
content: params.content,
285+
systemPrompt: params.systemPrompt,
286+
web_search: params.web_search,
287+
fetch_url: params.fetch_url,
288+
max_steps: Number.isFinite(maxSteps) ? maxSteps : undefined,
289+
max_tokens: Number.isFinite(maxTokens) ? maxTokens : undefined,
290+
}
291+
}
292+
234293
// Chat params (default)
235294
const chatParams = {
236295
apiKey: params.apiKey,
@@ -267,6 +326,11 @@ Return ONLY the date string in MM/DD/YYYY format - no explanations, no quotes, n
267326
search_recency_filter: { type: 'string', description: 'Recency filter' },
268327
search_after_date: { type: 'string', description: 'After date filter' },
269328
search_before_date: { type: 'string', description: 'Before date filter' },
329+
// Agent operation inputs
330+
agentModel: { type: 'string', description: 'Agent API model' },
331+
web_search: { type: 'boolean', description: 'Enable web search' },
332+
fetch_url: { type: 'boolean', description: 'Enable URL fetch' },
333+
max_steps: { type: 'string', description: 'Maximum agent steps' },
270334
// Common
271335
apiKey: { type: 'string', description: 'Perplexity API key' },
272336
},
@@ -277,6 +341,9 @@ Return ONLY the date string in MM/DD/YYYY format - no explanations, no quotes, n
277341
usage: { type: 'json', description: 'Token usage' },
278342
// Search outputs
279343
results: { type: 'json', description: 'Search results array' },
344+
// Agent outputs
345+
status: { type: 'string', description: 'Agent run status' },
346+
sources: { type: 'json', description: 'Web sources the agent used' },
280347
},
281348
}
282349

‎apps/sim/tools/generated/tool-ids.ts‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎apps/sim/tools/generated/tool-metadata.ts‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎apps/sim/tools/generated/tool-outputs.ts‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)