From shaughv-code
Search the web and get AI-grounded answers using the Perplexity API. Covers three APIs: Agent API (multi-provider models with web search and presets), Search API (raw ranked results), and Sonar API (web-grounded chat completions with citations). USE WHEN: - User asks to search with Perplexity, use Perplexity, or query Perplexity - Web research requiring real-time, cited results - Need raw search results for custom processing - Want AI answers grounded in current web data - Need to use specific LLM providers (OpenAI, Anthropic, Google, xAI) via unified API - Deep research or multi-step web analysis tasks - User mentions "perplexity", "sonar", "pro-search", "deep-research"
How this skill is triggered — by the user, by Claude, or both
Slash command
/shaughv-code:perplexity-searchThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Web search and AI-grounded answers via the Perplexity API.
Web search and AI-grounded answers via the Perplexity API.
Returns ranked search results (title, URL, snippet, date) without any AI processing.
Choose when:
Pros: Fastest, cheapest, no hallucination risk, full control over result processing, multi-query support (up to 5 queries per request), domain/language/region filtering Cons: No AI synthesis — you get raw results and must process them yourself. No citations, no summarization, no follow-up conversation.
Perplexity's own Sonar models generate answers grounded in live web search. Chat completions format.
Choose when:
Pros: Built-in citations array, simple chat completions format, multi-turn conversation, streaming support, OpenAI SDK compatible, Perplexity's own optimized models Cons: Limited to Perplexity's Sonar models only (no choosing OpenAI/Anthropic/Google). Less control over search behavior. No presets or tool configuration.
Access OpenAI, Anthropic, Google, xAI, and more through one API, with integrated web search tools and pre-configured presets.
Choose when:
Pros: Multi-provider model access (no separate API keys needed), 4 optimized presets, granular control (tools, reasoning, token budgets, max steps), model fallback chains, detailed cost/usage in every response, domain filtering on web_search tool Cons: Most expensive option (token costs + search costs). More complex request format. Slower for simple queries vs Search or Sonar. Preset system prompts can be verbose.
| Question | Answer | Use |
|---|---|---|
| Do you need raw URLs/data, not AI text? | Yes | Search |
| Do you want a quick cited answer? | Yes | Sonar |
| Do you need a specific model (GPT, Claude, etc.)? | Yes | Agent |
| Is this a deep, multi-step research task? | Yes | Agent (deep-research preset) |
| Building a simple Q&A chatbot? | Yes | Sonar |
| Feeding results into another AI model? | Yes | Search |
| Need the cheapest option? | Yes | Search > Sonar > Agent |
| Need the simplest integration? | Yes | Sonar > Agent > Search |
Set PERPLEXITY_API_KEY in your environment before invoking this skill:
export PERPLEXITY_API_KEY=pplx-... (or add to ~/.zshrc / ~/.bashrc)[Environment]::SetEnvironmentVariable('PERPLEXITY_API_KEY', 'pplx-...', 'User') — then start a new shell$env:PERPLEXITY_API_KEY = 'pplx-...'PERPLEXITY_API_KEY from the environment directly. If it isn't set, ask the user to set it rather than prompting for the key value in chat.Optional SDK install:
pip install perplexityai # Python
npm install @perplexity-ai/perplexity_ai # TypeScript
python scripts/perplexity.py search "latest AI news" --max-results 5
curl -X POST 'https://api.perplexity.ai/search' \
-H "Authorization: Bearer $PERPLEXITY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "latest AI news", "max_results": 5}'
python scripts/perplexity.py sonar "What are the latest developments in quantum computing?"
curl https://api.perplexity.ai/v1/sonar \
-H "Authorization: Bearer $PERPLEXITY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "sonar-pro", "messages": [{"role": "user", "content": "your question"}]}'
# Quick factual lookup
python scripts/perplexity.py agent "Who won the Nobel Prize in Physics 2025?" --preset fast-search
# Standard research
python scripts/perplexity.py agent "Compare React vs Vue in 2026" --preset pro-search
# Deep analysis (many sources, multi-step reasoning)
python scripts/perplexity.py agent "Analyze AI regulation impact on startups" --preset deep-research
# Institutional-grade research
python scripts/perplexity.py agent "Competitive analysis of cloud providers" --preset advanced-deep-research
scripts/perplexity.py — standalone CLI (stdlib only, no dependencies).
python scripts/perplexity.py search "query" [--max-results N] [--domain-filter d1,d2] [--language en] [--country US]
python scripts/perplexity.py sonar "prompt" [--model sonar-pro] [--system "instructions"] [--stream]
python scripts/perplexity.py agent "prompt" [--preset NAME] [--model provider/model] [--tools web_search,fetch_url] [--stream]
Common flags: --json (raw output), --api-key KEY (override)
| Preset | Speed | Depth | Best For |
|---|---|---|---|
fast-search | Fastest | 1 step | Simple factual questions |
pro-search | Balanced | 3 steps | Most research queries |
deep-research | Slow | 10 steps | Complex analysis |
advanced-deep-research | Slowest | 10 steps | Premium institutional research |
Presets auto-configure model, tools, and system prompt. Override any parameter alongside preset.
# Only search specific domains
python scripts/perplexity.py search "AI research" --domain-filter arxiv.org,nature.com
# Exclude domains
python scripts/perplexity.py search "tech news" --domain-filter "-reddit.com,-pinterest.com"
# Filter by language
python scripts/perplexity.py search "renewable energy" --language en,de
# Regional search
python scripts/perplexity.py search "government policy" --country US
Guides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.
npx claudepluginhub realemmetts/shaughv-code --plugin shaughv-code