From 6d6e96cf7a16e308278892f7f2190856b4cf0010 Mon Sep 17 00:00:00 2001 From: sydney-runkle Date: Fri, 14 Feb 2025 15:29:40 -0500 Subject: [PATCH] adding perplexity docs --- docs/models.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/models.md b/docs/models.md index ec3288560a..9daeaf6173 100644 --- a/docs/models.md +++ b/docs/models.md @@ -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.