perplexity-sonar

Use Perplexity Sonar API for real-time, citation-backed answers. Ideal for up-to-date information and quick synthesis. Requires PERPLEXITY_API_KEY

⭐2stars🔀0forks📁View on GitHub🕐Updated Nov 26, 2025

When & Why to Use This Skill

The Perplexity Sonar skill empowers Claude with real-time web search capabilities, providing accurate, citation-backed answers to complex queries. By leveraging the Perplexity Sonar API, it bridges the gap between static training data and the live web, making it an essential tool for up-to-date research, information synthesis, and verifying facts with authoritative sources.

Use Cases

  • Market Intelligence: Conduct deep-dive research into current market trends, competitor updates, and industry shifts using the most recent data available online.
  • Fact-Checking and Verification: Quickly verify claims or find the latest statistics and news reports with direct citations to original sources.
  • Academic and Professional Research: Gather synthesized summaries of complex topics with integrated citations, facilitating faster literature reviews and data gathering.
  • Real-time Event Tracking: Stay informed about breaking news, product launches, or policy changes that occurred after the AI's last training cutoff.
nameperplexity-sonar
descriptionUse Perplexity Sonar API for real-time, citation-backed answers. Ideal for up-to-date information and quick synthesis. Requires PERPLEXITY_API_KEY

Perplexity Sonar Skill

This skill utilizes the Perplexity Sonar API to provide synthesized answers backed by real-time web sources. It uses the OpenAI Python library for compatibility.

Setup

  1. Dependencies:

    pip install openai python-dotenv
    
  2. API Key Configuration: The skill requires the PERPLEXITY_API_KEY. Ensure it is set in a .env file in the project root.

    # If the script fails due to a missing key, run the following:
    echo "It seems the Perplexity API key is not set up."
    read -p "Enter your Perplexity API key: " PPLX_KEY
    echo "PERPLEXITY_API_KEY=$PPLX_KEY" >> .env
    # Ensure .env is ignored by git
    if [ -f .gitignore ] && ! grep -q ".env" .gitignore; then echo ".env" >> .gitignore; fi
    echo "API key saved to .env."
    

Usage

Use the scripts/ask.py script to query the Sonar API.

Command

python3 scripts/ask.py --prompt "<your_research_question>" [--model <model_name>]

Parameters

  • --prompt (Required): The research question.
  • --model (Optional): Defaults to sonar-medium-online. Use sonar-large-online for comprehensive analysis.

Example

python3 scripts/ask.py --prompt "What are the latest developments in the EV market in Q4 2025?" --model sonar-large-online

Output

The script outputs the synthesized answer directly to stdout, with citations integrated by the Perplexity model.