pplx2api  by yushangxiao

OpenAI-compatible API for Perplexity AI

Created 5 months ago
360 stars

Top 77.7% 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 month ago

Responsiveness

1 day

Pull Requests (30d)
1
Issues (30d)
3
Star History
42 stars in the last 30 days

Explore Similar Projects

Starred by Patrick von Platen Patrick von Platen(Author of Hugging Face Diffusers; Research Engineer at Mistral) and Jeff Hammerbacher Jeff Hammerbacher(Cofounder of Cloudera).

client-python by mistralai

0.6%
648
Python SDK for Mistral AI platform
Created 1 year ago
Updated 2 weeks ago
Feedback? Help us improve.