Authentication
Set yourPERPLEXITY_API_KEY environment variable. Get your key from Perplexity here.
Example
UsePerplexity with your Agent:
View more examples here.
Params
Perplexity also supports the params of OpenAI.Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
You are viewing v1 docs. For the latest documentation, visit docs.agno.com
Learn how to use Perplexity with Agno.
PERPLEXITY_API_KEY environment variable. Get your key from Perplexity here.
export PERPLEXITY_API_KEY=***
setx PERPLEXITY_API_KEY ***
Perplexity with your Agent:
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")
| Parameter | Type | Default | Description |
|---|---|---|---|
id | str | "sonar-pro" | The specific model ID used for generating responses. |
name | str | "Perplexity" | The name identifier for the Perplexity agent. |
provider | str | "Perplexity" + id | The provider of the model, combining "Perplexity" with the model ID. |
api_key | Optional[str] | - | The API key for authenticating requests to the Perplexity service. Retrieved from the environment variable PERPLEXITY_API_KEY. |
base_url | str | "https://api.perplexity.ai/" | The base URL for making API requests to the Perplexity service. |
max_tokens | int | 1024 | The maximum number of tokens to generate in the response. |
Perplexity also supports the params of OpenAI.Was this page helpful?