Overview
The official Perplexity SDKs provide convenient access to the Perplexity APIs from Python 3.10+ and Node.js 20+ applications. Both SDKs include type definitions for all request parameters and response fields, with both synchronous and asynchronous clients. Use the SDKs with the Agent API for third-party models with web search tools and effort levels, Search for ranked web search results, Embeddings for standard and contextualized text embeddings, and Decisions for typed answers with probabilities. The client also covers Agent API batches, files, skills, and models, plus the legacy Sonar API (chat.completions and async chat completions).
Building a coding agent that writes its own retrieval code? The Search SDK is a separate, agents-first Python package for batched web search and page snippets. Use this SDK for general app integrations.
Available APIs
Agent API
Third-party models from OpenAI, Anthropic, Google, and more with effort levels and web search tools.
Search
Ranked web search results with filtering, multi-query support, and domain controls.
Embeddings
Generate high-quality text embeddings for semantic search and RAG.
Decisions
Get yes/no, choice, and score answers with probabilities.
Installation
Install the SDK for your preferred language:Authentication
Get your Perplexity API Key
Generate a new key on the API Keys page in the API Console.
- Windows
- MacOS/Linux
Using Environment Variables
You can use the environment variable directly:.env file:
Agent API
Get started with third-party models
Search
Get started with web search
Embeddings
Get started with text embeddings
Decisions
Get started with decisions
Resources
Python Package
Install from PyPI with pip
Node.js and TypeScript Package
Install from npm registry