[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-helallao--perplexity-ai":3,"tool-helallao--perplexity-ai":64},[4,17,27,35,43,56],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":16},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,3,"2026-04-05T11:01:52",[13,14,15],"开发框架","图像","Agent","ready",{"id":18,"name":19,"github_repo":20,"description_zh":21,"stars":22,"difficulty_score":23,"last_commit_at":24,"category_tags":25,"status":16},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",138956,2,"2026-04-05T11:33:21",[13,15,26],"语言模型",{"id":28,"name":29,"github_repo":30,"description_zh":31,"stars":32,"difficulty_score":23,"last_commit_at":33,"category_tags":34,"status":16},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107662,"2026-04-03T11:11:01",[13,14,15],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":23,"last_commit_at":41,"category_tags":42,"status":16},3704,"NextChat","ChatGPTNextWeb\u002FNextChat","NextChat 是一款轻量且极速的 AI 助手，旨在为用户提供流畅、跨平台的大模型交互体验。它完美解决了用户在多设备间切换时难以保持对话连续性，以及面对众多 AI 模型不知如何统一管理的痛点。无论是日常办公、学习辅助还是创意激发，NextChat 都能让用户随时随地通过网页、iOS、Android、Windows、MacOS 或 Linux 端无缝接入智能服务。\n\n这款工具非常适合普通用户、学生、职场人士以及需要私有化部署的企业团队使用。对于开发者而言，它也提供了便捷的自托管方案，支持一键部署到 Vercel 或 Zeabur 等平台。\n\nNextChat 的核心亮点在于其广泛的模型兼容性，原生支持 Claude、DeepSeek、GPT-4 及 Gemini Pro 等主流大模型，让用户在一个界面即可自由切换不同 AI 能力。此外，它还率先支持 MCP（Model Context Protocol）协议，增强了上下文处理能力。针对企业用户，NextChat 提供专业版解决方案，具备品牌定制、细粒度权限控制、内部知识库整合及安全审计等功能，满足公司对数据隐私和个性化管理的高标准要求。",87618,"2026-04-05T07:20:52",[13,26],{"id":44,"name":45,"github_repo":46,"description_zh":47,"stars":48,"difficulty_score":23,"last_commit_at":49,"category_tags":50,"status":16},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",84991,"2026-04-05T10:45:23",[14,51,52,53,15,54,26,13,55],"数据工具","视频","插件","其他","音频",{"id":57,"name":58,"github_repo":59,"description_zh":60,"stars":61,"difficulty_score":10,"last_commit_at":62,"category_tags":63,"status":16},3128,"ragflow","infiniflow\u002Fragflow","RAGFlow 是一款领先的开源检索增强生成（RAG）引擎，旨在为大语言模型构建更精准、可靠的上下文层。它巧妙地将前沿的 RAG 技术与智能体（Agent）能力相结合，不仅支持从各类文档中高效提取知识，还能让模型基于这些知识进行逻辑推理和任务执行。\n\n在大模型应用中，幻觉问题和知识滞后是常见痛点。RAGFlow 通过深度解析复杂文档结构（如表格、图表及混合排版），显著提升了信息检索的准确度，从而有效减少模型“胡编乱造”的现象，确保回答既有据可依又具备时效性。其内置的智能体机制更进一步，使系统不仅能回答问题，还能自主规划步骤解决复杂问题。\n\n这款工具特别适合开发者、企业技术团队以及 AI 研究人员使用。无论是希望快速搭建私有知识库问答系统，还是致力于探索大模型在垂直领域落地的创新者，都能从中受益。RAGFlow 提供了可视化的工作流编排界面和灵活的 API 接口，既降低了非算法背景用户的上手门槛，也满足了专业开发者对系统深度定制的需求。作为基于 Apache 2.0 协议开源的项目，它正成为连接通用大模型与行业专有知识之间的重要桥梁。",77062,"2026-04-04T04:44:48",[15,14,13,26,54],{"id":65,"github_repo":66,"name":67,"description_en":68,"description_zh":69,"ai_summary_zh":69,"readme_en":70,"readme_zh":71,"quickstart_zh":72,"use_case_zh":73,"hero_image_url":74,"owner_login":75,"owner_name":76,"owner_avatar_url":77,"owner_bio":78,"owner_company":79,"owner_location":80,"owner_email":78,"owner_twitter":78,"owner_website":81,"owner_url":82,"languages":83,"stars":88,"forks":89,"last_commit_at":90,"license":91,"difficulty_score":23,"env_os":92,"env_gpu":93,"env_ram":93,"env_deps":94,"category_tags":108,"github_topics":109,"view_count":118,"oss_zip_url":78,"oss_zip_packed_at":78,"status":16,"created_at":119,"updated_at":120,"faqs":121,"releases":151},138,"helallao\u002Fperplexity-ai","perplexity-ai","Unofficial API Wrapper for Perplexity.ai + Account Generator with Web Interface","perplexity-ai 是一个非官方的 Perplexity.ai 接口封装工具，能自动通过 Emailnator 生成临时 Gmail 账号，从而绕过免费用户的查询限制，实现“无限次”使用 Pro 功能。它同时提供命令行 API（支持同步与异步）和图形化网页界面，方便不同使用习惯的用户操作。项目还内置了 MCP（Model Context Protocol）服务器，可将 Perplexity 的搜索能力作为工具接入 Claude Code 等支持 MCP 的 AI 客户端。\n\n这个工具主要解决了 Perplexity.ai 免费账户查询次数受限的问题，适合开发者、研究人员或重度 AI 用户在本地自动化调用高级搜索功能。其技术亮点包括完整的类型提示、结构化日志、自动重试机制、流式响应支持，以及对文件上传和深度研究模式的兼容。普通用户可通过网页界面轻松使用，而开发者则能借助 API 或 MCP 集成到自己的工作流中。需要注意的是，该工具依赖反向工程实现，并非官方服务。","# Perplexity AI\n\n![Python](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fpython-3.8+-blue.svg)\n![License](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Flicense-MIT-green.svg)\n\nPerplexity AI is a Python module that leverages [Emailnator](https:\u002F\u002Femailnator.com\u002F) to generate new accounts for unlimited pro queries. It supports both synchronous and asynchronous APIs, as well as a web interface for users who prefer a GUI-based approach.\n\n## Features\n\n- **Account Generation**: Automatically generate Gmail accounts using Emailnator\n- **Unlimited Pro Queries**: Bypass query limits by creating new accounts\n- **Web Interface**: Automate account creation and usage via a browser\n- **Sync & Async APIs**: Full support for both synchronous and asynchronous programming\n- **Type Safety**: Complete type hints for better IDE support\n- **Robust Error Handling**: Custom exceptions for better error management\n- **Comprehensive Logging**: Structured logging for debugging\n- **File Upload**: Support for document analysis and Q&A\n- **Streaming Responses**: Real-time response streaming\n- **Retry Logic**: Automatic retry with exponential backoff\n- **Rate Limiting**: Built-in rate limiting to prevent abuse\n\n## Installation\n\n### Basic Installation\n\n```bash\npip install -e .\n```\n\n### With Driver Support (Web Interface)\n\n```bash\npip install -e \".[driver]\"\npatchright install chromium\n```\n\n### With MCP Server\n\n```bash\npip install -e \".[mcp]\"\n```\n\n### Development Installation\n\n```bash\npip install -e \".[dev]\"\n```\n\nThis includes testing tools (pytest, pytest-cov, pytest-asyncio), linting (flake8, black, isort, mypy), and all optional dependencies.\n\n## MCP Server\n\nThis project includes an MCP (Model Context Protocol) server that exposes Perplexity search as tools for Claude Code and other MCP clients. It works without an API key by using the same reverse-engineered web interface as the rest of this library.\n\n### Installation\n\n```bash\npip install -e \".[mcp]\"\n```\n\n### Running the Server\n\nThe server supports two transports, controlled by the `MCP_TRANSPORT` environment variable (default: `stdio`).\n\n#### stdio (default)\n\nUsed by local MCP clients like Claude Code and Claude Desktop. The client spawns the process directly.\n\n```bash\nperplexity-mcp\n```\n\nAdd to Claude Code:\n\n```bash\nclaude mcp add perplexity -- perplexity-mcp\n```\n\nManual config:\n\n```json\n{\n  \"mcpServers\": {\n    \"perplexity\": {\n      \"command\": \"perplexity-mcp\",\n      \"env\": {\n        \"PERPLEXITY_COOKIES\": \"{\\\"next-auth.session-token\\\": \\\"...\\\"}\"\n      }\n    }\n  }\n}\n```\n\n#### HTTP (network\u002Fremote)\n\nRuns a persistent HTTP server that multiple clients can connect to over the network. Use this when you want to share one server instance across multiple clients or machines.\n\n**1. Start the server:**\n\n```bash\nMCP_TRANSPORT=http perplexity-mcp\n```\n\nDefaults to `127.0.0.1:8000`. To bind to all interfaces or change the port:\n\n```bash\nMCP_TRANSPORT=http MCP_HOST=0.0.0.0 MCP_PORT=9000 perplexity-mcp\n```\n\nTo include cookies:\n\n```bash\nMCP_TRANSPORT=http PERPLEXITY_COOKIES='{\"next-auth.session-token\": \"...\"}' perplexity-mcp\n```\n\nThe MCP endpoint will be available at `http:\u002F\u002F\u003Chost>:\u003Cport>\u002Fmcp`.\n\n**2. Add to Claude Code:**\n\n```bash\nclaude mcp add --transport http perplexity http:\u002F\u002F127.0.0.1:8000\u002Fmcp\n```\n\nAdjust the URL if you changed the host or port. For a remote machine, replace `127.0.0.1` with its address.\n\n**3. Verify:**\n\n```bash\nclaude mcp list\n```\n\n---\n\nThe `PERPLEXITY_COOKIES` environment variable is optional for both transports. If not set, the server runs anonymously with access to free (auto mode) queries only. Set it to a JSON string of your Perplexity cookies to enable pro, reasoning, and deep research modes. See [How To Get Cookies](#how-to-get-cookies) for instructions.\n\n### Available Tools\n\n| Tool | Mode | Description |\n|------|------|-------------|\n| `perplexity_ask` | `auto` | General-purpose question answering |\n| `perplexity_research` | `deep research` | In-depth research on a topic |\n| `perplexity_reason` | `reasoning` | Step-by-step reasoning through a problem |\n| `perplexity_search` | `pro` + web sources | Web search |\n\n### Differences from the Official MCP\n\nThe [official `@perplexity-ai\u002Fmcp-server`](https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002F@perplexity-ai\u002Fmcp-server) requires a paid Perplexity API key. This server uses the reverse-engineered web interface instead. As a result, the following features available in the official MCP are not supported here:\n\n| Feature | Official MCP | This server |\n|---------|-------------|-------------|\n| No API key required | No | **Yes** |\n| `messages` array input | Yes | No (single `query` string only) |\n| `search_recency_filter` | Yes | No |\n| `search_domain_filter` | Yes | No |\n| `search_context_size` | Yes | No |\n| `reasoning_effort` | Yes | No |\n| `strip_thinking` | Yes | No |\n| Structured search results (citations, images) | Yes | No (plain text answer only) |\n\n## Quick Start\n\n### Basic Usage\n\n```python\nimport perplexity\n\n# Create client\nclient = perplexity.Client()\n\n# Make a query\nresponse = client.search(\"What is artificial intelligence?\")\nprint(response['answer'])\n```\n\n### With Account (for enhanced features)\n\n```python\nimport perplexity\n\n# Your Perplexity cookies\ncookies = {\n    'next-auth.csrf-token': 'your-token',\n    'next-auth.session-token': 'your-session',\n}\n\nclient = perplexity.Client(cookies)\n\n# Use enhanced modes\nresponse = client.search(\n    \"Complex query here\",\n    mode='pro',\n    model='gpt-5.2',\n    sources=['scholar']\n)\n```\n\n### Streaming Responses\n\n```python\nfor chunk in client.search(\"Explain quantum computing\", stream=True):\n    if 'answer' in chunk:\n        print(chunk['answer'], end='', flush=True)\n```\n\n### Async Usage\n\n```python\nimport asyncio\nimport perplexity_async\n\nasync def main():\n    client = await perplexity_async.Client()\n    response = await client.search(\"What is machine learning?\")\n    print(response['answer'])\n\nasyncio.run(main())\n```\n\n## Documentation\n\n- **[Examples](examples\u002F)** - Practical examples for common use cases\n- **[Changelog](docs\u002FCHANGELOG.md)** - Bug fixes and changes history\n- **[Improvements](docs\u002FIMPROVEMENTS.md)** - Suggested improvements and roadmap\n- **[API Reference](#api-reference)** - Complete API documentation\n\n## Usage\n\n### Web Interface\n\nThe web interface automates account creation and usage in a browser. [Patchright](https:\u002F\u002Fgithub.com\u002FKaliiiiiiiiii-Vinyzu\u002Fpatchright-python#best-practices) uses [\"Chrome User Data Directory\"](https:\u002F\u002Fwww.google.com\u002Fsearch?q=chrome+user+data+directory) to be completely undetected, it's ``C:\\Users\\YourName\\AppData\\Local\\Google\\Chrome\\User Data`` for Windows, as shown below:\n\n```python\nimport os\nfrom perplexity.driver import Driver\n\ncli = Driver()\ncli.run(rf'C:\\\\Users\\\\{os.getlogin()}\\\\AppData\\\\Local\\\\Google\\\\Chrome\\\\User Data')\n```\n\nTo use your own Chrome instance, enable remote debugging (it may enter dead loop in Cloudflare):\n\n1. Add `--remote-debugging-port=9222` to Chrome's shortcut target.\n2. Pass the port to the `Driver.run()` method:\n\n```python\ncli.run(rf'C:\\\\Users\\\\{os.getlogin()}\\\\AppData\\\\Local\\\\Google\\\\Chrome\\\\User Data', port=9222)\n```\n\n### API Usage\n\n#### Synchronous API\n\nBelow is an example code for simple usage, without using your own account or generating new accounts.\n\n```python3\nimport perplexity\n\nperplexity_cli = perplexity.Client()\n\n# model = model for mode, which can only be used in own accounts, that is {\n#     'auto': [None],\n#     'pro': [None, 'sonar', 'gpt-5.2', 'claude-4.5-sonnet', 'grok-4-1'],\n#     'reasoning': [None, 'gpt-5.2-thinking', 'claude-4.5-sonnet-thinking', 'gemini-3.0-pro', 'kimi-k2-thinking', 'grok-4.1-reasoning'],\n#     'deep research': [None]\n# }\n# sources = ['web', 'scholar', 'social']\n# files = a dictionary which has keys as filenames and values as file data\n# stream = returns a generator when enabled and just final response when disabled\n# language = ISO 639 code of language you want to use\n# follow_up = last query info for follow-up queries, you can directly pass response from a query, look at second example below\n# incognito = Enables incognito mode, for people who are using their own account\nresp = perplexity_cli.search('Your query here', mode='auto', model=None, sources=['web'], files={}, stream=False, language='en-US', follow_up=None, incognito=False)\nprint(resp)\n\n# second example to show how to use follow-up queries and stream response\nfor i in perplexity_cli.search('Your query here', stream=True, follow_up=resp):\n    print(i)\n```\n\nAnd this is how you use your own account, you need to get your cookies in order to use your own account. Look at [How To Get Cookies](#how-to-get-cookies),\n\n```python3\nimport perplexity\n\nperplexity_cookies = { \n    \u003Cyour cookies here>\n}\n\nperplexity_cli = perplexity.Client(perplexity_cookies)\n\nresp = perplexity_cli.search('Your query here', mode='reasoning', model='gpt-5.2-thinking', sources=['web'], files={'myfile.txt': open('file.txt').read()}, stream=False, language='en-US', follow_up=None, incognito=False)\nprint(resp)\n```\n\nAnd finally account generating, you need to get cookies for [Emailnator](https:\u002F\u002Femailnator.com\u002F) to use this feature. Look at [How To Get Cookies](#how-to-get-cookies),\n\n```python3\nimport perplexity\n\nemailnator_cookies = { \n    \u003Cyour cookies here>\n}\n\nperplexity_cli = perplexity.Client()\nperplexity_cli.create_account(emailnator_cookies) # Creates a new gmail, so your 5 pro queries will be renewed.\n\nresp = perplexity_cli.search('Your query here', mode='reasoning', model=None, sources=['web'], files={'myfile.txt': open('file.txt').read()}, stream=False, language='en-US', follow_up=None, incognito=False)\nprint(resp)\n```\n\n#### Asynchronous API\n\nBelow is an example code for simple usage, without using your own account or generating new accounts.\n\n```python3\nimport asyncio\nimport perplexity_async\n\nasync def test():\n    perplexity_cli = await perplexity_async.Client()\n\n    # mode = ['auto', 'pro', 'reasoning', 'deep research']\n    # model = model for mode, which can only be used in own accounts, that is {\n    #     'auto': [None],\n    #     'pro': [None, 'sonar', 'gpt-5.2', 'claude-4.5-sonnet', 'grok-4-1'],\n    #     'reasoning': [None, 'gpt-5.2-thinking', 'claude-4.5-sonnet-thinking', 'gemini-3.0-pro', 'kimi-k2-thinking', 'grok-4.1-reasoning'],\n    #     'deep research': [None]\n    # }\n    # sources = ['web', 'scholar', 'social']\n    # files = a dictionary which has keys as filenames and values as file data\n    # stream = returns a generator when enabled and just final response when disabled\n    # language = ISO 639 code of language you want to use\n    # follow_up = last query info for follow-up queries, you can directly pass response from a query, look at second example below\n    # incognito = Enables incognito mode, for people who are using their own account\n    resp = await perplexity_cli.search('Your query here', mode='auto', model=None, sources=['web'], files={}, stream=False, language='en-US', follow_up=None, incognito=False)\n    print(resp)\n\n    # second example to show how to use follow-up queries and stream response\n    async for i in await perplexity_cli.search('Your query here', stream=True, follow_up=resp):\n        print(i)\n\nasyncio.run(test())\n```\n\nAnd this is how you use your own account, you need to get your cookies in order to use your own account. Look at [How To Get Cookies](#how-to-get-cookies),\n\n```python3\nimport asyncio\nimport perplexity_async\n\nperplexity_cookies = { \n    \u003Cyour cookies here>\n}\n\nasync def test():\n    perplexity_cli = await perplexity_async.Client(perplexity_cookies)\n\n    resp = await perplexity_cli.search('Your query here', mode='reasoning', model='gpt-5.2-thinking', sources=['web'], files={'myfile.txt': open('file.txt').read()}, stream=False, language='en-US', follow_up=None, incognito=False)\n    print(resp)\n\nasyncio.run(test())\n```\n\nAnd finally account generating, you need to get cookies for [emailnator](https:\u002F\u002Femailnator.com\u002F) to use this feature. Look at [How To Get Cookies](#how-to-get-cookies),\n\n```python3\nimport asyncio\nimport perplexity_async\n\nemailnator_cookies = { \n    \u003Cyour cookies here>\n}\n\nasync def test():\n    perplexity_cli = await perplexity_async.Client()\n    await perplexity_cli.create_account(emailnator_cookies) # Creates a new gmail, so your 5 pro queries will be renewed.\n\n    resp = await perplexity_cli.search('Your query here', mode='reasoning', model=None, sources=['web'], files={'myfile.txt': open('file.txt').read()}, stream=False, language='en-US', follow_up=None, incognito=False)\n    print(resp)\n\nasyncio.run(test())\n```\n\n## How to Get Cookies\n\n### Perplexity (to use your own account)\n* Open [Perplexity.ai](https:\u002F\u002Fperplexity.ai\u002F) website and login to your account.\n* Click F12 or ``Ctrl + Shift + I`` to open inspector.\n* Go to the \"Network\" tab in the inspector.\n* Refresh the page, right click the first request, hover on \"Copy\" and click to \"Copy as cURL (bash)\".\n* Now go to the [CurlConverter](https:\u002F\u002Fcurlconverter.com\u002Fpython\u002F) and paste your code here. The cookies dictionary will appear, copy and use it in your codes.\n\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhelallao_perplexity-ai_readme_10402a3b80b4.png\">\n\n### Emailnator (for account generating)\n* Open [Emailnator](https:\u002F\u002Femailnator.com\u002F) website and verify you're human.\n* Click F12 or ``Ctrl + Shift + I`` to open inspector.\n* Go to the \"Network\" tab in the inspector.\n* Refresh the page, right click the first request, hover on \"Copy\" and click to \"Copy as cURL (bash)\".\n* Now go to the [CurlConverter](https:\u002F\u002Fcurlconverter.com\u002Fpython\u002F) and paste your code here. The cookies dictionary will appear, copy and use it in your codes.\n* Cookies for [Emailnator](https:\u002F\u002Femailnator.com\u002F) are temporary, you need to renew them continuously.\n\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhelallao_perplexity-ai_readme_c8628bb505da.png\">\n\n## API Reference\n\n### Client Class\n\n```python\nclass Client:\n    def __init__(self, cookies: Optional[Dict[str, str]] = None):\n        \"\"\"\n        Initialize Perplexity client.\n        \n        Args:\n            cookies: Optional Perplexity account cookies for enhanced features\n        \"\"\"\n    \n    def search(\n        self,\n        query: str,\n        mode: str = 'auto',\n        model: Optional[str] = None,\n        sources: List[str] = ['web'],\n        files: Dict[str, Union[str, bytes]] = {},\n        stream: bool = False,\n        language: str = 'en-US',\n        follow_up: Optional[Dict] = None,\n        incognito: bool = False\n    ) -> Union[Dict, Generator]:\n        \"\"\"\n        Search with Perplexity AI.\n        \n        Args:\n            query: Search query\n            mode: Search mode ('auto', 'pro', 'reasoning', 'deep research')\n            model: Model to use (depends on mode)\n            sources: Information sources (['web', 'scholar', 'social'])\n            files: Files to upload {filename: content}\n            stream: Enable streaming responses\n            language: ISO 639 language code\n            follow_up: Previous query for context\n            incognito: Enable incognito mode\n            \n        Returns:\n            Response dict with 'answer' key, or generator if stream=True\n        \"\"\"\n    \n    def create_account(self, emailnator_cookies: Dict[str, str]):\n        \"\"\"\n        Create new account using Emailnator.\n        \n        Args:\n            emailnator_cookies: Emailnator cookies for account creation\n        \"\"\"\n```\n\n### Available Models\n\n```python\n{\n    'auto': [None],\n    'pro': [None, 'sonar', 'gpt-5.2', 'claude-4.5-sonnet', 'grok-4-1'],\n    'reasoning': [None, 'gpt-5.2-thinking', 'claude-4.5-sonnet-thinking', 'gemini-3.0-pro', 'kimi-k2-thinking', 'grok-4.1-reasoning'],\n    'deep research': [None]\n}\n```\n\n### Custom Exceptions\n\n```python\nfrom perplexity.exceptions import (\n    PerplexityError,          # Base exception\n    AuthenticationError,      # Authentication failed\n    RateLimitError,          # Rate limit exceeded\n    NetworkError,            # Network issues\n    ValidationError,         # Invalid parameters\n    ResponseParseError,      # Failed to parse response\n    AccountCreationError,    # Account creation failed\n    FileUploadError,         # File upload failed\n)\n```\n\n## Testing\n\n### Run All Tests\n\n```bash\npytest tests\u002F -v\n```\n\n### With Coverage\n\n```bash\npytest tests\u002F --cov=perplexity --cov=perplexity_async --cov-report=html\n```\n\n### Run Specific Tests\n\n```bash\npytest tests\u002Ftest_utils.py -v\npytest tests\u002Ftest_config.py -v\n```\n\n## Development\n\n### Setup Development Environment\n\n```bash\n# Clone repository\ngit clone https:\u002F\u002Fgithub.com\u002Fyourusername\u002Fperplexity-ai.git\ncd perplexity-ai\n\n# Install in development mode\npip install -e \".[dev]\"\n\n# Run tests\npytest\n\n# Format code\nblack perplexity perplexity_async\n\n# Check types\nmypy perplexity perplexity_async\n\n# Lint\nflake8 perplexity perplexity_async\n```\n\n### Contributing\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature\u002Famazing-feature`)\n3. Make your changes\n4. Run tests and linting\n5. Commit your changes (`git commit -m 'Add amazing feature'`)\n6. Push to the branch (`git push origin feature\u002Famazing-feature`)\n7. Open a Pull Request\n\n## Troubleshooting\n\n### Common Issues\n\n**Issue**: Response returns `None`\n- **Solution**: The API structure may have changed. Check [Changelog](docs\u002FCHANGELOG.md) for updates.\n\n**Issue**: Account creation fails\n- **Solution**: Emailnator cookies expire frequently. Get fresh cookies from [Emailnator.com](https:\u002F\u002Femailnator.com\u002F).\n\n**Issue**: File upload fails\n- **Solution**: Ensure you have a valid Perplexity account with file upload quota available.\n\n**Issue**: Rate limiting\n- **Solution**: Use built-in rate limiting or wait between requests. Consider using async API for better concurrency.\n\n### Getting Help\n\n- Check the [examples\u002F](examples\u002F) directory for working code\n- Read the [documentation](docs\u002F)\n- Open an issue on GitHub\n\n## Changelog\n\nSee [CHANGELOG.md](docs\u002FCHANGELOG.md) for detailed changes and bug fixes.\n\n## Roadmap\n\nSee [IMPROVEMENTS.md](docs\u002FIMPROVEMENTS.md) for planned improvements and features.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n## Acknowledgments\n\n- [Perplexity.ai](https:\u002F\u002Fperplexity.ai\u002F) for the amazing AI search engine\n- [Emailnator](https:\u002F\u002Femailnator.com\u002F) for temporary email service\n- All contributors who help improve this project\n\n## Disclaimer\n\nThis is an unofficial API wrapper. Use responsibly and respect Perplexity.ai's terms of service. This project is for educational purposes only.\n","# Perplexity AI\n\n![Python](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fpython-3.8+-blue.svg)\n![License](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Flicense-MIT-green.svg)\n\nPerplexity AI 是一个 Python 模块，利用 [Emailnator](https:\u002F\u002Femailnator.com\u002F) 自动生成 Gmail 账户，从而实现无限次 Pro 查询。它同时支持同步（synchronous）和异步（asynchronous）API，并提供 Web 界面，方便偏好图形用户界面（GUI）的用户使用。\n\n## 功能特性\n\n- **账户生成**：通过 Emailnator 自动创建 Gmail 账户\n- **无限 Pro 查询**：通过创建新账户绕过查询次数限制\n- **Web 界面**：通过浏览器自动化账户创建与使用\n- **同步与异步 API**：完整支持同步和异步编程模式\n- **类型安全**：提供完整的类型提示（type hints），提升 IDE 支持体验\n- **健壮的错误处理**：自定义异常，便于错误管理\n- **全面的日志记录**：结构化日志，便于调试\n- **文件上传**：支持文档分析与问答\n- **流式响应**：实时流式返回响应内容\n- **重试机制**：自动重试并采用指数退避策略（exponential backoff）\n- **速率限制**：内置限速机制，防止滥用\n\n## 安装\n\n### 基础安装\n\n```bash\npip install -e .\n```\n\n### 含驱动支持（用于 Web 界面）\n\n```bash\npip install -e \".[driver]\"\npatchright install chromium\n```\n\n### 含 MCP 服务器支持\n\n```bash\npip install -e \".[mcp]\"\n```\n\n### 开发环境安装\n\n```bash\npip install -e \".[dev]\"\n```\n\n此安装包含测试工具（pytest、pytest-cov、pytest-asyncio）、代码格式化与检查工具（flake8、black、isort、mypy）以及所有可选依赖项。\n\n## MCP 服务器\n\n本项目包含一个 MCP（Model Context Protocol，模型上下文协议）服务器，可将 Perplexity 搜索功能作为工具暴露给 Claude Code 等 MCP 客户端使用。该服务器无需 API 密钥，而是通过与本库其他部分相同的逆向工程 Web 接口实现功能。\n\n### 安装\n\n```bash\npip install -e \".[mcp]\"\n```\n\n### 启动服务器\n\n服务器支持两种传输方式，由环境变量 `MCP_TRANSPORT` 控制（默认为 `stdio`）。\n\n#### stdio（默认）\n\n适用于本地 MCP 客户端，如 Claude Code 和 Claude Desktop。客户端会直接启动该进程。\n\n```bash\nperplexity-mcp\n```\n\n添加到 Claude Code：\n\n```bash\nclaude mcp add perplexity -- perplexity-mcp\n```\n\n手动配置示例：\n\n```json\n{\n  \"mcpServers\": {\n    \"perplexity\": {\n      \"command\": \"perplexity-mcp\",\n      \"env\": {\n        \"PERPLEXITY_COOKIES\": \"{\\\"next-auth.session-token\\\": \\\"...\\\"}\"\n      }\n    }\n  }\n}\n```\n\n#### HTTP（网络\u002F远程）\n\n启动一个持久化的 HTTP 服务器，允许多个客户端通过网络连接。适用于在多台客户端或机器间共享同一个服务器实例的场景。\n\n**1. 启动服务器：**\n\n```bash\nMCP_TRANSPORT=http perplexity-mcp\n```\n\n默认监听 `127.0.0.1:8000`。若需绑定所有接口或更改端口：\n\n```bash\nMCP_TRANSPORT=http MCP_HOST=0.0.0.0 MCP_PORT=9000 perplexity-mcp\n```\n\n若需包含 Cookie：\n\n```bash\nMCP_TRANSPORT=http PERPLEXITY_COOKIES='{\"next-auth.session-token\": \"...\"}' perplexity-mcp\n```\n\nMCP 端点将可通过 `http:\u002F\u002F\u003Chost>:\u003Cport>\u002Fmcp` 访问。\n\n**2. 添加到 Claude Code：**\n\n```bash\nclaude mcp add --transport http perplexity http:\u002F\u002F127.0.0.1:8000\u002Fmcp\n```\n\n如果更改了主机或端口，请相应调整 URL。对于远程机器，请将 `127.0.0.1` 替换为其实际地址。\n\n**3. 验证配置：**\n\n```bash\nclaude mcp list\n```\n\n---\n\n`PERPLEXITY_COOKIES` 环境变量对两种传输方式均为可选。若未设置，服务器将以匿名模式运行，仅能访问免费（auto 模式）查询功能。若设置为有效的 Perplexity Cookie JSON 字符串，则可启用 Pro、推理（reasoning）和深度研究（deep research）模式。获取 Cookie 的方法请参见 [如何获取 Cookie](#how-to-get-cookies)。\n\n### 可用工具\n\n| 工具 | 模式 | 描述 |\n|------|------|-------------|\n| `perplexity_ask` | `auto` | 通用问答 |\n| `perplexity_research` | `deep research` | 对主题进行深入研究 |\n| `perplexity_reason` | `reasoning` | 分步推理解决问题 |\n| `perplexity_search` | `pro` + 网络来源 | 网络搜索 |\n\n### 与官方 MCP 的差异\n\n官方 [`@perplexity-ai\u002Fmcp-server`](https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002F@perplexity-ai\u002Fmcp-server) 需要付费的 Perplexity API 密钥，而本服务器使用的是逆向工程的 Web 接口。因此，以下官方 MCP 支持的功能在本服务器中**不支持**：\n\n| 功能 | 官方 MCP | 本服务器 |\n|---------|-------------|-------------|\n| 无需 API 密钥 | 否 | **是** |\n| `messages` 数组输入 | 是 | 否（仅支持单个 `query` 字符串） |\n| `search_recency_filter` | 是 | 否 |\n| `search_domain_filter` | 是 | 否 |\n| `search_context_size` | 是 | 否 |\n| `reasoning_effort` | 是 | 否 |\n| `strip_thinking` | 是 | 否 |\n| 结构化搜索结果（引用、图片等） | 是 | 否（仅返回纯文本答案） |\n\n## 快速开始\n\n### 基础用法\n\n```python\nimport perplexity\n\n# 创建客户端\nclient = perplexity.Client()\n\n# 发起查询\nresponse = client.search(\"什么是人工智能？\")\nprint(response['answer'])\n```\n\n### 使用账户（启用增强功能）\n\n```python\nimport perplexity\n\n# 你的 Perplexity Cookie\ncookies = {\n    'next-auth.csrf-token': 'your-token',\n    'next-auth.session-token': 'your-session',\n}\n\nclient = perplexity.Client(cookies)\n\n# 使用增强模式\nresponse = client.search(\n    \"复杂的查询内容\",\n    mode='pro',\n    model='gpt-5.2',\n    sources=['scholar']\n)\n```\n\n### 流式响应\n\n```python\nfor chunk in client.search(\"解释量子计算\", stream=True):\n    if 'answer' in chunk:\n        print(chunk['answer'], end='', flush=True)\n```\n\n### 异步用法\n\n```python\nimport asyncio\nimport perplexity_async\n\nasync def main():\n    client = await perplexity_async.Client()\n    response = await client.search(\"什么是机器学习？\")\n    print(response['answer'])\n\nasyncio.run(main())\n```\n\n## 文档\n\n- **[示例](examples\u002F)** - 常见使用场景的实用示例\n- **[更新日志](docs\u002FCHANGELOG.md)** - Bug 修复与变更历史\n- **[改进计划](docs\u002FIMPROVEMENTS.md)** - 建议的改进方向与路线图\n- **[API 参考](#api-reference)** - 完整的 API 文档\n\n## 使用说明\n\n### Web 界面\n\nWeb 界面在浏览器中自动完成账号创建和使用。[Patchright](https:\u002F\u002Fgithub.com\u002FKaliiiiiiiiii-Vinyzu\u002Fpatchright-python#best-practices) 使用 [\"Chrome 用户数据目录\"](https:\u002F\u002Fwww.google.com\u002Fsearch?q=chrome+user+data+directory) 来实现完全无痕，Windows 系统下的路径为 ``C:\\Users\\YourName\\AppData\\Local\\Google\\Chrome\\User Data``，如下所示：\n\n```python\nimport os\nfrom perplexity.driver import Driver\n\ncli = Driver()\ncli.run(rf'C:\\\\Users\\\\{os.getlogin()}\\\\AppData\\\\Local\\\\Google\\\\Chrome\\\\User Data')\n```\n\n若要使用你自己的 Chrome 实例，请启用远程调试（在 Cloudflare 中可能会陷入死循环）：\n\n1. 在 Chrome 快捷方式的目标中添加 `--remote-debugging-port=9222`。\n2. 将端口传递给 `Driver.run()` 方法：\n\n```python\ncli.run(rf'C:\\\\Users\\\\{os.getlogin()}\\\\AppData\\\\Local\\\\Google\\\\Chrome\\\\User Data', port=9222)\n```\n\n### API 使用\n\n#### 同步 API\n\n以下是一个简单用法的示例代码，不使用自有账号，也不生成新账号。\n\n```python3\nimport perplexity\n\nperplexity_cli = perplexity.Client()\n\n# model = 模式对应的模型，仅限自有账号使用，取值如下：\n#     'auto': [None],\n#     'pro': [None, 'sonar', 'gpt-5.2', 'claude-4.5-sonnet', 'grok-4-1'],\n#     'reasoning': [None, 'gpt-5.2-thinking', 'claude-4.5-sonnet-thinking', 'gemini-3.0-pro', 'kimi-k2-thinking', 'grok-4.1-reasoning'],\n#     'deep research': [None]\n# sources = ['web', 'scholar', 'social']\n# files = 字典，键为文件名，值为文件内容\n# stream = 启用时返回生成器，禁用时仅返回最终响应\n# language = 所需语言的 ISO 639 代码\n# follow_up = 用于后续查询的上一次查询信息，可直接传入前一次查询的响应，见下方第二个示例\n# incognito = 启用无痕模式，适用于使用自有账号的用户\nresp = perplexity_cli.search('Your query here', mode='auto', model=None, sources=['web'], files={}, stream=False, language='en-US', follow_up=None, incognito=False)\nprint(resp)\n\n# 第二个示例展示如何使用后续查询和流式响应\nfor i in perplexity_cli.search('Your query here', stream=True, follow_up=resp):\n    print(i)\n```\n\n以下是使用自有账号的方式，你需要获取自己的 cookies 才能使用自有账号。参见 [如何获取 Cookies](#how-to-get-cookies)：\n\n```python3\nimport perplexity\n\nperplexity_cookies = { \n    \u003Cyour cookies here>\n}\n\nperplexity_cli = perplexity.Client(perplexity_cookies)\n\nresp = perplexity_cli.search('Your query here', mode='reasoning', model='gpt-5.2-thinking', sources=['web'], files={'myfile.txt': open('file.txt').read()}, stream=False, language='en-US', follow_up=None, incognito=False)\nprint(resp)\n```\n\n最后是账号生成功能，你需要获取 [Emailnator](https:\u002F\u002Femailnator.com\u002F) 的 cookies 才能使用此功能。参见 [如何获取 Cookies](#how-to-get-cookies)：\n\n```python3\nimport perplexity\n\nemailnator_cookies = { \n    \u003Cyour cookies here>\n}\n\nperplexity_cli = perplexity.Client()\nperplexity_cli.create_account(emailnator_cookies) # 创建一个新的 Gmail 账号，从而重置你的 5 次 Pro 查询额度。\n\nresp = perplexity_cli.search('Your query here', mode='reasoning', model=None, sources=['web'], files={'myfile.txt': open('file.txt').read()}, stream=False, language='en-US', follow_up=None, incognito=False)\nprint(resp)\n```\n\n#### 异步 API\n\n以下是一个简单用法的示例代码，不使用自有账号，也不生成新账号。\n\n```python3\nimport asyncio\nimport perplexity_async\n\nasync def test():\n    perplexity_cli = await perplexity_async.Client()\n\n    # mode = ['auto', 'pro', 'reasoning', 'deep research']\n    # model = 模式对应的模型，仅限自有账号使用，取值如下：\n    #     'auto': [None],\n    #     'pro': [None, 'sonar', 'gpt-5.2', 'claude-4.5-sonnet', 'grok-4-1'],\n    #     'reasoning': [None, 'gpt-5.2-thinking', 'claude-4.5-sonnet-thinking', 'gemini-3.0-pro', 'kimi-k2-thinking', 'grok-4.1-reasoning'],\n    #     'deep research': [None]\n    # sources = ['web', 'scholar', 'social']\n    # files = 字典，键为文件名，值为文件内容\n    # stream = 启用时返回生成器，禁用时仅返回最终响应\n    # language = 所需语言的 ISO 639 代码\n    # follow_up = 用于后续查询的上一次查询信息，可直接传入前一次查询的响应，见下方第二个示例\n    # incognito = 启用无痕模式，适用于使用自有账号的用户\n    resp = await perplexity_cli.search('Your query here', mode='auto', model=None, sources=['web'], files={}, stream=False, language='en-US', follow_up=None, incognito=False)\n    print(resp)\n\n    # 第二个示例展示如何使用后续查询和流式响应\n    async for i in await perplexity_cli.search('Your query here', stream=True, follow_up=resp):\n        print(i)\n\nasyncio.run(test())\n```\n\n以下是使用自有账号的方式，你需要获取自己的 cookies 才能使用自有账号。参见 [如何获取 Cookies](#how-to-get-cookies)：\n\n```python3\nimport asyncio\nimport perplexity_async\n\nperplexity_cookies = { \n    \u003Cyour cookies here>\n}\n\nasync def test():\n    perplexity_cli = await perplexity_async.Client(perplexity_cookies)\n\n    resp = await perplexity_cli.search('Your query here', mode='reasoning', model='gpt-5.2-thinking', sources=['web'], files={'myfile.txt': open('file.txt').read()}, stream=False, language='en-US', follow_up=None, incognito=False)\n    print(resp)\n\nasyncio.run(test())\n```\n\n最后是账号生成功能，你需要获取 [emailnator](https:\u002F\u002Femailnator.com\u002F) 的 cookies 才能使用此功能。参见 [如何获取 Cookies](#how-to-get-cookies)：\n\n```python3\nimport asyncio\nimport perplexity_async\n\nemailnator_cookies = { \n    \u003Cyour cookies here>\n}\n\nasync def test():\n    perplexity_cli = await perplexity_async.Client()\n    await perplexity_cli.create_account(emailnator_cookies) # 创建一个新的 Gmail 账号，从而重置你的 5 次 Pro 查询额度。\n\n    resp = await perplexity_cli.search('Your query here', mode='reasoning', model=None, sources=['web'], files={'myfile.txt': open('file.txt').read()}, stream=False, language='en-US', follow_up=None, incognito=False)\n    print(resp)\n\nasyncio.run(test())\n```\n\n## 如何获取 Cookies\n\n### Perplexity（用于使用自有账号）\n* 打开 [Perplexity.ai](https:\u002F\u002Fperplexity.ai\u002F) 网站并登录你的账号。\n* 按下 F12 或 ``Ctrl + Shift + I`` 打开检查器（Inspector）。\n* 在检查器中切换到 \"Network\"（网络）标签页。\n* 刷新页面，右键点击第一个请求，将鼠标悬停在 \"Copy\"（复制）上，然后点击 \"Copy as cURL (bash)\"（以 cURL (bash) 格式复制）。\n* 现在前往 [CurlConverter](https:\u002F\u002Fcurlconverter.com\u002Fpython\u002F)，将你复制的代码粘贴进去。Cookies 字典将会显示出来，复制并在你的代码中使用即可。\n\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhelallao_perplexity-ai_readme_10402a3b80b4.png\">\n\n### Emailnator（用于账号生成）\n* 打开 [Emailnator](https:\u002F\u002Femailnator.com\u002F) 网站并完成人机验证。\n* 按下 F12 或 ``Ctrl + Shift + I`` 打开开发者工具（inspector）。\n* 在开发者工具中切换到 \"Network\"（网络）标签页。\n* 刷新页面，右键点击第一个请求，将鼠标悬停在 \"Copy\"（复制）上，然后点击 \"Copy as cURL (bash)\"（以 cURL (bash) 格式复制）。\n* 现在前往 [CurlConverter](https:\u002F\u002Fcurlconverter.com\u002Fpython\u002F)，将你复制的代码粘贴进去。此时会生成 cookies 字典，请将其复制并在你的代码中使用。\n* [Emailnator](https:\u002F\u002Femailnator.com\u002F) 的 cookies 是临时的，需要持续更新。\n\n\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhelallao_perplexity-ai_readme_c8628bb505da.png\">\n\n## API 参考\n\n### Client 类\n\n```python\nclass Client:\n    def __init__(self, cookies: Optional[Dict[str, str]] = None):\n        \"\"\"\n        初始化 Perplexity 客户端。\n        \n        Args:\n            cookies: 可选的 Perplexity 账号 cookies，用于启用增强功能\n        \"\"\"\n    \n    def search(\n        self,\n        query: str,\n        mode: str = 'auto',\n        model: Optional[str] = None,\n        sources: List[str] = ['web'],\n        files: Dict[str, Union[str, bytes]] = {},\n        stream: bool = False,\n        language: str = 'en-US',\n        follow_up: Optional[Dict] = None,\n        incognito: bool = False\n    ) -> Union[Dict, Generator]:\n        \"\"\"\n        使用 Perplexity AI 进行搜索。\n        \n        Args:\n            query: 搜索查询内容\n            mode: 搜索模式（'auto', 'pro', 'reasoning', 'deep research'）\n            model: 使用的模型（取决于 mode）\n            sources: 信息来源（['web', 'scholar', 'social']）\n            files: 要上传的文件 {文件名: 内容}\n            stream: 启用流式响应\n            language: ISO 639 语言代码\n            follow_up: 用于上下文的上一次查询\n            incognito: 启用无痕模式\n            \n        Returns:\n            包含 'answer' 键的响应字典，或当 stream=True 时返回生成器\n        \"\"\"\n    \n    def create_account(self, emailnator_cookies: Dict[str, str]):\n        \"\"\"\n        使用 Emailnator 创建新账号。\n        \n        Args:\n            emailnator_cookies: 用于账号创建的 Emailnator cookies\n        \"\"\"\n```\n\n### 可用模型\n\n```python\n{\n    'auto': [None],\n    'pro': [None, 'sonar', 'gpt-5.2', 'claude-4.5-sonnet', 'grok-4-1'],\n    'reasoning': [None, 'gpt-5.2-thinking', 'claude-4.5-sonnet-thinking', 'gemini-3.0-pro', 'kimi-k2-thinking', 'grok-4.1-reasoning'],\n    'deep research': [None]\n}\n```\n\n### 自定义异常\n\n```python\nfrom perplexity.exceptions import (\n    PerplexityError,          # 基础异常\n    AuthenticationError,      # 认证失败\n    RateLimitError,          # 超出速率限制\n    NetworkError,            # 网络问题\n    ValidationError,         # 参数无效\n    ResponseParseError,      # 响应解析失败\n    AccountCreationError,    # 账号创建失败\n    FileUploadError,         # 文件上传失败\n)\n```\n\n## 测试\n\n### 运行所有测试\n\n```bash\npytest tests\u002F -v\n```\n\n### 带覆盖率报告\n\n```bash\npytest tests\u002F --cov=perplexity --cov=perplexity_async --cov-report=html\n```\n\n### 运行特定测试\n\n```bash\npytest tests\u002Ftest_utils.py -v\npytest tests\u002Ftest_config.py -v\n```\n\n## 开发\n\n### 设置开发环境\n\n```bash\n# 克隆仓库\ngit clone https:\u002F\u002Fgithub.com\u002Fyourusername\u002Fperplexity-ai.git\ncd perplexity-ai\n\n# 以开发模式安装\npip install -e \".[dev]\"\n\n# 运行测试\npytest\n\n# 格式化代码\nblack perplexity perplexity_async\n\n# 类型检查\nmypy perplexity perplexity_async\n\n# 代码检查\nflake8 perplexity perplexity_async\n```\n\n### 贡献代码\n\n1. Fork 本仓库\n2. 创建特性分支（`git checkout -b feature\u002Famazing-feature`）\n3. 进行修改\n4. 运行测试和代码检查\n5. 提交更改（`git commit -m 'Add amazing feature'`）\n6. 推送到分支（`git push origin feature\u002Famazing-feature`）\n7. 提交 Pull Request\n\n## 故障排除\n\n### 常见问题\n\n**问题**: 响应返回 `None`  \n- **解决方案**: API 结构可能已变更。请查看 [Changelog](docs\u002FCHANGELOG.md) 获取更新信息。\n\n**问题**: 账号创建失败  \n- **解决方案**: Emailnator cookies 会频繁过期。请从 [Emailnator.com](https:\u002F\u002Femailnator.com\u002F) 获取新的 cookies。\n\n**问题**: 文件上传失败  \n- **解决方案**: 确保你拥有有效的 Perplexity 账号，并且有可用的文件上传配额。\n\n**问题**: 触发速率限制  \n- **解决方案**: 使用内置的速率限制功能，或在请求之间增加等待时间。考虑使用异步 API 以获得更好的并发性能。\n\n### 获取帮助\n\n- 查看 [examples\u002F](examples\u002F) 目录中的可运行示例代码\n- 阅读 [文档](docs\u002F)\n- 在 GitHub 上提交 issue\n\n## 更新日志\n\n详细变更和错误修复请参阅 [CHANGELOG.md](docs\u002FCHANGELOG.md)。\n\n## 路线图\n\n计划中的改进和功能请参阅 [IMPROVEMENTS.md](docs\u002FIMPROVEMENTS.md)。\n\n## 许可证\n\n本项目采用 MIT 许可证。详情请参阅 [LICENSE](LICENSE) 文件。\n\n## 致谢\n\n- [Perplexity.ai](https:\u002F\u002Fperplexity.ai\u002F) 提供了出色的 AI 搜索引擎\n- [Emailnator](https:\u002F\u002Femailnator.com\u002F) 提供了临时邮箱服务\n- 所有帮助改进本项目的贡献者\n\n## 免责声明\n\n这是一个非官方的 API 封装库。请负责任地使用，并遵守 Perplexity.ai 的服务条款。本项目仅用于教育目的。","# Perplexity AI 开源工具快速上手指南\n\n## 环境准备\n\n- **Python 版本**：3.8 或更高\n- **操作系统**：Windows \u002F macOS \u002F Linux 均支持\n- **可选依赖**：\n  - 如需使用 Web 界面（自动创建账号），需安装 Chromium（推荐通过 `patchright` 安装）\n  - 国内用户建议配置 pip 镜像源（如清华源）加速安装：\n    ```bash\n    pip config set global.index-url https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n    ```\n\n## 安装步骤\n\n### 基础安装（仅 API 功能）\n```bash\npip install -e .\n```\n\n### 安装 Web 界面支持（用于自动创建 Gmail 账号）\n```bash\npip install -e \".[driver]\"\npatchright install chromium\n```\n\n### 安装 MCP Server（用于与 Claude Code 等客户端集成）\n```bash\npip install -e \".[mcp]\"\n```\n\n### 开发者安装（包含测试、格式化、类型检查等工具）\n```bash\npip install -e \".[dev]\"\n```\n\n> 💡 提示：国内网络环境下，若 `patchright install chromium` 下载缓慢，可手动下载 Chromium 并配置环境变量，或使用代理。\n\n## 基本使用\n\n### 1. 最简查询（匿名模式，免费额度）\n```python\nimport perplexity\n\nclient = perplexity.Client()\nresponse = client.search(\"什么是人工智能？\")\nprint(response['answer'])\n```\n\n### 2. 流式响应（实时输出）\n```python\nfor chunk in client.search(\"解释量子计算\", stream=True):\n    if 'answer' in chunk:\n        print(chunk['answer'], end='', flush=True)\n```\n\n### 3. 异步调用（需安装基础包即可）\n```python\nimport asyncio\nimport perplexity_async\n\nasync def main():\n    client = await perplexity_async.Client()\n    response = await client.search(\"机器学习是什么？\")\n    print(response['answer'])\n\nasyncio.run(main())\n```\n\n> ✅ 提示：以上示例无需账号即可运行，使用 Perplexity 的免费“auto”模式。如需使用 **pro**、**reasoning** 或 **deep research** 模式，请配置你的 Perplexity Cookie（获取方式见项目 README 中的 *How To Get Cookies* 部分）。","某市场研究团队需要每天从公开渠道收集全球新兴AI初创公司的动态，并生成结构化简报供高管决策。\n\n### 没有 perplexity-ai 时\n- 团队成员手动登录 Perplexity.ai 免费账号，每天仅能提交有限次数的高级查询（如深度研究或推理模式），无法满足高频信息采集需求。\n- 为绕过限制，需频繁注册新 Gmail 账号并手动完成邮箱验证，耗时且易出错。\n- 自动化脚本难以集成 Perplexity 的网页功能，尤其无法处理文件上传（如分析竞品PDF报告）和流式响应。\n- 在 Claude Code 中调用 Perplexity 功能需依赖官方 API（尚未开放），只能通过复制粘贴间接使用，打断工作流。\n- 查询失败后缺乏自动重试机制，网络波动时常导致任务中断，需人工干预。\n\n### 使用 perplexity-ai 后\n- 利用内置 Emailnator 自动批量生成临时邮箱并创建 Perplexity 账号，实现无限次 Pro 级查询，支撑每日上百条深度检索任务。\n- 通过同步\u002F异步 API 直接嵌入现有 Python 数据管道，轻松上传行业报告并发起文档问答，结果实时流式返回。\n- 启动 MCP Server 后，Claude Code 可直接调用 `perplexity_research` 工具，在代码编辑器内一键触发深度市场扫描，无缝衔接分析流程。\n- 内置指数退避重试与结构化日志，即使偶发请求失败也能自动恢复，保障夜间批处理任务稳定运行。\n- Web 界面为非技术成员提供图形化操作入口，无需编码即可执行复杂查询并导出结果。\n\nperplexity-ai 将原本受限、割裂的手动搜索转化为可扩展、自动化的智能信息获取系统，显著提升团队研究效率与数据覆盖广度。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fhelallao_perplexity-ai_f5e5de2e.png","helallao","Ali Yaşar","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fhelallao_63f034bc.png",null,"@Metakorteks","Adana, Turkey","https:\u002F\u002Fmetakorteks.com\u002F","https:\u002F\u002Fgithub.com\u002Fhelallao",[84],{"name":85,"color":86,"percentage":87},"Python","#3572A5",100,1521,299,"2026-04-05T20:01:39","MIT","Linux, macOS, Windows","未说明",{"notes":95,"python":96,"dependencies":97},"若需使用 Web 界面功能，需安装 Chromium 并配置 Chrome 用户数据目录；MCP 服务器支持 stdio 和 HTTP 两种传输方式；部分高级功能（如 Pro 模式）需要提供 Perplexity 或 Emailnator 的 Cookie。","3.8+",[98,99,100,101,102,103,104,105,106,107],"emailnator","patchright","flask","pydantic","requests","aiohttp","pytest","black","mypy","flake8",[26,15,51,13,53,14],[110,111,112,113,114,115,116,117],"ai","api","artificial-intelligence","chatgpt","gpt","language-model","language-models","perplexity",5,"2026-03-27T02:49:30.150509","2026-04-06T07:12:44.126922",[122,127,132,137,142,147],{"id":123,"question_zh":124,"answer_zh":125,"source_url":126},186,"如何正确设置并运行 perplexity-ai 项目？","项目本身没有提供详细的设置指南。若需使用代理，可参考互联网上关于 curl_cffi 配合代理的资源。维护者建议直接在本地运行脚本，而非通过代理绕过 Cloudflare。","https:\u002F\u002Fgithub.com\u002Fhelallao\u002Fperplexity-ai\u002Fissues\u002F53",{"id":128,"question_zh":129,"answer_zh":130,"source_url":131},187,"为什么使用 Cookie 时返回 403 错误？","首先尝试更新 websocket-client 库：`pip3 install websocket-client`。此外，获取 Cookie 时若被重定向到 Cloudflare 验证页面，会导致 Cookie 无效。应避免触发验证码：在 Perplexity 网站输入邮箱后点击“Continue with Email”时，若跳转到验证码页面，请返回重试，直到不触发验证码为止，再复制最新 Cookie。","https:\u002F\u002Fgithub.com\u002Fhelallao\u002Fperplexity-ai\u002Fissues\u002F25",{"id":133,"question_zh":134,"answer_zh":135,"source_url":136},188,"初始化 Client 时出现 JSONDecodeError（如 'Expecting value: line 1 column 1'）怎么办？","该错误通常是因为请求被 Cloudflare 拦截，返回的是 HTML 验证页面而非 JSON 数据。解决方法包括：确保使用有效的、未触发 Cloudflare 验证的 Cookie；检查请求头（headers）是否与浏览器一致；必要时手动替换为从浏览器复制的完整请求头。","https:\u002F\u002Fgithub.com\u002Fhelallao\u002Fperplexity-ai\u002Fissues\u002F52",{"id":138,"question_zh":139,"answer_zh":140,"source_url":141},189,"LabsClient 初始化失败，返回 Cloudflare 的 'Just a moment...' 页面怎么办？","这表明请求被 Cloudflare 拦截。根本原因是 Labs API 同样受 Cloudflare 保护，若 Cookie 或请求头无效，会返回 HTML 而非 JSON。应确保使用有效的会话 Cookie，并模仿真实浏览器的请求头。目前该项目对 Labs API 的支持不稳定，有用户转向使用官方 API 或 Node.js 替代方案。","https:\u002F\u002Fgithub.com\u002Fhelallao\u002Fperplexity-ai\u002Fissues\u002F33",{"id":143,"question_zh":144,"answer_zh":145,"source_url":146},190,"WebSocket 连接在首次请求后立即断开怎么办？","此问题通常由 Cloudflare 防护机制导致。可尝试在 on_message 回调中添加 `print(message)` 调试输出，观察是否收到有效消息。若 WebSocket 线程迅速断开，说明连接被服务器拒绝，需检查 Cookie 和请求头的有效性，确保未触发 Cloudflare 验证。","https:\u002F\u002Fgithub.com\u002Fhelallao\u002Fperplexity-ai\u002Fissues\u002F36",{"id":148,"question_zh":149,"answer_zh":150,"source_url":136},191,"使用自定义 Cookie 初始化 Client 时报 JSON 解析错误如何解决？","用户反馈通过将请求头（headers）替换为自己从浏览器复制的真实请求头后问题得以解决。因此，除了提供完整 Cookie 外，还需确保 User-Agent、Accept 等请求头与浏览器一致，以避免被服务端拒绝。",[]]