> This is a page from the ElevenLabs documentation. For a complete page index, fetch https://elevenlabs.io/docs/llms.txt. For the full documentation in a single file, fetch https://elevenlabs.io/docs/llms-full.txt.

# Perplexity

## 概述

将 ElevenLabs AI 智能体与 Perplexity 连接，以便在对话期间根据实时网页回答问题。智能体可以提问并获取附带引用来源的简短回答，或直接搜索网页和文章。使用此功能可让回答基于比智能体自身知识更新的信息。

## 设置

此集成使用 **Perplexity API 密钥**进行身份验证。

#### 创建 Perplexity 账户

如果还没有账户，请在 [perplexity.ai](https://www.perplexity.ai) 注册。

#### 添加付款方式

Perplexity 按量计费 API 使用。请先在 [API 控制台](https://console.perplexity.ai)添加付款方式，再生成密钥。

#### 生成 API 密钥

前往 [console.perplexity.ai/project/keys](https://console.perplexity.ai/project/keys) 并创建新密钥。密钥以 `pplx-` 开头。

#### 在 ElevenLabs 中连接

在 ElevenLabs 集成设置中，将 Perplexity API 密钥粘贴到 **API Key** 字段。

## 工具

该集成提供两个工具。智能体选择哪个工具取决于来电者需要回答还是来源列表。

| 工具       | 返回内容             |
| -------- | ---------------- |
| `Ask`    | 基于来源 URL 的简短文本回答 |
| `Search` | 包含标题、链接和简短摘录的网页  |

### Ask

Ask 会将问题发送至 Perplexity 的 Agent API，后者会搜索网页并撰写回答。回答会限制为约 3 句纯文本，长度适合朗读，同时会一并返回支持该回答的来源。适用于“本周 X 发生了什么”等问题，即来电者希望听到直接回答。

### Search

Search 会查询 Perplexity 的 Search API，并返回网页本身，每页包含标题、链接和简短摘录。智能体可以将结果限定为特定域名，或限定在过去 1 小时、1 天、1 周、1 个月或 1 年的时间范围内。默认返回 3 个页面，长度适合在通话中朗读；当来电者要求特定数量时，最多可返回 20 个。

### 搜索模式

Search 默认搜索开放网页。Search 工具的 `search_type` 参数用于选择模式，可在配置工具时更改：

| 模式       | 返回内容         |
| -------- | ------------ |
| `web`    | 网页。默认模式。     |
| `fast`   | 网页，针对更低延迟优化。 |
| `people` | 个人资料信息。      |

配置会固定智能体每次调用使用的模式。如果选择 `people`，请编辑 Search 工具的 **Condition prompt**，说明它用于查询个人信息，以便智能体针对正确的问题调用该工具。

## 如何缩短回答

两个工具都会返回特意精简的结果，大小适合来电者在对话中消化。该集成默认将返回页面数量设为 3，请求最短的可用页面摘录，并要求回答模型控制在几句话内。这些都是工具参数；如果智能体需要更完整的背景信息，请在配置时提高这些值。

## 实用链接

* [Perplexity API 文档](https://docs.perplexity.ai)
* [Perplexity API 控制台](https://console.perplexity.ai)
* [Agent API 参考文档](https://docs.perplexity.ai/api-reference/agent-post)
* [Search API 参考文档](https://docs.perplexity.ai/api-reference/search-post)