Documentation Index
Fetch the complete documentation index at: https://docs.perplexity.ai/llms.txt
Use this file to discover all available pages before exploring further.
Overview
LiteLLM is a Python SDK and proxy server that gives you a single OpenAI-compatible interface to 100+ LLM providers. Both Perplexity’s Sonar models and the Agent API (with third-party models like GPT-5, Claude, and Gemini routed through Perplexity) are first-class providers in LiteLLM.LiteLLM lets you swap providers without rewriting code, run a self-hosted proxy that fronts every model behind one API key, and track spend, latency, and errors per provider. Learn more at litellm.ai.
Installation
API Key Setup
LiteLLM uses two environment variables depending on which Perplexity endpoint you’re calling:Get API Key
Generate your Perplexity API key from the API portal.
Sonar Chat Completions
Call Perplexity’s Sonar models throughlitellm.completion with the perplexity/ model prefix:
Streaming
Reasoning Effort
For reasoning-capable Sonar models, passreasoning_effort to control depth:
Supported Sonar Models
| Model | LiteLLM Identifier |
|---|---|
sonar | perplexity/sonar |
sonar-pro | perplexity/sonar-pro |
sonar-reasoning | perplexity/sonar-reasoning |
sonar-reasoning-pro | perplexity/sonar-reasoning-pro |
sonar-deep-research | perplexity/sonar-deep-research |
Agent API
Uselitellm.responses to call the Agent API, which routes through Perplexity to third-party models with tool orchestration and presets.
Presets
fast-search, pro-search, deep-research, advanced-deep-research.
Tool Use (web_search and fetch_url)
Structured Outputs
Supported Third-Party Models via Agent API
| Provider | Models |
|---|---|
| OpenAI | perplexity/openai/gpt-5.5, perplexity/openai/gpt-5.4, perplexity/openai/gpt-5.4-mini, perplexity/openai/gpt-5.2, perplexity/openai/gpt-5.1, perplexity/openai/gpt-5-mini |
| Anthropic | perplexity/anthropic/claude-opus-4-7, perplexity/anthropic/claude-opus-4-6, perplexity/anthropic/claude-sonnet-4-6, perplexity/anthropic/claude-opus-4-5, perplexity/anthropic/claude-sonnet-4-5, perplexity/anthropic/claude-haiku-4-5 |
perplexity/google/gemini-3.1-pro-preview, perplexity/google/gemini-3-flash-preview, perplexity/google/gemini-3.1-flash-lite | |
| xAI | perplexity/xai/grok-4.20-non-reasoning |
| Perplexity | perplexity/perplexity/sonar |
LiteLLM Proxy
Run LiteLLM as a self-hosted proxy that fronts Perplexity (and any other provider) behind a single OpenAI-compatible endpoint.config.yaml
Start the Proxy
Call the Proxy
Links & Resources
LiteLLM Perplexity Docs
Official LiteLLM Perplexity provider docs.
LiteLLM Docs
Full LiteLLM documentation.
Perplexity Agent API
Agent API reference and presets.
Perplexity Models
Available Sonar and Agent API models.
Support
Need help with the integration?- Browse the LiteLLM documentation
- Review our FAQ