{"id":23399624,"url":"https://github.com/adryfish/llm-web-api","last_synced_at":"2025-04-09T12:08:13.643Z","repository":{"id":241274414,"uuid":"803875402","full_name":"adryfish/llm-web-api","owner":"adryfish","description":"将ChatGPT网页转换成API接口。ChatGPT Web to API.","archived":false,"fork":false,"pushed_at":"2025-02-19T14:53:04.000Z","size":25,"stargazers_count":83,"open_issues_count":1,"forks_count":12,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-02T11:01:42.824Z","etag":null,"topics":["chatgpt","chatgpt-api","chatgpt-api-wrapper","openai","openai-api"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adryfish.png","metadata":{"files":{"readme":"README-ZH.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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-05-21T14:30:23.000Z","updated_at":"2025-03-29T16:19:02.000Z","dependencies_parsed_at":"2024-07-10T16:27:58.854Z","dependency_job_id":"fd691e75-8694-4d48-9da9-97374e8d827b","html_url":"https://github.com/adryfish/llm-web-api","commit_stats":{"total_commits":3,"total_committers":1,"mean_commits":3.0,"dds":0.0,"last_synced_commit":"56887b011bc82d6b0076709a8ee43e042ce25909"},"previous_names":["adryfish/llm-web-api"],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adryfish%2Fllm-web-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adryfish%2Fllm-web-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adryfish%2Fllm-web-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adryfish%2Fllm-web-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adryfish","download_url":"https://codeload.github.com/adryfish/llm-web-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248036067,"owners_count":21037092,"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","chatgpt-api","chatgpt-api-wrapper","openai","openai-api"],"created_at":"2024-12-22T10:15:23.920Z","updated_at":"2025-04-09T12:08:13.617Z","avatar_url":"https://github.com/adryfish.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# LLM Web API\n\n[![](https://img.shields.io/github/license/adryfish/llm-web-api.svg)](LICENSE)\n![](https://img.shields.io/github/stars/adryfish/llm-web-api.svg)\n![](https://img.shields.io/github/forks/adryfish/llm-web-api.svg)\n\n使用`Playwright`将网页版ChatGPT转换成`API`接口\n\n## 功能列表\n - 通过`Cloudflare`验证破解\n - 登录模式支持免登录、邮箱登录和Google登录\n - 高速流式输出\n - 模型切换,动态显示支持模型\n - 对话支持\n - TTS支持(文本转语音支持)\n\n与ChatGPT接口完全兼容。\n\n## 使用方法\n\n### 使用Docker运行\n\n```shell\ndocker run --name llm-web-api --rm -it -p 5000:5000 adryfish/llm-web-api\n```\n\n### 使用Docker compose\n\n详细配置见下方环境变量\n\n```yml\nservices:\n  llm-web-api:\n    image: adryfish/llm-web-api\n    container_name: llm-web-api\n    ports:\n      - \"5000:5000\"\n    volumes:\n      # 浏览器数据，如何要保留浏览器登录信息，需要配置\n      - ./data:/app/data\n    environment:\n      # PROXY_SERVER: \"\"          # 代理服务器地址\n      # OPENAI_LOGIN_TYPE: \"\"     # 登录类型,nologin or email或者google\n      # OPENAI_LOGIN_EMAIL: \"\"    # 登录邮箱\n      # OPENAI_LOGIN_PASSWORD: \"\" # 登录密码\n    restart: unless-stopped\n```\n\n### 环境变量\n\n所有的环境变量均为可选。\n\n| 变量名                 | 描述                                    | 默认值  |\n|-----------------------|----------------------------------------|--------|\n| PROXY_SERVER          | 代理服务器地址                            | None     |\n| DATA_DIR              | 数据存放目录                         | 当前目录/data   |\n| OPENAI_LOGIN_TYPE     | ChatGPT 的登录类型, nologin, email, google    | nologin|\n| OPENAI_LOGIN_EMAIL    | 对于 email 登录方式，提供 email 帐号        | None     |\n| OPENAI_LOGIN_PASSWORD | 对于 email 登录方式，提供密码               | None     |\n| OPENAI_LOGIN_APP_PASSWORD | app password(非必须)  | None     |\n| GOOGLE_LOGIN_EMAIL    | google登录邮箱 | None      |\n| GOOGLE_LOGIN_PASSWORD    | google登录邮箱密码 | None      |\n| GOOGLE_LOGIN_OTP_SECRET    | google登录二次认证secret  | None      |\n| GOOGLE_LOGIN_RECOVERY_EMAIL    | google登录恢复邮箱  | None      |\n\n\n## 原理\n使用`Playwright`控制指纹浏览器，模拟用户操作，发送请求到OpenAI网页， 将响应转换成API接口。\n\n## 接口列表\n\n目前支持与openai兼容的 `/v1/chat/completions` 接口，可自行使用与openai或其他兼容的客户端接入接口\n\n### 对话补全\n\n对话补全接口，与openai的 [chat-completions-api](https://platform.openai.com/docs/api-reference/chat) 兼容。\n\n**POST /v1/chat/completions**\n\n请求数据：\n```jsonc\n{\n    \"model\": \"gpt-4o\",\n    \"messages\": [\n        {\n            \"role\": \"user\",\n            \"content\": \"Hello\"\n        }\n    ],\n    // 可选: 如果使用SSE流请设置为true，默认false\n    \"stream\": false\n    // 可选: 如果启用，响应中将包含元数据 (message_id 和 conversation_id)\n    // 如果同时提供 parent_message_id 和 conversation_id，则请求将在现有对话上下文中继续。\n    // 如果未设置，则请求将被视为新的对话。\n    // \"meta\": {\n    //   \"enable\": true,\n    //   \"parent_message_id\": \"5363437e-b364-4b72-b3d6-415deeed11ab\", # 可选\n    //   \"conversation_id\": \"6774f183-f70c-800b-9965-6c110d3a3485\"    # 可选 \n    // }\n}\n```\n\n响应数据：\n```jsonc\n{\n    \"id\": \"chatcmpl-fZc6l869OzRu8rp7X8Dhj0COfTsR6\",\n    \"object\": \"chat.completion\",\n    \"created\": 1733726226,\n    \"model\": \"gpt-4o\",\n    \"choices\": [\n        {\n            \"index\": 0,\n            \"message\": {\n                \"role\": \"assistant\",\n                \"content\": \"Hi there! How can I assist you today? 😊\"\n            },\n            \"logprobs\": null,\n            \"finish_reason\": \"stop\"\n        }\n    ],\n    \"usage\": {\n        \"prompt_tokens\": 1,\n        \"completion_tokens\": 11,\n        \"total_tokens\": 12\n    },\n    // 如何没有设置ENABLE_REQUEST_METADATA=True，则不会有meta数据返回\n    \"meta\": {\n        \"message_id\": \"dffd63ef-63ac-4d40-b6de-e33ec40de9e2\",\n        \"conversation_id\": \"6774f183-f70c-800b-9965-6c110d3a3485\"\n    }\n}\n```\n\n### 语音合成API\n\n语音合成API，与OpenAI的 [Audio Speech API](https://platform.openai.com/docs/api-reference/audio) 兼容。允许用户将文本转换为语音。\n\n**POST /v1/audio/speech**\n\n请求数据：\n```jsonc\n{\n    \"input\": \"你好，你今天怎么样？\",\n    \"voice\": \"cove\",\n    \"model\": \"tts-1\",\n    // 可选：指定返回格式，默认为 \"aac\"\n    \"response_format\": \"mp3\"\n}\n```\n\n响应数据:\n\n如果请求成功，API 将返回所请求格式的音频文件。\n\n\n## 用例\n### 使用Python OpenAI官方库\n#### Python\n```python\nimport openai\n\nopenai.api_key = 'anything'\nopenai.base_url = \"http://localhost:5000/v1/\"\n\ncompletion = openai.chat.completions.create(\n    model=\"gpt-4o\",\n    messages=[\n        {\"role\": \"user\", \"content\": \"Hello\"},\n    ],\n)\n\nprint(completion.choices[0].message.content)\n```\n\n#### Node.js\n\n```javascript\nimport OpenAI from 'openai';\n\nconst openai = new OpenAI({\n\tapiKey: \"anything\",\n\tbaseURL: \"http://localhost:5000/v1/\",\n});\n\nconst chatCompletion = await openai.chat.completions.create({\n  messages: [{ role: 'user', content: 'Echo Hello' }],\n  model: 'gpt-4o',\n});\n\nconsole.log(chatCompletion.choices[0].message.content);\n```\n\n\n## 同类项目 \n  - chat2api: https://github.com/lanqian528/chat2api\n\n## Star History\n\n[![Star History Chart](https://api.star-history.com/svg?repos=adryfish/llm-web-api\u0026type=Date)](https://star-history.com/#adryfish/llm-web-api\u0026Date)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadryfish%2Fllm-web-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadryfish%2Fllm-web-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadryfish%2Fllm-web-api/lists"}