Token导航 LogoToken导航TokenDH.com
研究检索敏感数据github未标认证来源可访问许可证需确认审计提醒

perplexityPerplexity 搜索

Agent Skill

perplexity 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

465

周安装

19

GitHub Stars

14

下载量

149
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:perplexity(Perplexity 搜索)
来源仓库:https://github.com/itechmeat/llm-code
仓库路径:skills/perplexity
安装命令:
npx skills add https://github.com/itechmeat/llm-code --skill perplexity
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/itechmeat/llm-code --skill perplexity

简介

perplexity 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中快速定位候选结果。

  • 适用于 Perplexity 搜索引擎相关的信息搜索和知识查询工作。
  • 通过关键词搜索、搜索参数配置和结果排序来获取网络信息。
  • 安装命令:npx skills add https://github.com/itechmeat/llm-code --skill perplexity
  • 建议确认权限范围和维护状态,注意是否会触发联网或文件读写操作

SKILL.md

Perplexity API

Build AI applications with real-time web search and grounded responses.

Quick Navigation

  • Models & pricing: references/models.md
  • Search API patterns: references/search-api.md
  • Chat completions guide: references/chat-completions.md
  • Browser sessions API: references/browser.md
  • Embeddings API: references/embeddings.md
  • Structured outputs: references/structured-outputs.md
  • Filters (domain/language/date/location): references/filters.md
  • Media (images/videos/attachments): references/media.md
  • Pro Search: references/pro-search.md
  • Prompting best practices: references/prompting.md

When to Use

  • Need AI responses grounded in current web data
  • Building search-powered applications
  • Research tools requiring citations
  • Real-time Q&A with source verification
  • Document/image analysis with web context

Installation

Install: pip install perplexityai (Python) or npm install @perplexityai/perplexity (TypeScript/JavaScript).

Authentication

# macOS/Linux
export PERPLEXITY_API_KEY="your_api_key_here"

# Windows
setx PERPLEXITY_API_KEY "your_api_key_here"

SDK auto-reads PERPLEXITY_API_KEY environment variable.

Quick Start — Chat Completion

from perplexity import Perplexity

client = Perplexity()

completion = client.chat.completions.create(
    model="sonar-pro",
    messages=[{"role": "user", "content": "What is the latest news on AI?"}]
)

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

Note (v0.28.0): The Python client includes a custom JSON encoder to support additional types in request payloads.

Quick Start — Search API

from perplexity import Perplexity

client = Perplexity()

search = client.search.create(
    query="artificial intelligence trends 2024",
    max_results=5
)

for result in search.results:
    print(f"{result.title}: {result.url}")

Model Selection Guide

ModelUse CaseCost
sonarQuick facts, simple Q&ALowest
sonar-proComplex queries, researchMedium
sonar-reasoning-proMulti-step reasoning, analysisMedium
sonar-deep-researchExhaustive research, reportsHighest

Key Patterns

Streaming Responses

stream = client.chat.completions.create(
    messages=[{"role": "user", "content": "Explain quantum computing"}],
    model="sonar",
    stream=True
)

for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")

Multi-Turn Conversation

messages = [
    {"role": "system", "content": "You are a research assistant."},
    {"role": "user", "content": "What causes climate change?"},
    {"role": "assistant", "content": "Climate change is caused by..."},
    {"role": "user", "content": "What are the solutions?"}
]

completion = client.chat.completions.create(messages=messages, model="sonar")

Web Search Options

completion = client.chat.completions.create(
    messages=[{"role": "user", "content": "Latest renewable energy news"}],
    model="sonar",
    web_search_options={
        "search_recency_filter": "week",
        "search_domain_filter": ["energy.gov", "iea.org"]
    }
)

Pro Search (Multi-Step Research)

# REQUIRES stream=True
completion = client.chat.completions.create(
    model="sonar-pro",
    messages=[{"role": "user", "content": "Research solar panel ROI"}],
    search_type="pro",
    stream=True
)

for chunk in completion:
    print(chunk.choices[0].delta.content or "", end="")

Image Attachment

completion = client.chat.completions.create(
    model="sonar-pro",
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "Describe this image"},
            {"type": "image_url", "image_url": {"url": "https://example.com/image.jpg"}}
        ]
    }]
)

File Attachment (PDF Analysis)

completion = client.chat.completions.create(
    model="sonar-pro",
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "Summarize this document"},
            {"type": "file_url", "file_url": {"url": "https://example.com/report.pdf"}}
        ]
    }]
)

Return Images in Response

completion = client.chat.completions.create(
    model="sonar",
    messages=[{"role": "user", "content": "Mount Everest photos"}],
    return_images=True,
    image_format_filter=["jpg", "png"]
)

Domain Filtering (Search API)

# Allowlist: include only these domains
search = client.search.create(
    query="climate research",
    search_domain_filter=["science.org", "nature.com"]
)

# Denylist: exclude these domains
search = client.search.create(
    query="tech news",
    search_domain_filter=["-reddit.com", "-pinterest.com"]
)

Multi-Query Search

search = client.search.create(
    query=[
        "AI trends 2024",
        "machine learning healthcare",
        "neural networks applications"
    ],
    max_results=5
)

for i, query_results in enumerate(search.results):
    print(f"Query {i+1} results:")
    for result in query_results:
        print(f"  {result.title}")

Structured Outputs (JSON Schema)

from pydantic import BaseModel

class ContactInfo(BaseModel):
    email: str
    phone: str

completion = client.chat.completions.create(
    model="sonar-pro",
    messages=[{"role": "user", "content": "Find contact for Tesla IR"}],
    response_format={
        "type": "json_schema",
        "json_schema": {"schema": ContactInfo.model_json_schema()}
    }
)

contact = ContactInfo.model_validate_json(completion.choices[0].message.content)

Async Operations

import asyncio
from perplexity import AsyncPerplexity

async def main():
    async with AsyncPerplexity() as client:
        tasks = [
            client.search.create(query="AI news"),
            client.search.create(query="tech trends")
        ]
        results = await asyncio.gather(*tasks)

asyncio.run(main())

Rate Limit Handling

import time
from perplexity import RateLimitError

def search_with_retry(client, query, max_retries=3):
    for attempt in range(max_retries):
        try:
            return client.search.create(query=query)
        except RateLimitError:
            if attempt < max_retries - 1:
                time.sleep(2 ** attempt)
            else:
                raise

Response Parameters

ParameterDefaultDescription
temperature0.7Creativity (0-2)
max_tokensvariesResponse length limit
top_p0.9Nucleus sampling
presence_penalty0Reduce repetition (-2 to 2)
frequency_penalty0Reduce word frequency (-2 to 2)

Search API Parameters

ParameterDescription
max_results1-20 results per query
max_tokens_per_pageContent extraction depth (default 2048)
countryISO country code for regional results
search_domain_filterDomain allowlist/denylist (max 20)
search_language_filterISO 639-1 language codes (max 10)

Pricing Quick Reference

Search API: $5/1K requests (no token costs)

Sonar Models (per 1M tokens):

ModelInputOutput
sonar$1$1
sonar-pro$3$15
sonar-reasoning-pro$2$8

Request fees (per 1K requests): $5-$14 depending on search context size.

Critical Prohibitions

  • Do NOT request links/URLs in prompts (use citations field instead — model will hallucinate URLs)
  • Do NOT use recursive JSON schemas (not supported)
  • Do NOT use dict[str, Any] in Pydantic models for structured outputs
  • Do NOT mix allowlist and denylist in search_domain_filter
  • Do NOT exceed 5 queries in multi-query search
  • Do NOT expect first request with new JSON schema to be fast (10-30s warmup)
  • Do NOT use Pro Search without stream=True (will fail)
  • Do NOT send images to sonar-deep-research (not supported)
  • Do NOT include data: prefix for file attachments base64 (only for images)
  • Do NOT try to control search via prompts (use API parameters instead)

Error Handling

import perplexity

try:
    completion = client.chat.completions.create(...)
except perplexity.BadRequestError as e:
    print(f"Invalid parameters: {e}")
except perplexity.RateLimitError:
    print("Rate limited, retry later")
except perplexity.APIStatusError as e:
    print(f"API error: {e.status_code}")

OpenAI SDK Compatibility

Perplexity supports OpenAI Chat Completions format. Use OpenAI client by pointing to Perplexity endpoint.

Links

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

38.04%
按下载量换算57

Claude

27.7%
按下载量换算41

Cursor

21.09%
按下载量换算31

Gemini CLI

9.47%
按下载量换算14

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills