Unofficial Python wrapper and API server for Perplexity AI's web interface.
- Python 3.13+
- See
pyproject.tomlfor dependencies (curl-cffi, fastapi, uvicorn, websocket-client)
- Clone this repository:
git clone <your-repo-url> cd perplexity-web-wrapper
- Install dependencies using uv:
uv sync
- Place your Perplexity cookies in
perplexity_cookies.json(see example in repo). - The API and library will use these cookies for authenticated requests.
From the project root, start the FastAPI server using Uvicorn:
uvicorn api.main:app --reload --host 0.0.0.0 --port 8000| Functionality | Method/Attribute | Description |
|---|---|---|
| Search | Client.search() |
Query Perplexity AI with various modes, models, sources, and file uploads |
| List Threads | Client.get_threads() |
Fetch a list of threads from Perplexity AI |
See /docs (Swagger UI) for full API details and interactive usage.
You can use the Python client directly:
from lib.perplexity import Client
import json
with open("perplexity_cookies.json") as f:
cookies = json.load(f)
client = Client(cookies)
result = client.search("What is Perplexity AI?", mode="auto")
print(result)- This is an unofficial project and not affiliated with Perplexity AI.
- For production, restrict CORS and secure your cookies.
MIT. Contributions welcome!