examples/provider-perplexity/README.md
This example demonstrates how to use Perplexity's search-augmented chat models to get up-to-date answers with citations, structured outputs, and specialized reasoning.
You can run this example with:
npx promptfoo@latest init --example provider-perplexity
cd provider-perplexity
This example requires the following environment variables:
PERPLEXITY_API_KEY - Your Perplexity API key from Perplexity SettingsOPENAI_API_KEY - Your OpenAI API key (for comparison model in basic example)You can set these in a .env file or directly in your environment:
export PERPLEXITY_API_KEY=your_api_key_here
export OPENAI_API_KEY=your_api_key_here
This example includes multiple configuration files to demonstrate different Perplexity features:
promptfooconfig.yaml)Compares different Perplexity search models against a traditional non-search model (GPT-4o-mini):
sonar: Lightweight search modelsonar-pro: Advanced search model with high contextsonar-reasoning: Fast reasoning model with step-by-step thinkingnpx promptfoo@latest eval -c promptfooconfig.yaml
promptfooconfig.structured-output.yaml)Demonstrates Perplexity's structured output capabilities:
npx promptfoo@latest eval -c promptfooconfig.structured-output.yaml
promptfooconfig.search-filters.yaml)Shows how to use advanced search filtering options:
npx promptfoo@latest eval -c promptfooconfig.search-filters.yaml
promptfooconfig.research-reasoning.yaml)Demonstrates specialized models for research and reasoning:
sonar-deep-research: Comprehensive research modelsonar-reasoning-pro: Advanced reasoning with Chain of Thoughtr1-1776: Offline model without search capabilitiesnpx promptfoo@latest eval -c promptfooconfig.research-reasoning.yaml
After initializing the example, you can run any of the configurations:
cd provider-perplexity
npx promptfoo@latest eval -c <config-file.yaml>
npx promptfoo@latest view
These examples will show you how to: