> ## Documentation Index
> Fetch the complete documentation index at: https://docs.definable.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Perplexity

> Use Perplexity Sonar models with built-in search.

## Setup

```bash theme={null}
export PERPLEXITY_API_KEY="pplx-..."
```

## Basic Usage

```python theme={null}
from definable.model.perplexity import Perplexity
from definable.model.message import Message

model = Perplexity(id="sonar-pro")
response = model.invoke(
    messages=[Message(role="user", content="What happened in AI this week?")],
    assistant_message=Message(role="assistant", content=""),
)
print(response.content)
```

## String Shorthand

```python theme={null}
agent = Agent(model="perplexity/sonar-pro")
```

## Parameters

<ParamField path="id" type="str" default="sonar-pro">
  Model identifier. Common values: `sonar-pro`, `sonar`.
</ParamField>

<ParamField path="api_key" type="str">
  Perplexity API key. Defaults to `PERPLEXITY_API_KEY`.
</ParamField>

## Imports

```python theme={null}
from definable.model.perplexity import Perplexity
```
