pplx2api  by yushangxiao

OpenAI-compatible API for Perplexity AI

created 4 months ago
308 stars

Top 88.2% on sourcepulse

GitHubView on GitHub
Project Summary

This project provides an OpenAI-compatible API gateway for Perplexity AI, enabling users to leverage Perplexity's advanced features like image recognition, reasoning, web search, and image generation through a familiar API structure. It targets developers and power users who want to integrate Perplexity's capabilities into their applications or workflows without direct reliance on Perplexity's native interface.

How It Works

Pplx2Api acts as a proxy, translating standard OpenAI API requests into Perplexity's internal API calls. It supports various Perplexity models, including those with integrated search capabilities (-search suffix). Key features include handling multi-modal inputs (text and images), managing chat history by uploading long contexts as files, and offering a "privacy mode" to prevent chat history from being saved on Perplexity's servers. It also includes automatic cookie refreshing for continuous availability and an option to expose the model's thinking process.

Quick Start & Requirements

  • Docker: docker run -d -p 8080:8080 -e SESSIONS=<your_perplexity_session_cookie> -e APIKEY=<your_api_key> ghcr.io/yushangxiao/pplx2api:latest
  • Prerequisites: Perplexity.ai session cookie (__Secure-next-auth.session-token), Go 1.23+ (for source build), Docker.
  • Configuration: Set SESSIONS and APIKEY environment variables. Multiple session cookies can be provided, comma-separated, for account rotation.
  • Docs: HuggingFace Space

Highlighted Details

  • OpenAI compatible API for Perplexity AI.
  • Supports image recognition, web search, and image generation.
  • Handles chat history by uploading long contexts as files.
  • Includes privacy mode and automatic cookie refreshing.

Maintenance & Community

The project is maintained by yushangxiao. Contributions are welcome via pull requests.

Licensing & Compatibility

MIT License. Compatible with commercial use and closed-source applications.

Limitations & Caveats

The project relies on Perplexity.ai's internal API, which could change without notice, potentially breaking the compatibility of this wrapper. The effectiveness of features like account rotation depends on the validity and management of the provided session cookies.

Health Check
Last commit

1 week ago

Responsiveness

Inactive

Pull Requests (30d)
1
Issues (30d)
10
Star History
143 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.