Skip to content

Commit

Permalink
Add perplexity docs to OpenAI compatible models section (#930)
Browse files Browse the repository at this point in the history
  • Loading branch information
sydney-runkle authored Feb 17, 2025
1 parent ef80e23 commit df68932
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions docs/models.md
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,24 @@ agent = Agent(model)
...
```

### Perplexity

Follow the Perplexity [getting started](https://docs.perplexity.ai/guides/getting-started)
guide to create an API key. Then, you can query the Perplexity API with the following:

```py {title="perplexity_model_init.py"}
from pydantic_ai import Agent
from pydantic_ai.models.openai import OpenAIModel

model = OpenAIModel(
'sonar-pro',
base_url='https://api.perplexity.ai',
api_key='your-perplexity-api-key',
)
agent = Agent(model)
...
```

## Implementing Custom Models

To implement support for models not already supported, you will need to subclass the [`Model`][pydantic_ai.models.Model] abstract base class.
Expand Down

0 comments on commit df68932

Please sign in to comment.