> ## Documentation Index
> Fetch the complete documentation index at: https://aisa.one/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Perplexity Search

> 为自治 Agent 提供带引用的网页答案与深度研究报告。通过一个 AIsa API key 使用 Perplexity Sonar 四档能力：快速答案、综合分析、多步推理和完整深度研究。

[在 GitHub 上查看 ->](https://github.com/AIsa-team/agent-skills/tree/main/perplexity-search)

**为自治 Agent 提供带引用的网页答案与深度研究。** 使用一个 `AISA_API_KEY` 访问完整 Perplexity Sonar 系列能力，从秒级查询到详尽研究报告都可覆盖。

## 安装

如果还没有安装 AIsa CLI，请先安装：

```bash theme={null}
npm install -g @aisa-one/cli
```

然后安装该技能：

```bash theme={null}
aisa skills install perplexity-search
```

## Agent 可以用它做什么？

<CardGroup cols={2}>
  <Card title="快速事实回答" icon="bolt">
    “OpenAI 最新版本发布了什么？”——几秒内返回带引用的答案。
  </Card>

  <Card title="对比分析" icon="scale-balanced">
    “按价格和功能比较 2026 年排名前三的 AI coding agents。”
  </Card>

  <Card title="多步推理" icon="diagram-project">
    “分析采用 x402 与传统 API key 计费的取舍。”
  </Card>

  <Card title="深度研究报告" icon="microscope">
    “生成一篇 2,000 字的 agentic browser frameworks 结构化报告。”
  </Card>

  <Card title="实时新闻" icon="newspaper">
    “总结本周 AI 基础设施公告。”
  </Card>

  <Card title="决策支持" icon="list-check">
    “我们是否应该采用这个库？请引用采用情况、issue 和替代方案。”
  </Card>
</CardGroup>

## 模型档位

| Model                 | 适合场景               |
| --------------------- | ------------------ |
| `sonar`               | 快速回答简单问题，并附带引用（秒级） |
| `sonar-pro`           | 综合、对比、更长答案和更多来源    |
| `sonar-reasoning-pro` | 多步分析推理、取舍分析、技术深挖   |
| `sonar-deep-research` | 详尽长文报告；可接受数分钟处理时间  |

## 快速开始

```bash theme={null}
export AISA_API_KEY="your-key"
```

### Sonar（快速答案）

```bash theme={null}
curl -X POST "https://api.aisa.one/apis/v1/perplexity/sonar" \
  -H "Authorization: Bearer $AISA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sonar",
    "messages": [{"role": "user", "content": "What is the Model Context Protocol?"}]
  }'
```

### Sonar Pro（综合分析）

```bash theme={null}
curl -X POST "https://api.aisa.one/apis/v1/perplexity/sonar-pro" \
  -H "Authorization: Bearer $AISA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sonar-pro",
    "messages": [{"role": "user", "content": "Compare the performance of top AI coding agents in 2026."}]
  }'
```

### Sonar Reasoning Pro（分析推理）

```bash theme={null}
curl -X POST "https://api.aisa.one/apis/v1/perplexity/sonar-reasoning-pro" \
  -H "Authorization: Bearer $AISA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sonar-reasoning-pro",
    "messages": [{"role": "user", "content": "Analyze the tradeoffs of adopting x402 vs. traditional billing."}]
  }'
```

### Sonar Deep Research

```bash theme={null}
curl -X POST "https://api.aisa.one/apis/v1/perplexity/sonar-deep-research" \
  -H "Authorization: Bearer $AISA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sonar-deep-research",
    "messages": [{"role": "user", "content": "Create a 2,000-word deep research report on autonomous browser agents."}]
  }'
```

<Tip>
  Deep research 可以接受更长处理时间，Python 客户端也实现了自动重试。对时效敏感的请求，建议降级使用 `sonar-pro` 或 `sonar-reasoning-pro`，不要长时间等待。
</Tip>

## Python 客户端

```bash theme={null}
# 快速答案
python3 scripts/perplexity_search_client.py sonar --query "What is MCP?"

# 综合分析
python3 scripts/perplexity_search_client.py sonar-pro --query "Compare AI coding agents 2026"

# 分析推理
python3 scripts/perplexity_search_client.py sonar-reasoning-pro --query "x402 tradeoffs"

# 深度研究（允许较长处理时间）
python3 scripts/perplexity_search_client.py sonar-deep-research --query "Agentic payments landscape"

# 可选 system message，用于控制输出格式
python3 scripts/perplexity_search_client.py sonar-pro \
  --query "Explain RAG" \
  --system "Answer in bullet points with citations inline as [1], [2]..."
```

## 端点参考

| Endpoint                          | Method | 用途                                                                                   |
| --------------------------------- | ------ | ------------------------------------------------------------------------------------ |
| `/perplexity/sonar`               | POST   | [Sonar — 快速答案](/api-reference/perplexity/post_perplexity-sonar)                      |
| `/perplexity/sonar-pro`           | POST   | [Sonar Pro — 综合分析](/api-reference/perplexity/post_perplexity-sonar-pro)              |
| `/perplexity/sonar-reasoning-pro` | POST   | [Sonar Reasoning Pro](/api-reference/perplexity/post_perplexity-sonar-reasoning-pro) |
| `/perplexity/sonar-deep-research` | POST   | [Sonar Deep Research](/api-reference/perplexity/post_perplexity-sonar-deep-research) |

## 开始使用

1. 在 [aisa.one](https://aisa.one) 注册（新账户有 \$2 免费额度）。
2. 从控制台生成 API key。
3. `export AISA_API_KEY="your-key"` 并安装技能：
   ```bash theme={null}
   npm install -g @aisa-one/cli
   aisa skills install perplexity-search
   ```

## 相关

<CardGroup cols={3}>
  <Card title="Perplexity API reference" icon="sparkles" href="/api-reference/perplexity/post_perplexity-sonar">
    四个 Sonar 端点及交互式 Playground。
  </Card>

  <Card title="Pricing" icon="dollar-sign" href="/guides/pricing/ai-model-pricing-llm-inference">
    各 Sonar 变体的 token 价格。
  </Card>

  <Card title="Error Codes" icon="triangle-exclamation" href="/api-reference/errors">
    处理超时和上游错误。
  </Card>
</CardGroup>
