{"id":13455819,"url":"https://github.com/easychen/openai-api-proxy","last_synced_at":"2025-05-15T18:05:18.238Z","repository":{"id":145559314,"uuid":"609024677","full_name":"easychen/openai-api-proxy","owner":"easychen","description":"一行Docker命令部署的 OpenAI/GPT API代理，支持SSE流式返回、腾讯云函数 。Simple proxy for OpenAi api via a one-line docker command","archived":false,"fork":false,"pushed_at":"2024-03-26T06:00:10.000Z","size":1796,"stargazers_count":1600,"open_issues_count":13,"forks_count":251,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-04-07T22:11:14.631Z","etag":null,"topics":["gpt-3","openai","proxy"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":false,"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/easychen.png","metadata":{"files":{"readme":"README.CN.md","changelog":null,"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":"2023-03-03T08:07:32.000Z","updated_at":"2025-04-07T15:48:56.000Z","dependencies_parsed_at":"2025-03-31T21:50:38.086Z","dependency_job_id":"22b8b46d-63b0-408b-8519-71b6258e6732","html_url":"https://github.com/easychen/openai-api-proxy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/easychen%2Fopenai-api-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/easychen%2Fopenai-api-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/easychen%2Fopenai-api-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/easychen%2Fopenai-api-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/easychen","download_url":"https://codeload.github.com/easychen/openai-api-proxy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254394720,"owners_count":22063984,"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":["gpt-3","openai","proxy"],"created_at":"2024-07-31T08:01:11.653Z","updated_at":"2025-05-15T18:05:18.200Z","avatar_url":"https://github.com/easychen.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","Uncategorized"],"sub_categories":["Uncategorized"],"readme":"\u003e ⚠️ 这是代理的服务器端，不是客户端。需要部署到可以联通 openai api 的网络环境后访问。\n\n## 特色功能\n\n1. 支持SSE流式输出\n1. 内置文本安全审核（需要配置腾讯云KEY）\n\n## NodeJS部署\n\n你可以把 ./app.js 部署到所有支持 nodejs 14+ 的环境，比如云函数和边缘计算平台。\n\n1. 复制 app.js 和 package.json 到目录 \n1. yarn install 安装依赖\n1. node app.js 启动服务\n\n## Docker部署 \n\n```\ndocker run -p 9000:9000 easychen/ai.level06.com:latest\n```\n\nProxy地址为 http://${IP}:9000\n\n### 可用环境变量\n\n1. PORT: 服务端口\n1. PROXY_KEY: 代理访问KEY，用于限制访问\n1. TIMEOUT：请求超时时间，默认30秒\n1. TENCENT_CLOUD_SID：腾讯云secret_id\n1. TENCENT_CLOUD_SKEY：腾讯云secret_key\n1. TENCENT_CLOUD_AP：腾讯云区域（如：ap-singapore 新加坡）\n\n## 接口使用方法\n\n1. 将原来项目中 openai 的请求地址（ 比如 https://api.openai.com ）中的域名变更为本 proxy 的域名/IP（注意带上端口号）\n1. 如果设置了PROXY_KEY，在 openai 的 key 后加上 `:\u003cPROXY_KEY\u003e`，如果没有设置，则不需修改\n1. moderation：true 开启审核，false 关闭审核\n1. moderation_level：high 中断所有审核结果不为 Pass 的句子，low 只中断审核结果为 Block 的句子\n\n## 说明 \n\n1. 只支持 GET 和 POST 方法的接口，不支持文件相关接口\n1. ~~当前不支持SSE，因此需要关掉 stream 相关的选项~~ 已支持\n\n## 客户端使用实例\n\n以 `https://www.npmjs.com/package/chatgpt` 为例\n\n```js\nchatApi= new gpt.ChatGPTAPI({\n    apiKey: 'sk.....:\u003cproxy_key写这里\u003e',\n    apiBaseUrl: \"http://localhost:9001/v1\", // 替换代理域名/IP\n});\n   \n```\n\n## 致谢\n\n1. SSE参考了[chatgpt-api项目相关代码](https://github.com/transitive-bullshit/chatgpt-api/blob/main/src/fetch-sse.ts)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feasychen%2Fopenai-api-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feasychen%2Fopenai-api-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feasychen%2Fopenai-api-proxy/lists"}