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
- ✅ OpenAI-compatible API - Works with any OpenAI SDK
- ✅ Cookie authentication - Use your Perplexity account for free searches
- ✅ Web dashboard - Manage API keys and monitor usage
- ✅ Hot-reload cookies - Update cookies without restarting
- ✅ Token tracking - Monitor your usage
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
 
from openai import OpenAI
client = OpenAI(
    base_url="http://localhost:8765/v1",
    api_key="pplx_your-generated-key-here"
)
response = client.chat.completions.create(
    model="sonar-pro",
    messages=[
        {"role": "user", "content": "What are the latest developments in AI?"}
    ]
)
print(response.choices[0].message.content)- 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- Perplexity API endpoint
- POST /v1/chat/completions- OpenAI-compatible endpoint
- GET /models- List available models
- GET /health- Health check
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 server
│   └── perplexity_fixed.py       # Perplexity client
├── web/
│   └── index.html                # Dashboard
├── scripts/
│   └── start_server.sh           # Startup script
├── requirements.txt
├── .env.example
└── README.md
# With auto-reload
FLASK_DEBUG=1 python src/perplexity_api_server.py
# With custom port
PORT=9000 python src/perplexity_api_server.py# Build image
docker build -t perplexity-api-simple .
# Run container
docker run -p 8765:8765 \
  -e PERPLEXITY_COOKIE="your-cookie" \
  -v $(pwd)/.api_keys.json:/app/.api_keys.json \
  perplexity-api-simple- 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.