A free, fast API for Perplexity AI. No API key needed — uses your logged-in Perplexity session.
Includes an MCP server so Claude Code (or any MCP client) can use Perplexity as a search tool.
Your app → pAPI → curl-impersonate (Chrome TLS) → Perplexity web UI → Answer
pAPI reverse-engineers Perplexity's internal /rest/sse/perplexity_ask endpoint. It uses curl-impersonate to bypass Cloudflare's TLS fingerprinting and your browser session cookies for authentication.
git clone https://github.com/Rani367/pAPI.git
cd pAPI
bun install# macOS arm64
mkdir bin && curl -sL "https://github.com/lexiforest/curl-impersonate/releases/download/v1.5.1/curl-impersonate-v1.5.1.arm64-macos.tar.gz" | tar xz -C bin
# Linux x86_64
mkdir bin && curl -sL "https://github.com/lexiforest/curl-impersonate/releases/download/v1.5.1/curl-impersonate-v1.5.1.x86_64-linux-gnu.tar.gz" | tar xz -C bin- Go to perplexity.ai and log in
- Open DevTools → Network tab
- Type a question and submit it
- Find the
perplexity_askrequest → right-click → Copy as cURL - Extract the cookie string from the
-bor--cookieflag
cp .env.example .env
# Paste your cookie string as PERPLEXITY_COOKIESbun run dev # with hot reload
bun run start # productioncurl -X POST http://localhost:3000/ask \
-H 'Content-Type: application/json' \
-d '{"prompt": "What is quantum computing?"}'Request body:
| Field | Type | Default | Description |
|---|---|---|---|
prompt |
string | required | Your question |
sources |
string[] | ["web"] |
Search sources |
citations |
boolean | false |
Include source URLs |
Response:
{
"answer": "Quantum computing is...",
"citations": ["https://..."]
}Same request body. Returns Server-Sent Events.
Returns {"status": "ok"}.
docker build -t papi .
docker run -d -p 3000:3000 --env-file .env --name papi papiAn MCP server that exposes a perplexity_search tool. Works with any MCP client: Claude Code, Claude Desktop, Cursor, Windsurf, VS Code Copilot, etc.
# Claude Code
claude mcp add -e PAPI_URL=https://your-papi-instance.com --scope user papi-search -- npx papi-mcp-server
# Claude Desktop / Cursor / other — add to your MCP config:
{
"mcpServers": {
"papi-search": {
"command": "npx",
"args": ["papi-mcp-server"],
"env": {
"PAPI_URL": "https://your-papi-instance.com"
}
}
}
}| Variable | Description |
|---|---|
PAPI_URL |
Direct pAPI URL (e.g. https://my-papi.example.com) |
PAPI_GIST_URL |
URL to a file containing the pAPI hostname (for dynamic tunnels) |
Set one or the other.
Just ask your AI to search:
"Use perplexity_search to find the latest version of Bun"
The Cloudflare cookies (cf_clearance, __cf_bm) expire periodically. When requests start returning errors, grab fresh cookies from your browser and update .env.
MIT