Perplexity ACTION
Chat Completions (Advanced)
Generates a model's response for the given chat conversation with multi-message support and Perplexity search controls. Docs: https://docs.perplexity.ai/api-reference/chat-completions-post
- Action
- Writes data
- API key
- SDK
- MCP
IMPLEMENTATION
Call this tool
Connect a user's Perplexity account once, then configure and run Chat Completions (Advanced) from your backend or agent.
import { PipedreamClient } from "@pipedream/sdk"
const pd = new PipedreamClient({
projectId: process.env.PIPEDREAM_PROJECT_ID!,
clientId: process.env.PIPEDREAM_CLIENT_ID!,
clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
projectEnvironment: "production",
})
const result = await pd.actions.run({
id: "perplexity-chat-completions-advanced",
externalUserId: "{external_user_id}", // any stable ID for this user in your system
configuredProps: {
perplexity: { authProvisionId: "apn_xxxxxxx" },
model: "Model",
messages: ["Messages (JSON strings or UI collection)"],
},
})
console.log(result)curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
-H "Content-Type: application/json" \
-H "X-PD-Environment: production" \
-H "Authorization: Bearer {access_token}" \
-d '{
"external_user_id": "{external_user_id}",
"id": "perplexity-chat-completions-advanced",
"configured_props": {
"perplexity": { "authProvisionId": "apn_xxxxxxx" },
"model": "Model",
"messages": ["Messages (JSON strings or UI collection)"]
}
}'// accessToken: mint a short-lived token with the Connect SDK — see the MCP guide
const transport = new StreamableHTTPClientTransport(
new URL("https://remote.mcp.pipedream.net/v3"),
{
requestInit: {
headers: {
Authorization: `Bearer ${accessToken}`,
"x-pd-project-id": "{project_id}",
"x-pd-environment": "production",
"x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
"x-pd-app-slug": "perplexity",
},
},
},
)
const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)
const { tools } = await mcp.listTools()
// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
name: "perplexity-chat-completions-advanced",
arguments: {
model: "Model",
messages: ["Messages (JSON strings or UI collection)"],
},
})SCHEMA
Inputs
Pipedream supplies the connected account. Your application provides the operation-specific values below. Dynamic inputs are resolved against that user's account.
| Property | Type | Description |
|---|---|---|
model Model | string | The name of the model that will complete your prompt Required |
messages Messages (JSON strings or UI collection) | string[] | Array of message objects: [{ role: 'system'|'user'|'assistant', content: '...' }, ...]. If provided, 'role' and 'content' are ignored. Optional |
system System | string | Optional system prompt injected as the first message Optional |
role Role | string | The role of the speaker in this turn of conversation. After the (optional) system message, user and assistant roles should alternate with 'user' then 'assistant', ending in 'user'. Optional |
content Content | string | The contents of the message in this turn of conversation Optional |
temperature Temperature | string | Sampling temperature. Higher values = more diverse output. Optional |
topP Top-p | string | Nucleus sampling probability mass. Use either temperature or top_p. Optional |
maxTokens Max Output Tokens | integer | Cap response length (Sonar Pro practical max output ~8k). Optional |
stream Stream | boolean | Enable server-side streaming. This action will still buffer and return the final text. Optional |
searchDomainFilter Search Domain Filter | string[] | Limit web search to these domains (e.g., ['sec.gov','ft.com']) Optional |
searchRecencyFilter Search Recency Filter | string | Prefer recent sources (e.g., 'day', 'week', 'month', 'year') Optional |
topK Top K | integer | Restrict number of retrieved items considered Optional |
returnImages Return Images | boolean | Ask API to include images when applicable Optional |
returnRelatedQuestions Return Related Questions | boolean | Ask API to include related questions in response Optional |
REFERENCE
Tool details
Behavior hints are published with the component in the Pipedream registry and surface as MCP tool annotations, so an agent can reason about a tool before it calls it.
- Registry key
- perplexity-chat-completions-advanced
- Version
- 0.0.4
- App
- Perplexity
- Authentication
- API key
- Read-only
- No
- Destructive
- No
- Open world
- Yes
- Source
- View on GitHub ↗