--- id: perplexityai version: "0.43.3" license: Apache-2.0 license_treatment: permissive maintenance: active --- # perplexityai License: permissive · Maintenance: active · Downloads: 1.2M/mo ## 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 above — 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 pip install perplexityai uv add perplexityai 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_current - Install friction: low - Maintenance: active - Downloads: 1.2M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags perplexity api client, python perplexity sdk, ai search api wrapper, async perplexity client, web search integration, chat completions library, perplexity sonar model access, api-client, async-support, ai-integration [View on SkillFed](https://skillfed.io/packages/perplexityai) · [View on PyPI](https://pypi.org/project/perplexityai/)