skillfed

perplexityai

perplexityai v0.43.3 1.2M downloads/30d#4,273 on PyPI69
Permissive license Apache-2.0 Active released

What it is and what it does

Perplexityai is a Python client for the Perplexity REST API, wrapping web search and chat completion endpoints with both synchronous and asynchronous interfaces. It uses httpx for HTTP transport and provides full type annotations via pydantic models and TypedDicts, enabling editor autocomplete and type checking. The library handles authentication via API key, automatic retries for transient failures, and streaming responses via Server-Sent Events.

Developers use it to integrate Perplexity's search and generative capabilities into Python applications. The package supports both blocking and async workflows, with an optional aiohttp backend for improved concurrency. It includes structured error handling for connection failures, authentication issues, rate limits, and API errors, plus configurable retry and timeout policies.

Use it for:

  • Integrate web search results into a Python application without building HTTP calls manually.
  • Build an async chatbot or agent that queries Perplexity's sonar model for real-time information.
  • Stream chat completions to a user interface while handling backpressure and connection errors.
  • Automate research workflows that combine search queries with follow-up chat interactions.
  • Add type-safe API calls to a production service with automatic retry and timeout handling.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides a Python client library for the Perplexity REST API, offering synchronous and asynchronous access to web search and chat completion endpoints with full type support.

Yes. The package is actively maintained, has low install friction, carries a permissive license, and provides a clean, well-typed interface to a live API service. Install it if you need to call Perplexity's search or chat endpoints from Python; skip it only if you prefer to manage HTTP requests directly or do not have a Perplexity API key.

Install

perplexityai on PyPI

pip

pip install perplexityai

uv

uv add perplexityai

poetry

poetry add perplexityai

Installing perplexityai

Before you install

Low install friction with a pure-Python wheel and six standard runtime dependencies. Actively maintained with a release 3 days old and recent commits; repository has 69 stars.

License in practice

Apache-2.0 permissive license allows commercial and private use with minimal restrictions; suitable for most projects.

Quickstart

pip install perplexityai

import os
from perplexityai import Perplexity

client = Perplexity(api_key=os.environ.get("PERPLEXITY_API_KEY"))
search = client.search.create(query="latest AI developments 2024", max_results=5)
for result in search.results:
    print(f"{result.title}: {result.url}")

Requires Python 3.9 or later and a valid Perplexity API key via PERPLEXITY_API_KEY environment variable.

Verify before relying

  • Whether the library's retry behavior and timeout defaults suit typical production workloads.
  • Performance characteristics of the async client with httpx versus optional aiohttp backend.
  • Rate limiting and quota management strategies for high-volume requests.

Package facts

License Apache-2.0 (permissive)
Python support supports the current Python release (>=3.9)
Install friction low — pure-Python wheel
Runtime dependencies 6 — anyio, distro, httpx, pydantic, sniffio, typing-extensions
Maintenance actively maintained — 3 days since the last release
Last repo commit
First released
Downloads 1,168,749/month — #4,273 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: perplexityai-0.43.3-py3-none-any.whl

Intended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseOperating System :: OS IndependentTyping :: Typed

Tags

perplexity api clientpython perplexity sdkai search api wrapperasync perplexity clientweb search integrationchat completions libraryperplexity sonar model access
api-clientasync-supportai-integration

More Internet packages