Skip to main content
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
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"The ID of the Perplexity model to use
namestr"Perplexity"The name of the model
providerstr"Perplexity"The provider of the model
api_keyOptional[str]NoneThe API key for Perplexity (defaults to PERPLEXITY_API_KEY env var)
base_urlstr"https://api.perplexity.ai/"The base URL for the Perplexity API
max_tokensint1024Maximum number of tokens to generate
top_kOptional[float]NoneNumber of highest probability tokens to consider for generation
collect_metrics_on_completionboolTrueCollect token metrics only from the final streaming chunk (for providers with cumulative token counts)
Perplexity also supports the params of OpenAI.