Authentication
设置您的PERPLEXITY_API_KEY 环境变量。在此处从 Perplexity 获取您的密钥:https://www.perplexity.ai/settings/api。
Example
在您的Agent 中使用 Perplexity:
在此处查看更多示例:../examples/models/perplexity。
Params
Perplexity 还支持 OpenAI 的参数。Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
了解如何使用 Perplexity 和 Agno。
PERPLEXITY_API_KEY 环境变量。在此处从 Perplexity 获取您的密钥:https://www.perplexity.ai/settings/api。
export PERPLEXITY_API_KEY=***
setx PERPLEXITY_API_KEY ***
Agent 中使用 Perplexity:
from agno.agent import Agent, RunResponse
from agno.models.perplexity import Perplexity
agent = Agent(model=Perplexity(id="sonar-pro"), markdown=True)
# Print the response in the terminal
agent.print_response("Share a 2 sentence horror story")
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
id | str | "sonar-pro" | 用于生成响应的特定模型 ID。 |
name | str | "Perplexity" | Perplexity 代理的名称标识符。 |
provider | str | "Perplexity" + id | 模型提供商,结合了“Perplexity”和模型 ID。 |
api_key | Optional[str] | - | 用于向 Perplexity 服务进行身份验证的 API 密钥。从环境变量 PERPLEXITY_API_KEY 中检索。 |
base_url | str | "https://api.perplexity.ai/" | 向 Perplexity 服务发出 API 请求的基 URL。 |
max_tokens | int | 1024 | 在响应中生成的最大 token 数。 |
Perplexity 还支持 OpenAI 的参数。