
Perplexity Search
- 415 installs
- 3 repo stars
- Updated January 23, 2026
- dotneet/claude-code-marketplace
perplexity-search is a Claude Code marketplace skill that runs Perplexity-powered web searches inside Claude Code to gather current facts, citations, competitor moves, and API docs while exploring problems before writing
About
perplexity-search is a Claude Code marketplace skill that embeds Perplexity-powered web search directly in agent sessions so developers can pull current facts, citations, API documentation, and market context without leaving the coding flow. The skill returns sourced answers useful when training data is stale or when verifying competitor moves, pricing pages, or newly shipped API behavior. Reach for perplexity-search during spike work, integration planning, or debugging errors tied to recent library releases. It suits engineers using Claude Code who want retrieval-augmented research with citations instead of guessing from model memory. Use it before committing to an architecture, when validating third-party docs, or when a task needs fresh web evidence alongside repo context.
- Live Perplexity web search
- Citation-friendly answers
- Competitor and trend discovery
- In-agent research workflow
- Marketplace skill install
Perplexity Search by the numbers
- 415 all-time installs (skills.sh)
- Ranked #1,937 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Jul 29, 2026 (Skillselion catalog sync)
npx skills add https://github.com/dotneet/claude-code-marketplace --skill perplexity-searchAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 415 |
|---|---|
| repo stars | ★ 3 |
| Last updated | January 23, 2026 |
| Repository | dotneet/claude-code-marketplace ↗ |
How do you search the web inside Claude Code?
Run Perplexity-powered web searches inside Claude Code to gather current facts, citations, competitor moves, and API docs while exploring problems before writing code.
Who is it for?
Claude Code users who need cited, up-to-date web research on APIs, competitors, or recent events without switching to a browser.
Skip if: Developers who only need codebase-local search or already have authoritative offline docs and do not require live web citations.
When should I use this skill?
A developer needs current facts, API docs, citations, or competitor research from the web while working inside Claude Code.
What you get
Cited web search results, current API documentation excerpts, and fact summaries gathered via Perplexity inside Claude Code.
- cited search summaries
- API documentation excerpts
- research notes
Files
Perplexity Search Skill
A skill for executing real-time web searches and research using the Perplexity API.
Purpose
This skill provides the following capabilities:
1. perplexity_ask - Answer general questions (using sonar-pro model) 2. perplexity_research - Deep research and comprehensive reports (using sonar-deep-research model) 3. perplexity_reason - Advanced reasoning and analysis (using sonar-reasoning-pro model) 4. perplexity_search - Retrieve web search results
When to Use
Use this skill in the following situations:
- User needs up-to-date information
- Received a question requiring web search
- Asked to perform deep research or investigation
- Complex analysis or reasoning is required
- Keywords like "look up", "search for", "latest..." are included
Prerequisites
PERPLEXITY_API_KEYenvironment variable must be set- Internet connection must be available
Usage
Basic Usage
Use the scripts/perplexity_api.py script to call the API.
# General questions (ask)
python3 scripts/perplexity_api.py ask "your question"
# Deep research (research)
python3 scripts/perplexity_api.py research "research topic"
# Advanced reasoning (reason)
python3 scripts/perplexity_api.py reason "reasoning task"
# Web search (search)
python3 scripts/perplexity_api.py search "search query" [--max-results 10] [--country JP]Command Options
ask / research / reason
- First argument: question, research topic, or reasoning task
--strip-thinking: Remove<think>...</think>tags to save context tokens (research/reason only)
search
- First argument: search query
--max-results: Maximum number of results to return (1-20, default: 10)--max-tokens-per-page: Maximum tokens per page (256-2048, default: 1024)--country: ISO code for regional results (e.g., JP, US, GB)
Workflow
Standard Search Flow
1. Analyze the user's question and select the appropriate tool
- Simple questions →
ask - Deep research →
research - Complex analysis →
reason - Information gathering →
search
2. Execute the script to call the API
3. Present results to the user, citing sources when available
Tool Selection Guidelines
| Use Case | Tool | Description |
|---|---|---|
| Current weather, news | ask | When quick answers are needed |
| Technical topic research | research | When comprehensive analysis is needed |
| Complex problem analysis | reason | When logical reasoning is needed |
| Collecting sources | search | When URLs or snippets are needed |
API Details
For detailed API specifications, see references/api_reference.md.
Troubleshooting
- API Key Error: Verify the
PERPLEXITY_API_KEYenvironment variable - Timeout: Increase
PERPLEXITY_TIMEOUT_MS(default: 300000ms) - Proxy Issues: Set
PERPLEXITY_PROXYorHTTPS_PROXY
Perplexity API Reference
Overview
The Perplexity API provides real-time web search and advanced AI reasoning capabilities.
Authentication
All requests require an Authorization: Bearer <PERPLEXITY_API_KEY> header.
Endpoints
Chat Completions
URL: https://api.perplexity.ai/chat/completions Method: POST
Request Body
{
"model": "sonar-pro",
"messages": [
{
"role": "user",
"content": "Your question"
}
]
}Available Models
| Model | Description | Use Case |
|---|---|---|
sonar-pro | General conversational AI | Everyday questions, quick searches |
sonar-deep-research | Deep research model | Comprehensive reports, detailed analysis |
sonar-reasoning-pro | Reasoning-focused model | Complex problem-solving, logical analysis |
Response
{
"choices": [
{
"message": {
"role": "assistant",
"content": "Response content"
}
}
],
"citations": [
"https://example.com/source1",
"https://example.com/source2"
]
}Search API
URL: https://api.perplexity.ai/search Method: POST
Request Body
{
"query": "search query",
"max_results": 10,
"max_tokens_per_page": 1024,
"country": "JP"
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
query | string | Yes | Search query |
max_results | int | No | Maximum number of results (1-20, default: 10) |
max_tokens_per_page | int | No | Maximum tokens per page (256-2048, default: 1024) |
country | string | No | ISO 3166-1 alpha-2 country code |
Response
{
"results": [
{
"title": "Page title",
"url": "https://example.com/page",
"snippet": "Page excerpt...",
"date": "2024-01-15"
}
]
}Environment Variables
| Variable | Description | Default |
|---|---|---|
PERPLEXITY_API_KEY | API key (required) | - |
PERPLEXITY_TIMEOUT_MS | Timeout (milliseconds) | 300000 |
PERPLEXITY_PROXY | Proxy URL | - |
HTTPS_PROXY | HTTPS proxy (alternative) | - |
HTTP_PROXY | HTTP proxy (alternative) | - |
Error Handling
HTTP Status Codes
| Code | Description |
|---|---|
| 200 | Success |
| 400 | Bad Request |
| 401 | Authentication Error (invalid API key) |
| 429 | Rate Limit |
| 500 | Server Error |
Common Errors
1. API Key Error
- Symptom: 401 error
- Solution: Verify the
PERPLEXITY_API_KEYenvironment variable
2. Timeout
- Symptom: Request does not complete
- Solution: Increase
PERPLEXITY_TIMEOUT_MS
3. Proxy Error
- Symptom: Network connection failure
- Solution: Verify proxy settings (when inside corporate network)
Rate Limits
The API has rate limits. When making many requests, ensure appropriate intervals between them.
About Thinking Tokens
The sonar-deep-research and sonar-reasoning-pro models may output their thinking process in <think>...</think> tags before the answer.
To save context tokens, use the --strip-thinking option to remove these tags.
#!/usr/bin/env python3
"""
Perplexity API Client Script
Provides command-line access to Perplexity API for:
- ask: General conversational AI with web search (sonar-pro)
- research: Deep research and analysis (sonar-deep-research)
- reason: Advanced reasoning tasks (sonar-reasoning-pro)
- search: Web search with ranked results
"""
import argparse
import json
import os
import re
import sys
from urllib.request import Request, urlopen
from urllib.error import HTTPError, URLError
def get_api_key():
"""Get API key from environment variable."""
api_key = os.environ.get("PERPLEXITY_API_KEY")
if not api_key:
print("Error: PERPLEXITY_API_KEY environment variable is required", file=sys.stderr)
sys.exit(1)
return api_key
def get_timeout():
"""Get timeout from environment variable (default: 300 seconds)."""
timeout_ms = os.environ.get("PERPLEXITY_TIMEOUT_MS", "300000")
return int(timeout_ms) / 1000
def strip_thinking_tokens(content: str) -> str:
"""Remove <think>...</think> tags from content."""
return re.sub(r'<think>[\s\S]*?</think>', '', content).strip()
def make_api_request(url: str, body: dict, api_key: str) -> dict:
"""Make a POST request to the Perplexity API."""
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}",
}
request = Request(
url,
data=json.dumps(body).encode("utf-8"),
headers=headers,
method="POST"
)
timeout = get_timeout()
try:
with urlopen(request, timeout=timeout) as response:
return json.loads(response.read().decode("utf-8"))
except HTTPError as e:
error_body = e.read().decode("utf-8") if e.fp else "No response body"
print(f"API Error: {e.code} {e.reason}\n{error_body}", file=sys.stderr)
sys.exit(1)
except URLError as e:
print(f"Network Error: {e.reason}", file=sys.stderr)
sys.exit(1)
except TimeoutError:
print(f"Timeout Error: Request did not complete within {timeout}s", file=sys.stderr)
sys.exit(1)
def chat_completion(messages: list, model: str, strip_thinking: bool = False) -> str:
"""
Perform chat completion using Perplexity API.
Args:
messages: List of message dicts with 'role' and 'content'
model: Model to use (sonar-pro, sonar-deep-research, sonar-reasoning-pro)
strip_thinking: If True, remove <think>...</think> tags from response
Returns:
Response content with citations appended
"""
api_key = get_api_key()
url = "https://api.perplexity.ai/chat/completions"
body = {
"model": model,
"messages": messages,
}
data = make_api_request(url, body, api_key)
# Extract message content
content = data.get("choices", [{}])[0].get("message", {}).get("content", "")
# Strip thinking tokens if requested
if strip_thinking:
content = strip_thinking_tokens(content)
# Append citations if available
citations = data.get("citations", [])
if citations:
content += "\n\nCitations:\n"
for i, citation in enumerate(citations, 1):
content += f"[{i}] {citation}\n"
return content
def web_search(query: str, max_results: int = 10, max_tokens_per_page: int = 1024, country: str = None) -> str:
"""
Perform web search using Perplexity Search API.
Args:
query: Search query string
max_results: Maximum number of results (1-20)
max_tokens_per_page: Maximum tokens per page (256-2048)
country: ISO country code for regional results
Returns:
Formatted search results
"""
api_key = get_api_key()
url = "https://api.perplexity.ai/search"
body = {
"query": query,
"max_results": max_results,
"max_tokens_per_page": max_tokens_per_page,
}
if country:
body["country"] = country
data = make_api_request(url, body, api_key)
# Format results
results = data.get("results", [])
if not results:
return "No search results found."
output = f"Found {len(results)} search results:\n\n"
for i, result in enumerate(results, 1):
output += f"{i}. **{result.get('title', 'No title')}**\n"
output += f" URL: {result.get('url', 'N/A')}\n"
if result.get("snippet"):
output += f" {result['snippet']}\n"
if result.get("date"):
output += f" Date: {result['date']}\n"
output += "\n"
return output
def cmd_ask(args):
"""Handle 'ask' command."""
messages = [{"role": "user", "content": args.query}]
result = chat_completion(messages, "sonar-pro")
print(result)
def cmd_research(args):
"""Handle 'research' command."""
messages = [{"role": "user", "content": args.query}]
result = chat_completion(messages, "sonar-deep-research", args.strip_thinking)
print(result)
def cmd_reason(args):
"""Handle 'reason' command."""
messages = [{"role": "user", "content": args.query}]
result = chat_completion(messages, "sonar-reasoning-pro", args.strip_thinking)
print(result)
def cmd_search(args):
"""Handle 'search' command."""
result = web_search(
args.query,
max_results=args.max_results,
max_tokens_per_page=args.max_tokens_per_page,
country=args.country
)
print(result)
def main():
parser = argparse.ArgumentParser(
description="Perplexity API Client",
formatter_class=argparse.RawDescriptionHelpFormatter
)
subparsers = parser.add_subparsers(dest="command", help="Available commands")
# ask command
ask_parser = subparsers.add_parser("ask", help="General question answering with web search")
ask_parser.add_argument("query", help="Your question")
ask_parser.set_defaults(func=cmd_ask)
# research command
research_parser = subparsers.add_parser("research", help="Deep research and comprehensive analysis")
research_parser.add_argument("query", help="Research topic or question")
research_parser.add_argument("--strip-thinking", action="store_true",
help="Remove <think>...</think> tags from response")
research_parser.set_defaults(func=cmd_research)
# reason command
reason_parser = subparsers.add_parser("reason", help="Advanced reasoning and problem-solving")
reason_parser.add_argument("query", help="Reasoning task or problem")
reason_parser.add_argument("--strip-thinking", action="store_true",
help="Remove <think>...</think> tags from response")
reason_parser.set_defaults(func=cmd_reason)
# search command
search_parser = subparsers.add_parser("search", help="Web search with ranked results")
search_parser.add_argument("query", help="Search query")
search_parser.add_argument("--max-results", type=int, default=10,
help="Maximum number of results (1-20, default: 10)")
search_parser.add_argument("--max-tokens-per-page", type=int, default=1024,
help="Maximum tokens per page (256-2048, default: 1024)")
search_parser.add_argument("--country", type=str,
help="ISO country code for regional results (e.g., JP, US)")
search_parser.set_defaults(func=cmd_search)
args = parser.parse_args()
if not args.command:
parser.print_help()
sys.exit(1)
args.func(args)
if __name__ == "__main__":
main()
Related skills
How it compares
Pick perplexity-search over manual browser research when Claude Code sessions need inline, cited web retrieval without context switching.
FAQ
What does perplexity-search do in Claude Code?
perplexity-search runs Perplexity-powered web searches inside Claude Code to gather current facts, citations, competitor moves, and API documentation while developers explore problems before writing code.
When should developers invoke perplexity-search?
Developers should invoke perplexity-search when they need fresh, cited web research on APIs, releases, or market context during Claude Code sessions instead of relying on stale model memory.