perplexity-search by davila7/claude-code-templates
npx skills add https://github.com/davila7/claude-code-templates --skill perplexity-search通过 LiteLLM 和 OpenRouter 使用 Perplexity 模型执行 AI 驱动的网络搜索。Perplexity 提供基于网络的实时答案并附有来源引用,非常适合查找最新信息、近期科学文献以及模型训练数据截止日期之后的事实。
此技能通过 OpenRouter 提供对所有 Perplexity 模型的访问,仅需一个 API 密钥(无需单独的 Perplexity 账户)。
在以下情况使用此技能:
请勿用于:
# 设置 API 密钥
export OPENROUTER_API_KEY='sk-or-v1-your-key-here'
# 或使用设置脚本
python scripts/setup_env.py --api-key sk-or-v1-your-key-here
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
uv pip install litellm
python scripts/perplexity_search.py --check-setup
有关详细设置说明、故障排除和安全最佳实践,请参阅 references/openrouter_setup.md。
简单搜索:
python scripts/perplexity_search.py "What are the latest developments in CRISPR gene editing?"
保存结果:
python scripts/perplexity_search.py "Recent CAR-T therapy clinical trials" --output results.json
使用特定模型:
python scripts/perplexity_search.py "Compare mRNA and viral vector vaccines" --model sonar-pro-search
详细输出:
python scripts/perplexity_search.py "Quantum computing for drug discovery" --verbose
通过 --model 参数访问模型:
模型选择指南:
sonar-prosonar-pro-searchsonar-reasoning-prosonarsonar有关详细比较、用例、定价和性能特征,请参阅 references/model_comparison.md。
良好示例:
不佳示例:
Perplexity 搜索实时网络数据:
为获得高质量结果,请提及偏好的来源:
将复杂问题分解为清晰的组成部分:
示例: "What improvements does AlphaFold3 offer over AlphaFold2 for protein structure prediction, according to research published between 2023 and 2024? Include specific accuracy metrics and benchmarks."
有关查询设计、领域特定模式和高级技术的全面指导,请参阅 references/search_strategies.md。
python scripts/perplexity_search.py \
"What does recent research (2023-2024) say about the role of gut microbiome in Parkinson's disease? Focus on peer-reviewed studies and include specific bacterial species identified." \
--model sonar-pro
python scripts/perplexity_search.py \
"How to implement real-time data streaming from Kafka to PostgreSQL using Python? Include considerations for handling backpressure and ensuring exactly-once semantics." \
--model sonar-reasoning-pro
python scripts/perplexity_search.py \
"Compare PyTorch versus TensorFlow for implementing transformer models in terms of ease of use, performance, and ecosystem support. Include benchmarks from recent studies." \
--model sonar-pro-search
python scripts/perplexity_search.py \
"What is the evidence for intermittent fasting in managing type 2 diabetes in adults? Focus on randomized controlled trials and report HbA1c changes and weight loss outcomes." \
--model sonar-pro
python scripts/perplexity_search.py \
"What are the key trends in single-cell RNA sequencing technology over the past 5 years? Highlight improvements in throughput, cost, and resolution, with specific examples." \
--model sonar-pro
将 perplexity_search.py 作为模块使用:
from scripts.perplexity_search import search_with_perplexity
result = search_with_perplexity(
query="What are the latest CRISPR developments?",
model="openrouter/perplexity/sonar-pro",
max_tokens=4000,
temperature=0.2,
verbose=False
)
if result["success"]:
print(result["answer"])
print(f"Tokens used: {result['usage']['total_tokens']}")
else:
print(f"Error: {result['error']}")
# 保存到 JSON
python scripts/perplexity_search.py "query" --output results.json
# 使用 jq 处理
cat results.json | jq '.answer'
cat results.json | jq '.usage'
为多个查询创建脚本:
#!/bin/bash
queries=(
"CRISPR developments 2024"
"mRNA vaccine technology advances"
"AlphaFold3 accuracy improvements"
)
for query in "${queries[@]}"; do
echo "Searching: $query"
python scripts/perplexity_search.py "$query" --output "results_$(echo $query | tr ' ' '_').json"
sleep 2 # 速率限制
done
Perplexity 模型有不同的定价层级:
每次查询的大致成本:
成本优化策略:
sonarsonar-prosonar-pro-search--max-tokens 以限制响应长度错误:"OpenRouter API key not configured"
解决方案:
export OPENROUTER_API_KEY='sk-or-v1-your-key-here'
# 或运行设置脚本
python scripts/setup_env.py --api-key sk-or-v1-your-key-here
错误:"LiteLLM not installed"
解决方案:
uv pip install litellm
错误:"Rate limit exceeded"
解决方案:
错误:"Insufficient credits"
解决方案:
有关全面的故障排除指南,请参阅 references/openrouter_setup.md。
此技能与其他科学技能相辅相成:
与 literature-review 技能结合使用:
与 scientific-writing 技能结合使用:
与 hypothesis-generation 技能结合使用:
与 scientific-critical-thinking 技能结合使用:
--max-tokens 控制成本脚本:
scripts/perplexity_search.py:带有 CLI 界面的主搜索脚本scripts/setup_env.py:环境设置和验证助手参考资料:
references/search_strategies.md:全面的查询设计指南references/model_comparison.md:详细的模型比较和选择指南references/openrouter_setup.md:完整的设置、故障排除和安全指南资产:
assets/.env.example:示例环境文件模板OpenRouter:
LiteLLM:
Perplexity:
# LiteLLM 用于 API 访问
uv pip install litellm
# 用于 .env 文件支持
uv pip install python-dotenv
# 用于 JSON 处理(通常预装)
uv pip install jq
必需:
OPENROUTER_API_KEY:您的 OpenRouter API 密钥可选:
DEFAULT_MODEL:默认使用的模型(默认:sonar-pro)DEFAULT_MAX_TOKENS:默认最大令牌数(默认:4000)DEFAULT_TEMPERATURE:默认温度(默认:0.2)此技能提供:
执行 AI 驱动的网络搜索,以查找当前信息、最新研究以及带有来源引用的可靠答案。
每周安装
260
仓库
GitHub 星标
22.6K
首次出现
Jan 21, 2026
安全审计
安装于
opencode212
gemini-cli200
codex189
claude-code189
cursor178
github-copilot178
Perform AI-powered web searches using Perplexity models through LiteLLM and OpenRouter. Perplexity provides real-time, web-grounded answers with source citations, making it ideal for finding current information, recent scientific literature, and facts beyond the model's training data cutoff.
This skill provides access to all Perplexity models through OpenRouter, requiring only a single API key (no separate Perplexity account needed).
Use this skill when:
Do not use for:
Get OpenRouter API key :
Configure environment :
# Set API key
export OPENROUTER_API_KEY='sk-or-v1-your-key-here'
# Or use setup script
python scripts/setup_env.py --api-key sk-or-v1-your-key-here
Install dependencies :
uv pip install litellm
Verify setup :
python scripts/perplexity_search.py --check-setup
See references/openrouter_setup.md for detailed setup instructions, troubleshooting, and security best practices.
Simple search:
python scripts/perplexity_search.py "What are the latest developments in CRISPR gene editing?"
Save results:
python scripts/perplexity_search.py "Recent CAR-T therapy clinical trials" --output results.json
Use specific model:
python scripts/perplexity_search.py "Compare mRNA and viral vector vaccines" --model sonar-pro-search
Verbose output:
python scripts/perplexity_search.py "Quantum computing for drug discovery" --verbose
Access models via --model parameter:
Model selection guide:
sonar-prosonar-pro-searchsonar-reasoning-prosonarsonarSee references/model_comparison.md for detailed comparison, use cases, pricing, and performance characteristics.
Good examples:
Bad examples:
Perplexity searches real-time web data:
For high-quality results, mention source preferences:
Break complex questions into clear components:
Example: "What improvements does AlphaFold3 offer over AlphaFold2 for protein structure prediction, according to research published between 2023 and 2024? Include specific accuracy metrics and benchmarks."
See references/search_strategies.md for comprehensive guidance on query design, domain-specific patterns, and advanced techniques.
python scripts/perplexity_search.py \
"What does recent research (2023-2024) say about the role of gut microbiome in Parkinson's disease? Focus on peer-reviewed studies and include specific bacterial species identified." \
--model sonar-pro
python scripts/perplexity_search.py \
"How to implement real-time data streaming from Kafka to PostgreSQL using Python? Include considerations for handling backpressure and ensuring exactly-once semantics." \
--model sonar-reasoning-pro
python scripts/perplexity_search.py \
"Compare PyTorch versus TensorFlow for implementing transformer models in terms of ease of use, performance, and ecosystem support. Include benchmarks from recent studies." \
--model sonar-pro-search
python scripts/perplexity_search.py \
"What is the evidence for intermittent fasting in managing type 2 diabetes in adults? Focus on randomized controlled trials and report HbA1c changes and weight loss outcomes." \
--model sonar-pro
python scripts/perplexity_search.py \
"What are the key trends in single-cell RNA sequencing technology over the past 5 years? Highlight improvements in throughput, cost, and resolution, with specific examples." \
--model sonar-pro
Use perplexity_search.py as a module:
from scripts.perplexity_search import search_with_perplexity
result = search_with_perplexity(
query="What are the latest CRISPR developments?",
model="openrouter/perplexity/sonar-pro",
max_tokens=4000,
temperature=0.2,
verbose=False
)
if result["success"]:
print(result["answer"])
print(f"Tokens used: {result['usage']['total_tokens']}")
else:
print(f"Error: {result['error']}")
# Save to JSON
python scripts/perplexity_search.py "query" --output results.json
# Process with jq
cat results.json | jq '.answer'
cat results.json | jq '.usage'
Create a script for multiple queries:
#!/bin/bash
queries=(
"CRISPR developments 2024"
"mRNA vaccine technology advances"
"AlphaFold3 accuracy improvements"
)
for query in "${queries[@]}"; do
echo "Searching: $query"
python scripts/perplexity_search.py "$query" --output "results_$(echo $query | tr ' ' '_').json"
sleep 2 # Rate limiting
done
Perplexity models have different pricing tiers:
Approximate costs per query:
Cost optimization strategies:
sonar for simple fact lookupssonar-pro for most queriessonar-pro-search for complex analysis--max-tokens to limit response lengthError : "OpenRouter API key not configured"
Solution :
export OPENROUTER_API_KEY='sk-or-v1-your-key-here'
# Or run setup script
python scripts/setup_env.py --api-key sk-or-v1-your-key-here
Error : "LiteLLM not installed"
Solution :
uv pip install litellm
Error : "Rate limit exceeded"
Solutions :
Error : "Insufficient credits"
Solution :
See references/openrouter_setup.md for comprehensive troubleshooting guide.
This skill complements other scientific skills:
Use with literature-review skill:
Use with scientific-writing skill:
Use with hypothesis-generation skill:
Use with scientific-critical-thinking skill:
--max-tokens to control costsScripts:
scripts/perplexity_search.py: Main search script with CLI interfacescripts/setup_env.py: Environment setup and validation helperReferences:
references/search_strategies.md: Comprehensive query design guidereferences/model_comparison.md: Detailed model comparison and selection guidereferences/openrouter_setup.md: Complete setup, troubleshooting, and security guideAssets:
assets/.env.example: Example environment file templateOpenRouter:
LiteLLM:
Perplexity:
# LiteLLM for API access
uv pip install litellm
# For .env file support
uv pip install python-dotenv
# For JSON processing (usually pre-installed)
uv pip install jq
Required:
OPENROUTER_API_KEY: Your OpenRouter API keyOptional:
DEFAULT_MODEL: Default model to use (default: sonar-pro)DEFAULT_MAX_TOKENS: Default max tokens (default: 4000)DEFAULT_TEMPERATURE: Default temperature (default: 0.2)This skill provides:
Conduct AI-powered web searches to find current information, recent research, and grounded answers with source citations.
Weekly Installs
260
Repository
GitHub Stars
22.6K
First Seen
Jan 21, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykFail
Installed on
opencode212
gemini-cli200
codex189
claude-code189
cursor178
github-copilot178
AI Elements:基于shadcn/ui的AI原生应用组件库,快速构建对话界面
56,200 周安装
React useEffect 使用指南:何时需要与何时避免 Effect 的最佳实践
272 周安装
Seedance 2.0 分镜提示词生成器 - AI视频创作助手,多模态输入生成专业分镜
272 周安装
App Store Connect ASO 审核工具:自动化元数据检查和关键词差距分析
272 周安装
SQLAlchemy Alembic 专家最佳实践与代码审查指南 - 生产级数据库迁移优化
272 周安装
Django部署Google Cloud SQL PostgreSQL教程:10分钟快速配置与生产环境设置
272 周安装
代码复杂度分析工具:Python/Go代码质量检测与重构指南
273 周安装