Skip to content

Commit da76811

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

14 files changed

Lines changed: 548 additions & 20 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

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

9090
</ReferenceDetails>
9191

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

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

Lines changed: 74 additions & 8 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 { blockFieldOrToolArg, mapperOperation } 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+
mode: 'advanced',
95+
},
96+
// Agent operation inputs
97+
{
98+
id: 'agentModel',
99+
title: 'Model',
100+
type: 'combobox',
101+
placeholder: 'Type or select a model...',
102+
options: [
103+
{ label: 'Claude Opus 5.5', id: 'anthropic/claude-opus-5-5' },
104+
{ label: 'GPT-5.5', id: 'openai/gpt-5.5' },
105+
],
106+
value: () => 'anthropic/claude-opus-5-5',
107+
required: true,
108+
condition: { field: 'operation', value: 'perplexity_agent' },
109+
},
110+
{
111+
id: 'web_search',
112+
title: 'Web Search',
113+
type: 'switch',
114+
defaultValue: true,
115+
condition: { field: 'operation', value: 'perplexity_agent' },
116+
},
117+
{
118+
id: 'fetch_url',
119+
title: 'Fetch URLs',
120+
type: 'switch',
121+
description: 'Let the agent read the full content of URLs',
122+
condition: { field: 'operation', value: 'perplexity_agent' },
123+
mode: 'advanced',
124+
},
125+
{
126+
id: 'max_steps',
127+
title: 'Max Steps',
128+
type: 'short-input',
129+
placeholder: '3',
130+
condition: { field: 'operation', value: 'perplexity_agent' },
89131
mode: 'advanced',
90132
},
91133
// Search operation inputs
@@ -197,14 +239,16 @@ Return ONLY the date string in MM/DD/YYYY format - no explanations, no quotes, n
197239
},
198240
],
199241
tools: {
200-
access: ['perplexity_chat', 'perplexity_search'],
242+
access: ['perplexity_chat', 'perplexity_search', 'perplexity_agent'],
201243
config: {
202244
tool: (params) => {
203245
switch (params.operation) {
204246
case 'perplexity_chat':
205247
return 'perplexity_chat'
206248
case 'perplexity_search':
207249
return 'perplexity_search'
250+
case 'perplexity_agent':
251+
return 'perplexity_agent'
208252
default:
209253
return 'perplexity_chat'
210254
}
@@ -237,6 +281,21 @@ Return ONLY the date string in MM/DD/YYYY format - no explanations, no quotes, n
237281
return searchParams
238282
}
239283

284+
if (mapperOperation(params, context) === 'perplexity_agent') {
285+
const maxSteps = params.max_steps ? Number.parseInt(params.max_steps) : undefined
286+
const maxTokens = params.max_tokens ? Number.parseInt(params.max_tokens) : undefined
287+
return {
288+
apiKey: params.apiKey,
289+
model: blockFieldOrToolArg(context, params.agentModel, params.model),
290+
content: params.content,
291+
systemPrompt: params.systemPrompt,
292+
web_search: params.web_search,
293+
fetch_url: params.fetch_url,
294+
max_steps: Number.isFinite(maxSteps) ? maxSteps : undefined,
295+
max_tokens: Number.isFinite(maxTokens) ? maxTokens : undefined,
296+
}
297+
}
298+
240299
// Chat params (default)
241300
const chatParams = {
242301
apiKey: params.apiKey,
@@ -273,6 +332,11 @@ Return ONLY the date string in MM/DD/YYYY format - no explanations, no quotes, n
273332
search_recency_filter: { type: 'string', description: 'Recency filter' },
274333
search_after_date: { type: 'string', description: 'After date filter' },
275334
search_before_date: { type: 'string', description: 'Before date filter' },
335+
// Agent operation inputs
336+
agentModel: { type: 'string', description: 'Agent API model' },
337+
web_search: { type: 'boolean', description: 'Enable web search' },
338+
fetch_url: { type: 'boolean', description: 'Enable URL fetch' },
339+
max_steps: { type: 'string', description: 'Maximum agent steps' },
276340
// Common
277341
apiKey: { type: 'string', description: 'Perplexity API key' },
278342
},
@@ -284,14 +348,16 @@ Return ONLY the date string in MM/DD/YYYY format - no explanations, no quotes, n
284348
search_results: {
285349
type: 'json',
286350
description:
287-
'Sources the chat answer was grounded in [{title, url, date, last_updated, snippet}]',
351+
'Sources the chat answer was grounded in, or the agent retrieved [{title, url, date, last_updated, snippet}]',
288352
},
289353
usage: { type: 'json', description: 'Token usage' },
290354
// Search outputs
291355
results: {
292356
type: 'json',
293357
description: 'Search results [{title, url, snippet, date, last_updated}]',
294358
},
359+
// Agent outputs
360+
status: { type: 'string', description: 'Agent run status' },
295361
},
296362
}
297363

‎apps/sim/blocks/sdk-names.generated.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ const BLOCKS: Record<string, string> = {
329329
pagerduty_v2: '{"namespace":"pagerduty","methods":{"add_note":"addNote","create_incident":"createIncident","get_incident":"getIncident","get_service":"getService","list_escalation_policies":"listEscalationPolicies","list_incident_alerts":"listIncidentAlerts","list_incidents":"listIncidents","list_oncalls":"listOnCalls","list_schedules":"listSchedules","list_services":"listServices","list_users":"listUsers","merge_incidents":"mergeIncidents","send_event":"sendEvent","snooze_incident":"snoozeIncident","update_incident":"updateIncident"},"triggers":{"pagerduty_incident_acknowledged":"incidentAcknowledged","pagerduty_incident_escalated":"incidentEscalated","pagerduty_incident_reassigned":"incidentReassigned","pagerduty_incident_resolved":"incidentResolved","pagerduty_incident_triggered":"incidentTriggered","pagerduty_webhook":"webhook"},"paramAliases":{"action":{"oauthCredential":"credential"}}}',
330330
parallel_ai: '{"namespace":"parallelAi","methods":{"deep_research":"deepResearch","extract":"extractFromUrls","search":"search"}}',
331331
peopledatalabs: '{"namespace":"peopledatalabs","methods":{"pdl_autocomplete":"autocomplete","pdl_bulk_company_enrich":"bulkCompanyEnrich","pdl_bulk_person_enrich":"bulkPersonEnrich","pdl_clean_company":"companyCleaner","pdl_clean_location":"locationCleaner","pdl_clean_school":"schoolCleaner","pdl_company_enrich":"companyEnrich","pdl_company_search":"companySearch","pdl_person_enrich":"personEnrich","pdl_person_identify":"personIdentify","pdl_person_search":"personSearch"}}',
332-
perplexity: '{"namespace":"perplexity","methods":{"perplexity_chat":"chat","perplexity_search":"search"}}',
332+
perplexity: '{"namespace":"perplexity","methods":{"perplexity_agent":"agent","perplexity_chat":"chat","perplexity_search":"search"}}',
333333
persona: '{"namespace":"legacy.persona","methods":{"approve_inquiry":"approveInquiry","create_account":"createAccount","create_inquiry":"createInquiry","create_report":"createReport","decline_inquiry":"declineInquiry","expire_inquiry":"expireInquiry","generate_inquiry_link":"generateInquiryLink","get_account":"getAccount","get_case":"getCase","get_document":"getDocument","get_inquiry":"getInquiry","get_report":"getReport","get_verification":"getVerification","import_accounts":"importAccountsCsv","list_accounts":"listAccounts","list_cases":"listCases","list_inquiries":"listInquiries","list_inquiry_templates":"listInquiryTemplates","list_reports":"listReports","mark_inquiry_for_review":"markInquiryForReview","print_inquiry_pdf":"printInquiryPdf","redact_account":"redactAccount","redact_inquiry":"redactInquiry","resume_inquiry":"resumeInquiry","update_account":"updateAccount","update_inquiry":"updateInquiry"}}',
334334
persona_v2: '{"namespace":"persona","methods":{"approve_inquiry":"approveInquiry","create_account":"createAccount","create_inquiry":"createInquiry","create_report":"createReport","decline_inquiry":"declineInquiry","expire_inquiry":"expireInquiry","generate_inquiry_link":"generateInquiryLink","get_account":"getAccount","get_case":"getCase","get_document":"getDocument","get_inquiry":"getInquiry","get_report":"getReport","get_verification":"getVerification","import_accounts":"importAccountsCsv","list_accounts":"listAccounts","list_cases":"listCases","list_inquiries":"listInquiries","list_inquiry_templates":"listInquiryTemplates","list_reports":"listReports","mark_inquiry_for_review":"markInquiryForReview","print_inquiry_pdf":"printInquiryPdf","redact_account":"redactAccount","redact_inquiry":"redactInquiry","resume_inquiry":"resumeInquiry","update_account":"updateAccount","update_inquiry":"updateInquiry"},"paramAliases":{"action":{"oauthCredential":"credential"}}}',
335335
pi: '{"namespace":"pi"}',

‎apps/sim/blocks/sdk-names/perplexity.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"namespace": "perplexity",
33
"methods": {
4+
"perplexity_agent": "agent",
45
"perplexity_chat": "chat",
56
"perplexity_search": "search"
67
}

‎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)