| name | perplexity-core-workflow-a |
| description | Execute Perplexity primary workflow: single-query search with citations.
Use when implementing AI search, building fact-checking tools,
or integrating web-grounded answers into your application.
Trigger with phrases like "perplexity search", "perplexity query",
"search with citations", "perplexity main workflow".
|
| allowed-tools | Read, Write, Edit, Bash(npm:*), Grep |
| version | 1.12.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","perplexity","workflow"] |
| compatibility | Designed for Claude Code, also compatible with Codex and OpenClaw |
Perplexity Core Workflow A: Search with Citations
Overview
Primary money-path workflow: send a search query to Perplexity Sonar, receive a web-grounded answer with inline citations, parse and display the results. This is the single-query pattern used for search widgets, fact-checking, and real-time information retrieval.
Prerequisites
- Completed
perplexity-install-auth setup
openai package installed
PERPLEXITY_API_KEY set
Instructions
Step 1: Initialize Client and Send Query
import OpenAI from "openai";
const perplexity = new OpenAI({
apiKey: process.env.PERPLEXITY_API_KEY,
baseURL: "https://api.perplexity.ai",
});
async function searchWithCitations(query: string) {
const response = await perplexity.chat.completions.create({
model: "sonar",
messages: [
{
role: "system",
content: "Provide accurate, well-sourced answers. Cite your sources inline.",
},
{ role: "user", content: query },
],
search_recency_filter: "week",
} as );
response;
}