Perplexity offers powerful language models with built-in web search capabilities, enabling advanced research and Q&A functionality.

Explore Perplexity’s models here.

Authentication

Set your PERPLEXITY_API_KEY environment variable. Get your key from Perplexity here.

export PERPLEXITY_API_KEY=***

Example

Use 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")

View more examples here.

Params

ParameterTypeDefaultDescription
idstr"sonar-pro"The specific model ID used for generating responses.
namestr"Perplexity"The name identifier for the Perplexity agent.
providerstr"Perplexity" + idThe provider of the model, combining "Perplexity" with the model ID.
api_keyOptional[str]-The API key for authenticating requests to the Perplexity service. Retrieved from the environment variable PERPLEXITY_API_KEY.
base_urlstr"https://api.perplexity.ai/"The base URL for making API requests to the Perplexity service.
max_tokensint1024The maximum number of tokens to generate in the response.

Perplexity also supports the params of OpenAI.