perplexityai/perplexity-py ? reverse-engineered prompt

Reverse engineered prompt

Build me a Python library for the Perplexity API that feels easy to use in real projects.

I want a clean client for Python 3.9 and up, with both sync and async support, plus streaming responses. It should let me do web search and chat completions, use an API key from an environment variable by default, and make it simple to pass request options like retries, timeouts, and custom HTTP settings. Please include good type hints for request inputs and response objects, and make the responses easy to turn into dicts or JSON when needed.

Also handle errors nicely, so network issues, rate limits, and bad responses raise clear exceptions. Add a few example scripts and basic tests so I can see how to use it. If you need to check the latest API details online, go ahead and look them up.

Are you gonna build this?

make sure you review the code using coderabbit

Try freeSponsored — opens CodeRabbit in a new tab