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 dashboard -
POST /chat/completions- Chat completions endpoint (returns plain text) -
GET /models- List available models -
GET /health- Health check -
POST /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.