LiteLLM integration for Perplexity API providing a unified interface to call Perplexity Sonar models alongside 100+ other LLM providers with consistent API format, fallback routing, and cost tracking.
## Overview
LiteLLM provides a unified Python/TypeScript interface to call Perplexity alongside 100+ other LLM providers. Use the same code to call Perplexity, OpenAI, Anthropic, and more with automatic fallback and load balancing.
## Supported Models
- perplexity/sonar
- perplexity/sonar-pro
- perplexity/sonar-reasoning-pro
- perplexity/sonar-deep-research
## Key Features
- Unified API across all providers
- Automatic fallback chains (e.g., Perplexity -> OpenAI -> Anthropic)
- Load balancing across models
- Cost tracking and budgeting
- Token usage monitoring
- OpenAI-compatible API format
- Streaming support
## Usage
```python
from litellm import completion
response = completion(
model="perplexity/sonar-pro",
messages=[{"role": "user", "content": "What's new in AI today?"}]
)
print(response.choices[0].message.content)
```
## Configuration
Set PERPLEXITY_API_KEY environment variable. LiteLLM automatically routes requests to Perplexity's API endpoint.
## Proxy Server
LiteLLM can run as a proxy server, exposing a unified OpenAI-compatible endpoint that routes to Perplexity and other providers based on model name.Reads and summarizes scientific papers in plain language
Monitors supply chain disruptions and logistics developments globally
Analyzes job market conditions, salary trends, and skill demand
Monitors clinical trials for specific conditions or treatments
Monitors content for outdated information and suggests updates
Collects cybersecurity threat intelligence from open sources