agentleFS
G1JoshiG1Joshi/Agent-Skills/skills/ai-ml/perplexity/SKILL.md

perplexity

Skill15 starsChanged 42 days agoMITView on GitHub

Expert Perplexity AI API assistance covering sonar online models, search grounding, citations, and real-time web retrieval. Use when building search-augmented AI research and current event query pipelines.

  • Reads credentials

8 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 7 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use search_domain_filter to limit search to trusted corporate, scientific, or government websites.

    line 147
  2. Distinctive:

    Use high temperature settings (> 0.3) if exact factual precision and strict web grounding are desired.

    line 151

“Common” is measured: kept by at least 6 in 10 of the 7 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Perplexity

Perplexity is an AI search engine. For developers, the Sonar API provides grounded, cited answers for building search-enabled apps.

When to Use

  • Real-Time Web-Augmented Search & Retrieval: Querying fresh, live web data with grounded, verifiable source citations.
  • Fact-Checking & Research Automation: Generating comprehensive answers with linked URLs for financial, legal, and tech intelligence.
  • Perplexity Sonar Models via API: Accessing sonar-pro, sonar, and reasoning models for production AI assistants.
  • Recency-Filtered Search: Restricting search scope to the last day, week, or month for breaking developments.

Quick Start

from openai import OpenAI

# Perplexity uses OpenAI-compatible API format
client = OpenAI(
    api_key="your-perplexity-api-key",
    base_url="https://api.perplexity.ai"
)

response = client.chat.completions.create(
    model="sonar-pro",
    messages=[
        {"role": "user", "content": "What were the major tech announcements this week?"}
    ]
)

print(response.choices[0].message.content)

Core Concepts

Consuming Perplexity Sonar API with Citations

Querying live web search intelligence using OpenAI-compatible SDK:

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ.get("PERPLEXITY_API_KEY"),
    base_url="https://api.perplexity.ai"
)

response = client.chat.completions.create(
    model="sonar-pro",
    messages=[
        {"role": "system", "content": "You are a research analyst. Provide factual answers with explicit citations."},
        {"role": "user", "content": "What are the latest developments in quantum computing error correction in 2026?"}
    ],
    temperature=0.2,
)

answer = response.choices[0].message.content
citations = getattr(response, 'citations', [])

print("Answer:\n", answer)
print("\nSources / Citations:")
for i, url in enumerate(citations, 1):
    print(f"[{i}] {url}")

Search Domain & Recency Filtering

Restricting search context to authoritative domains and specific timeframes:

import requests
import json

url = "https://api.perplexity.ai/chat/completions"
headers = {
    "Authorization": f"Bearer {os.environ.get('PERPLEXITY_API_KEY')}",
    "Content-Type": "application/json"
}

payload = {
    "model": "sonar",
    "messages": [
        {"role": "user", "content": "What were the key policy changes announced by the central bank this week?"}
    ],
    "search_domain_filter": ["bloomberg.com", "reuters.com", "ft.com"],
    "search_recency_filter": "week" # "day", "week", "month", "year"
}

res = requests.post(url, json=payload, headers=headers)
data = res.json()
print(data['choices'][0]['message']['content'])

Structured Output Formatting with Sonar

Directing the model to output verified markdown data tables:

response = client.chat.completions.create(
    model="sonar",
    messages=[
        {"role": "user", "content": "Compare the top 3 open-source vector databases by license, GitHub stars, and vector indexing algorithm. Output as a Markdown table."}
    ],
    temperature=0.1
)

print(response.choices[0].message.content)

Common Patterns

Domain-Restricted Search Grounding

Problem: Retrieval results include low-quality blogs or outdated forum answers.

Solution: Filter search sources using search_domain_filter:

response = client.chat.completions.create(
    model="sonar",
    messages=[{"role": "user", "content": "What is the latest RFC standard for HTTP/3?"}],
    extra_body={
        "search_domain_filter": ["ietf.org", "mozilla.org", "w3.org"],
        "return_citations": True
    }
)

print("Answer:", response.choices[0].message.content)
# Access citation URLs if enabled
citations = getattr(response, "citations", [])
print("Citations:", citations)

Best Practices

Do:

  • Target sonar-pro for deep analytical research and sonar for fast, lightweight web queries.
  • Inspect and parse the citations array to display clickable references in user-facing interfaces.
  • Apply search_recency_filter when querying time-sensitive or breaking news topics.
  • Use search_domain_filter to limit search to trusted corporate, scientific, or government websites.

Don't:

  • Use high temperature settings (> 0.3) if exact factual precision and strict web grounding are desired.
  • Assume web search is necessary for closed-domain math or pure coding tasks; standard LLMs are faster and cheaper.
  • Hardcode PERPLEXITY_API_KEY in scripts; load securely from environment variables.

Troubleshooting

ErrorCauseSolution
401 UnauthorizedInvalid or expired Perplexity API key.Verify API key in Perplexity settings and set PPLX_API_KEY.
Model not supported: ...Using deprecated model tag (e.g. llama-3-sonar-8b).Use active sonar models: sonar or sonar-pro.
Base URL missing in clientConnecting to default api.openai.com instead of api.perplexity.ai.Specify base_url="https://api.perplexity.ai".

References

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.