Skip to main content
The Perplexity model provides access to Perplexity’s language models.

Parameters

ParameterTypeDefaultDescription
idstr"sonar"The ID of the Perplexity model to use
namestr"Perplexity"The name of the model
providerstr"Perplexity"The provider of the model
api_keyOptional[str]NoneThe API key for Perplexity (defaults to PERPLEXITY_API_KEY env var)
base_urlstr"https://api.perplexity.ai/"The base URL for the Perplexity API
max_tokensint1024Maximum number of tokens to generate
top_kOptional[float]NoneNumber of highest probability tokens to consider for generation
collect_metrics_on_completionboolTrueCollect token metrics only from the final streaming chunk (for providers with cumulative token counts)
retriesint0Number of retries to attempt before raising a ModelProviderError
delay_between_retriesint1Delay between retries, in seconds
exponential_backoffboolFalseIf True, the delay between retries is doubled each time
Perplexity extends the OpenAI-compatible interface and supports most parameters from OpenAI.