Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.perplexity.ai/llms.txt

Use this file to discover all available pages before exploring further.

Overview

Agno is an open-source Python framework for building agents, teams, and workflows with first-class support for 40+ model providers. Agno ships a native Perplexity model class so you can drop Perplexity’s web-grounded Sonar models into any Agno Agent with a single import.
Agno provides a unified Agent abstraction, a tools system, and a multi-agent team/workflow runtime. Learn more at agno.com.

Installation

pip install agno openai
The Perplexity model extends Agno’s OpenAI-compatible interface, so the openai SDK is required as a transitive dependency.

API Key Setup

Set your Perplexity API key as an environment variable:
export PERPLEXITY_API_KEY="your_api_key_here"

Get API Key

Generate your Perplexity API key from the API portal.

Quick Start

from agno.agent import Agent
from agno.models.perplexity import Perplexity

agent = Agent(
    model=Perplexity(id="sonar-pro"),
    markdown=True,
)

agent.print_response("What launched at the latest Perplexity event?")
The default model is sonar. Pass any Perplexity model id via the id parameter — sonar, sonar-pro, sonar-reasoning, sonar-reasoning-pro, or sonar-deep-research.

Parameters

The Perplexity model accepts the standard OpenAI parameters plus a few Perplexity-specific options:
ParameterTypeDefaultDescription
idstr"sonar"Perplexity model id
api_keyOptional[str]NoneFalls back to PERPLEXITY_API_KEY
base_urlstr"https://api.perplexity.ai/"API base URL
max_tokensint1024Maximum tokens to generate
top_kOptional[float]NoneTop-K sampling
retriesint0Retry attempts before raising ModelProviderError
delay_between_retriesint1Seconds between retries
exponential_backoffboolFalseDouble the delay on each retry
All OpenAI-compatible parameters (temperature, top_p, frequency_penalty, etc.) are also supported.

Structured Output

from pydantic import BaseModel
from agno.agent import Agent
from agno.models.perplexity import Perplexity

class Summary(BaseModel):
    headline: str
    bullets: list[str]

agent = Agent(
    model=Perplexity(id="sonar-pro"),
    response_model=Summary,
)

result = agent.run("Summarize this week's top AI research papers.")
print(result.content.headline)
for bullet in result.content.bullets:
    print(f"- {bullet}")

Streaming

from agno.agent import Agent
from agno.models.perplexity import Perplexity

agent = Agent(model=Perplexity(id="sonar"))

for chunk in agent.run("Explain quantum entanglement", stream=True):
    print(chunk.content, end="", flush=True)

Notes on Tool Calling

Perplexity models support tool calling through Agno, but Sonar models do not natively expose function-calling in the same first-class way as some other providers. Tool use through Perplexity may be less reliable than with OpenAIChat or Claude. For agent workflows that need rich tool orchestration on top of Perplexity-grounded answers, consider routing through the Agent API with web_search and fetch_url tools.

Agno Perplexity Docs

Official Agno Perplexity provider documentation.

Agno API Reference

Full parameter reference for the Perplexity model.

Perplexity Models

Available Perplexity models and capabilities.

Agno Docs

Learn more about agents, teams, and workflows in Agno.

Support

Need help with the integration?