困惑API简单
 ](https://github.com/anombyte93/perplexity-api-simple/stargazers)  ](https://github.com/anombyte93/perplexity-api-simple/issues)
一个简单,干净的滴入替代官方困惑API。非常适合与TaskMaster AI和Claude Code MCP服务器一起使用。
安装
curl -fsSL https://raw.githubusercontent.com/anombyte93/perplexity-api-simple/main/install.sh | bash这将把仓库克隆到 ~/perplexity-api-simple/,创建Python venv,安装依赖项,并设置 .env。运行相同的命令进行更新。
更新现有安装:
bash ~/perplexity-api-simple/install.sh --update自定义安装位置:
PERPLEXITY_INSTALL_DIR=/opt/perplexity bash .env `${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 })
});安全:
- 仅限扩展访问
localhost:8765(您的本地服务器) - Cookie永远不会离开您的机器
- 需要您的API密钥进行身份验证
- 所有通信都是本地的(不发送到互联网)
特性
- ✅ 一键式cookie同步
- ✅ 自动检测您登录的时间
- ✅ 热重载支持(无需重新启动服务器)
- ✅ 还支持ChatGPT Cookie
- ✅ MCP配置生成器(即将推出)
手动Cookie设置(无扩展)
要使用您的困惑帐户进行身份验证搜索,请执行以下操作:
获取您的Cookie
- 登录困惑 在
https://www.perplexity.ai - 打开DevTools (F12)
- 转到应用程序/存储→ Cookie
- 复制整个cookie字符串
选项1:通过Web仪表板
- 打开
http://localhost:8765 - 点击“Cookie设置”
- 粘贴您的饼干
- 点击“保存”(热重新加载,无需重新启动!)
选项2:通过.env文件
# Edit .env file
PERPLEXITY_COOKIE=your-full-cookie-string-here然后重新启动服务器。
故障排除
服务器无法启动
# 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.shAPI密钥不工作
- 打开
http://localhost:8765 - 检查您的钥匙是否在仪表板中处于活动状态
- 如果需要,重新生成新密钥
Cookie不起作用
- 确保您已登录到Perplexy.ai
- 复制整个cookie字符串(而不仅仅是一个字段)
- 尝试刷新您的困惑会话
- 使用web仪表板更新cookie(热重新加载)
WSL特定问题
如果在WSL中运行并且无法从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://:8765发展
项目结构
perplexity-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.pyDocker支持
运行此服务器的最简单方法是使用Docker:
# Quick Start
cp .env.example .env # Configure your Perplexity cookie
docker-compose up -d # Start the server访问仪表板 http://localhost:8765
完整的Docker文档
有关Docker的详细说明,包括:
- AWS EC2部署
- AWS ECS/Fargate部署
- 开发模式设置
- 监控和故障排除
- 生产最佳实践
看 医生.md 完整的指南。
安全
- API密钥本地存储在
.api_keys.json - Cookie存储在
.env(从未使用过git) - 服务器在本地运行,不会将您的密钥暴露给互联网
- 在生产部署中使用HTTPS
贡献
欢迎投稿!看 贡献.md 作为指导方针。
许可证
麻省理工学院
学分
专为与TaskMaster AI和Claude Code轻松集成而构建。
