A simple, clean drop-in replacement for the official Perplexity API. Perfect for using with TaskMaster AI and Claude Code MCP server.
- โ 100% Perplexity-focused - No multi-provider complexity
- โ Simple HTTP API - Easy integration with TaskMaster and Claude Code
- โ Cookie authentication - Use your Perplexity account for free searches
- โ Chrome Extension - One-click cookie extraction and MCP setup
- โ Web dashboard - Manage API keys and monitor usage
- โ Hot-reload cookies - Update cookies without restarting
- โ Token tracking - Monitor your usage
This system has three main components working together:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Chrome Extension โ
โ - Extracts Perplexity cookies โ
โ - Auto-configures MCP โ
โ - One-click setup โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโ
โ Sends cookies via HTTP
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Perplexity API Server (Flask) โ
โ - OpenAI-compatible HTTP API โ
โ - Cookie management โ
โ - API key generation โ
โ - Web dashboard โ
โ Port: localhost:8765 โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโ
โ HTTP requests
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ MCP Server (for Claude Code) โ
โ - Translates MCP protocol โ
โ - Connects Claude to API server โ
โ Location: perplexity-api-free โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
How it works:
- Chrome Extension extracts your Perplexity cookies automatically
- API Server uses cookies to make authenticated Perplexity requests
- MCP Server connects Claude Code to the API server
- Claude Code can now search using your Perplexity account!
cd /home/anombyte/projects/perplexity-api-simple
# Install dependencies
pip install -r requirements.txt
# Create .env file
cat > .env <<EOF
PERPLEXITY_COOKIE=your-cookie-here-optional
EOF# Simple start
./scripts/start_server.sh
# Or manually
export $(cat .env | xargs) && python src/perplexity_api_server.pyThe server will start at: http://localhost:8765
- Open
http://localhost:8765in your browser - Click "Generate New API Key"
- Copy your API key (starts with
pplx_)
Add to your TaskMaster configuration:
# In your .env or shell profile
export PERPLEXITY_API_KEY="pplx_your-generated-key-here"
export PERPLEXITY_API_BASE_URL="http://localhost:8765"Then use TaskMaster normally with the --research flag:
tm parse-prd --research
tm expand-all --research-
Generate API Key from the web dashboard at
http://localhost:8765 -
Update your MCP settings at
~/.claude/mcp_config.json:
{
"mcpServers": {
"perplexity-free": {
"command": "node",
"args": [
"/path/to/perplexity-api-free/mcp-server/build/index.js"
],
"env": {
"PERPLEXITY_API_KEY": "pplx_your-generated-key-here",
"PERPLEXITY_API_BASE_URL": "http://localhost:8765"
}
}
}
}-
Restart Claude Code
-
Test the connection:
- Ask Claude: "Use Perplexity to search for the latest Python best practices"
- Claude should use the MCP tool automatically
sonar- Default Perplexity model (fast)sonar-pro- Pro model (more accurate)sonar-reasoning- Reasoning model (deep thinking)sonar-deep-research- Deep research mode
GET /- Web dashboardPOST /chat/completions- Chat completions endpoint (returns plain text)GET /models- List available modelsGET /health- Health checkPOST /api/save-cookie- Save Perplexity cookie (used by extension)GET /download/extension- Download Chrome extension as ZIP
The easiest way to set up cookies and MCP configuration!
Option 1: Download from Dashboard (Easiest)
- Open
http://localhost:8765in Chrome - Scroll to "Chrome Extension" section
- Click "๐ฆ Download Chrome Extension"
- Extract the downloaded ZIP file
- Open Chrome โ
chrome://extensions/ - Enable "Developer mode" (top-right toggle)
- Click "Load unpacked"
- Select the extracted
extension/folder
Option 2: Use Extension from Project
- Open Chrome โ
chrome://extensions/ - Enable "Developer mode"
- Click "Load unpacked"
- Select
/home/anombyte/projects/perplexity-api-simple/extension/
- Login to Perplexity at https://www.perplexity.ai
- Click the extension icon in Chrome
- Enter your API key (from dashboard at localhost:8765)
- Click "๐ฎ Sync Perplexity Cookie"
- Done! Extension automatically:
- Extracts all Perplexity cookies from your browser
- Sends them securely to your local server
- Server hot-reloads with new cookies (no restart needed!)
The Chrome extension has permission to access cookies from perplexity.ai and uses the Chrome Cookies API to:
// From extension/scripts/popup.js
const cookies = await chrome.cookies.getAll({
domain: 'perplexity.ai'
});
const cookieString = cookies
.map(cookie => `${cookie.name}=${cookie.value}`)
.join('; ');
// Send to local server
await fetch('http://localhost:8765/api/save-cookie', {
method: 'POST',
headers: {
'Authorization': `Bearer ${apiKey}`
},
body: JSON.stringify({ cookie: cookieString })
});Security:
- Extension only accesses
localhost:8765(your local server) - Cookies never leave your machine
- Requires your API key for authentication
- All communication is local (not sent to internet)
- โ One-click cookie sync
- โ Auto-detects when you're logged in
- โ Hot-reload support (no server restart)
- โ Also supports ChatGPT cookies
- โ MCP configuration generator (coming soon)
To use your Perplexity account for authenticated searches:
- Login to Perplexity at
https://www.perplexity.ai - Open DevTools (F12)
- Go to Application/Storage โ Cookies
- Copy the entire cookie string
- Open
http://localhost:8765 - Click "Cookie Settings"
- Paste your cookie
- Click "Save" (hot-reloads without restart!)
# Edit .env file
PERPLEXITY_COOKIE=your-full-cookie-string-hereThen restart the server.
# Check if port 8765 is already in use
lsof -i :8765
# Kill existing process
kill -9 $(lsof -t -i :8765)
# Try again
./scripts/start_server.sh- Open
http://localhost:8765 - Check if your key is active in the dashboard
- Regenerate a new key if needed
- Make sure you're logged into Perplexity.ai
- Copy the ENTIRE cookie string (not just one field)
- Try refreshing your Perplexity session
- Use the web dashboard to update the cookie (hot-reload)
If running in WSL and can't access from Windows:
# Make sure you're using 0.0.0.0 (not 127.0.0.1)
# Server already binds to 0.0.0.0 by default
# Access from Windows using WSL IP
ip addr show eth0 | grep inet
# Use: http://<wsl-ip>:8765perplexity-api-simple/
โโโ src/
โ โโโ perplexity_api_server.py # Main Flask API server
โ โโโ perplexity_fixed.py # Perplexity client wrapper
โโโ web/
โ โโโ index.html # Web dashboard (API key management)
โโโ extension/ # Chrome extension
โ โโโ manifest.json # Extension config (v1.3.0)
โ โโโ popup.html # Extension popup UI
โ โโโ instructions.html # Setup instructions
โ โโโ scripts/
โ โ โโโ popup.js # Cookie extraction logic
โ โ โโโ background.js # Background service worker
โ โโโ icons/ # Extension icons
โโโ scripts/
โ โโโ start_server.sh # Server startup script
โโโ requirements.txt # Python dependencies
โโโ .env # Environment variables (gitignored)
โโโ .api_keys.json # API keys storage (gitignored)
โโโ README.md
# With auto-reload
FLASK_DEBUG=1 python src/perplexity_api_server.py
# With custom port
PORT=9000 python src/perplexity_api_server.pyThe easiest way to run this server is with Docker:
# Quick Start
cp .env.example .env # Configure your Perplexity cookie
docker-compose up -d # Start the serverAccess the dashboard at http://localhost:8765
For detailed Docker instructions including:
- AWS EC2 deployment
- AWS ECS/Fargate deployment
- Development mode setup
- Monitoring and troubleshooting
- Production best practices
See DOCKER.md for the complete guide.
- API keys are stored locally in
.api_keys.json - Cookies are stored in
.env(never committed to git) - The server runs locally and doesn't expose your keys to the internet
- Use HTTPS in production deployments
This is a simplified, Perplexity-focused version. For multi-provider support, see the main perplexity-api-free project.
MIT
Based on the perplexity-api-free project, simplified for ease of use with TaskMaster and Claude Code.