{"id":21026239,"url":"https://github.com/ultrasev/chatrapper","last_synced_at":"2025-04-05T06:04:04.708Z","repository":{"id":216244495,"uuid":"740795133","full_name":"ultrasev/chatrapper","owner":"ultrasev","description":"网页版 ChatGPT 包装成 API ","archived":false,"fork":false,"pushed_at":"2024-10-28T10:58:29.000Z","size":311,"stargazers_count":144,"open_issues_count":1,"forks_count":33,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-29T05:05:05.541Z","etag":null,"topics":["chatgpt-api","openai","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ultrasev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-09T04:41:07.000Z","updated_at":"2025-03-28T08:09:23.000Z","dependencies_parsed_at":"2024-04-11T15:50:20.534Z","dependency_job_id":"eb833ab8-9df8-4441-bb20-11bade9f63ba","html_url":"https://github.com/ultrasev/chatrapper","commit_stats":null,"previous_names":["ultrasev/youtube-projects","ultrasev/chatgpt-wrapper","ultrasev/chatrapper"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ultrasev%2Fchatrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ultrasev%2Fchatrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ultrasev%2Fchatrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ultrasev%2Fchatrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ultrasev","download_url":"https://codeload.github.com/ultrasev/chatrapper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247294516,"owners_count":20915340,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chatgpt-api","openai","python3"],"created_at":"2024-11-19T11:43:52.450Z","updated_at":"2025-04-05T06:04:04.687Z","avatar_url":"https://github.com/ultrasev.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\u003cdiv align=\"center\"\u003e\n \u003cfigure style=\"text-align: align;\"\u003e\n     \u003cimg src=\"https://s3.bmp.ovh/imgs/2024/03/15/2aa0a21860f0ded7.png\" width=189pt\u003e\n \u003c/figure\u003e\n\u003ch2\u003eChatGPT API (W)rapper\u003c/h2\u003e\n\n\u003c/div\u003e\n\n把网页版 ChatGPT 封装为一个简单的 API，以便在代码中使用。\n\n\u003e OpenAI 对逆向的限制越来越严格，逆向难度越来越大，且各平台的 API 已经很便宜了，像 Groq 的 Llama 3 API 还一直是免费的，不太建议大家继续研究这类项目了。如果特别需要，可以参考作者的另一个项目 [juchats](https://github.com/ultrasev/juchats)，有更多免费模型可以使用。\n\n# Installation\n```bash\npip3 install git+https://github.com/ultrasev/chatrapper.git\n```\n\n# Usage\n环境变量中设置 `TOKEN`，然后调用 `chat` 函数即可。\n```bash\nexport TOKEN=\"eyJhbGci...\"\n```\n\n在代码中使用 `Rapper`:\n```python\nimport os\nfrom chatrapper import Rapper\ntoken = os.environ.get(\"TOKEN\")\nrapper = Rapper(\n    access_token=token\n    model=\"text-davinci-002-render-sha\"\n)\nrapper(\"鲁迅为什么打周树人？\")\n```\n\n或者有异步需求的话，可以使用 `AsyncRapper`。这种情况下，最好有多个账号支持，单账号下，同一时间只支持一轮对话。\n\n```python\nimport os\nimport asyncio\nfrom chatrapper import AsyncRapper\n\ntoken = os.environ.get(\"TOKEN\")\nrapper = AsyncRapper(\n    access_token=token\n    model=\"text-davinci-002-render-sha\"\n)\nasync def main():\n    print(await rapper(\"鲁迅为什么打周树人？\"))\n\nasyncio.run(main())\n```\n\nDemo:\n\n\u003cfigure style=\"text-align: left;\"\u003e\n    \u003cimg src=\"https://s3.bmp.ovh/imgs/2024/03/15/25ea45935e95e00e.gif\" width=589pt\u003e\n\u003c/figure\u003e\n\n\n# Notes\n- 一定要保护好自己的 token，不要泄露给他人。\n- 合理使用 API，调用频率不宜过高，树大易招风，避免触发风控。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fultrasev%2Fchatrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fultrasev%2Fchatrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fultrasev%2Fchatrapper/lists"}