Skip to content

Commit df68932

Browse files
Add perplexity docs to OpenAI compatible models section (#930)
1 parent ef80e23 commit df68932

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

docs/models.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,24 @@ agent = Agent(model)
624624
...
625625
```
626626

627+
### Perplexity
628+
629+
Follow the Perplexity [getting started](https://docs.perplexity.ai/guides/getting-started)
630+
guide to create an API key. Then, you can query the Perplexity API with the following:
631+
632+
```py {title="perplexity_model_init.py"}
633+
from pydantic_ai import Agent
634+
from pydantic_ai.models.openai import OpenAIModel
635+
636+
model = OpenAIModel(
637+
'sonar-pro',
638+
base_url='https://api.perplexity.ai',
639+
api_key='your-perplexity-api-key',
640+
)
641+
agent = Agent(model)
642+
...
643+
```
644+
627645
## Implementing Custom Models
628646

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

0 commit comments

Comments
 (0)