perplexity-core-workflow-a
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".
Best use case
perplexity-core-workflow-a is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
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".
Teams using perplexity-core-workflow-a should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/perplexity-core-workflow-a/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How perplexity-core-workflow-a Compares
| Feature / Agent | perplexity-core-workflow-a | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
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".
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
ChatGPT vs Claude for Agent Skills
Compare ChatGPT and Claude for AI agent skills across coding, writing, research, and reusable workflow execution.
Cursor vs Codex for AI Workflows
Compare Cursor and Codex for AI coding workflows, repository assistance, debugging, refactoring, and reusable developer skills.
SKILL.md Source
# 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
```typescript
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 },
],
// Perplexity-specific parameters
search_recency_filter: "week", // hour | day | week | month
} as any);
return response;
}
```
### Step 2: Parse Response with Citations
```typescript
interface SearchResult {
answer: string;
citations: string[];
searchResults: Array<{ title: string; url: string; snippet: string }>;
tokensUsed: number;
}
function parseResponse(response: any): SearchResult {
return {
answer: response.choices[0].message.content,
citations: response.citations || [],
searchResults: response.search_results || [],
tokensUsed: response.usage?.total_tokens || 0,
};
}
```
### Step 3: Format Citations for Display
```typescript
function formatAnswer(result: SearchResult): string {
let formatted = result.answer;
// Replace [1], [2] markers with markdown links
result.citations.forEach((url, i) => {
formatted = formatted.replaceAll(`[${i + 1}]`, `[${i + 1}](${url})`);
});
// Append source list
if (result.citations.length > 0) {
formatted += "\n\n**Sources:**\n";
result.citations.forEach((url, i) => {
formatted += `${i + 1}. ${url}\n`;
});
}
return formatted;
}
```
### Step 4: Complete Workflow
```typescript
async function main() {
const query = "What are the latest advances in battery technology?";
const response = await searchWithCitations(query);
const result = parseResponse(response);
const formatted = formatAnswer(result);
console.log(formatted);
console.log(`\n[${result.tokensUsed} tokens | ${result.citations.length} sources]`);
}
main().catch(console.error);
```
### Step 5: Domain-Filtered Search
```typescript
// Restrict search to trusted sources
async function domainFilteredSearch(query: string, domains: string[]) {
const response = await perplexity.chat.completions.create({
model: "sonar",
messages: [{ role: "user", content: query }],
search_domain_filter: domains, // max 20 domains
} as any);
return parseResponse(response);
}
// Example: only search academic sources
const result = await domainFilteredSearch(
"CRISPR gene editing latest trials",
["nature.com", "science.org", "nih.gov", "arxiv.org"]
);
```
### Step 6: Python Implementation
```python
from openai import OpenAI
import os, re
client = OpenAI(
api_key=os.environ["PERPLEXITY_API_KEY"],
base_url="https://api.perplexity.ai",
)
def search_with_citations(query: str, model: str = "sonar", recency: str = None) -> dict:
kwargs = {
"model": model,
"messages": [
{"role": "system", "content": "Provide accurate answers with cited sources."},
{"role": "user", "content": query},
],
}
if recency:
kwargs["search_recency_filter"] = recency
response = client.chat.completions.create(**kwargs)
raw = response.model_dump()
return {
"answer": response.choices[0].message.content,
"citations": raw.get("citations", []),
"tokens": response.usage.total_tokens,
}
# Usage
result = search_with_citations(
"What are the latest advances in battery technology?",
recency="week"
)
print(result["answer"])
for i, url in enumerate(result["citations"], 1):
print(f" [{i}] {url}")
```
## Error Handling
| Error | Cause | Solution |
|-------|-------|----------|
| `401 Unauthorized` | Invalid API key | Regenerate at perplexity.ai/settings/api |
| `429 Too Many Requests` | Rate limit exceeded | Implement exponential backoff |
| Empty citations | Query too vague | Make query more specific and factual |
| Stale information | No recency filter | Add `search_recency_filter: "day"` |
| Slow response (>10s) | Using sonar-pro | Switch to sonar for faster results |
## Output
- Web-grounded answer text with inline citation markers
- Parsed citation URLs for source verification
- Formatted markdown with linked sources
- Token usage for cost tracking
## Resources
- [Perplexity API Reference](https://docs.perplexity.ai/api-reference/chat-completions-post)
- [Search Parameters](https://docs.perplexity.ai/docs/sonar/quickstart)
## Next Steps
For multi-query research, see `perplexity-core-workflow-b`.Related Skills
calendar-to-workflow
Converts calendar events and schedules into Claude Code workflows, meeting prep documents, and standup notes. Use when the user mentions calendar events, meeting prep, standup generation, or scheduling workflows. Trigger with phrases like "prep for my meetings", "generate standup notes", "create workflow from calendar", or "summarize today's schedule".
workhuman-core-workflow-b
Workhuman core workflow b for employee recognition and rewards API. Use when integrating Workhuman Social Recognition, or building recognition workflows with HRIS systems. Trigger: "workhuman core workflow b".
workhuman-core-workflow-a
Workhuman core workflow a for employee recognition and rewards API. Use when integrating Workhuman Social Recognition, or building recognition workflows with HRIS systems. Trigger: "workhuman core workflow a".
wispr-core-workflow-b
Wispr Flow core workflow b for voice-to-text API integration. Use when integrating Wispr Flow dictation, WebSocket streaming, or building voice-powered applications. Trigger: "wispr core workflow b".
wispr-core-workflow-a
Wispr Flow core workflow a for voice-to-text API integration. Use when integrating Wispr Flow dictation, WebSocket streaming, or building voice-powered applications. Trigger: "wispr core workflow a".
windsurf-core-workflow-b
Execute Windsurf's secondary workflow: Workflows, Memories, and reusable automation. Use when creating reusable Cascade workflows, managing persistent memories, or automating repetitive development tasks. Trigger with phrases like "windsurf workflow", "windsurf automation", "windsurf memories", "cascade workflow", "windsurf slash command".
windsurf-core-workflow-a
Execute Windsurf's primary workflow: Cascade Write mode for multi-file agentic coding. Use when building features, refactoring across files, or performing complex code tasks. Trigger with phrases like "windsurf cascade write", "windsurf agentic coding", "windsurf multi-file edit", "cascade write mode", "windsurf build feature".
webflow-core-workflow-b
Execute Webflow secondary workflows — Sites management, Pages API, Forms submissions, Ecommerce (products/orders/inventory), and Custom Code via the Data API v2. Use when managing sites, reading pages, handling form data, or working with Webflow Ecommerce products and orders. Trigger with phrases like "webflow sites", "webflow pages", "webflow forms", "webflow ecommerce", "webflow products", "webflow orders".
webflow-core-workflow-a
Execute the primary Webflow workflow — CMS content management: list collections, CRUD items, publish items, and manage content lifecycle via the Data API v2. Use when working with Webflow CMS collections and items, managing blog posts, team members, or any dynamic content. Trigger with phrases like "webflow CMS", "webflow collections", "webflow items", "create webflow content", "manage webflow CMS", "webflow content management".
veeva-core-workflow-b
Veeva Vault core workflow b for REST API and clinical operations. Use when working with Veeva Vault document management and CRM. Trigger: "veeva core workflow b".
veeva-core-workflow-a
Veeva Vault core workflow a for REST API and clinical operations. Use when working with Veeva Vault document management and CRM. Trigger: "veeva core workflow a".
vastai-core-workflow-b
Execute Vast.ai secondary workflow: multi-instance orchestration, spot recovery, and cost optimization. Use when running distributed training, handling spot preemption, or optimizing GPU spend across multiple instances. Trigger with phrases like "vastai distributed training", "vastai spot recovery", "vastai multi-gpu", "vastai cost optimization".