{"id":19555983,"url":"https://github.com/probiusofficial/openai-proxy","last_synced_at":"2025-04-19T18:49:21.609Z","repository":{"id":146209761,"uuid":"618011158","full_name":"ProbiusOfficial/openai-proxy","owner":"ProbiusOfficial","description":"使用腾讯云函数将Openai的API偷渡到国内x","archived":false,"fork":false,"pushed_at":"2023-03-24T03:50:18.000Z","size":2752,"stargazers_count":22,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-29T11:51:43.607Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ProbiusOfficial.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":"2023-03-23T15:12:51.000Z","updated_at":"2024-08-01T18:48:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"71c5aea6-c458-4098-96d7-deb2c496b887","html_url":"https://github.com/ProbiusOfficial/openai-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/ProbiusOfficial%2Fopenai-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProbiusOfficial%2Fopenai-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProbiusOfficial%2Fopenai-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProbiusOfficial%2Fopenai-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ProbiusOfficial","download_url":"https://codeload.github.com/ProbiusOfficial/openai-proxy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249769526,"owners_count":21323066,"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":[],"created_at":"2024-11-11T04:36:21.051Z","updated_at":"2025-04-19T18:49:21.590Z","avatar_url":"https://github.com/ProbiusOfficial.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# openai-proxy\n使用腾讯云函数将Openai的API偷渡到国内x\n\n跟随下面的文档进行搭建 / 或者直接上传封装好的代码包即可x\n\n### 如何部署\n\n在腾讯云中打开云函数列表：https://console.cloud.tencent.com/scf/list\n\n新建一个云函数，选择**从头开始**，类型为**Web函数**，**Nodejs**版本选择**16.13**如图：\n\n![](https://fastly.jsdelivr.net/gh/ProbiusOfficial/My_pic@main/2023y-3m-24-d11-h26m1679628401679.png)\n\n地区选择内陆地区以外的地区：\n\n![](https://fastly.jsdelivr.net/gh/ProbiusOfficial/My_pic@main/2023y-3m-24-d11-h26m1679628416310.png)\n\n注意超时时间的阈值高一点：\n\n![](https://fastly.jsdelivr.net/gh/ProbiusOfficial/My_pic@main/2023y-3m-24-d11-h27m1679628434367.png)\n\n启用多并发：\n\n![](https://fastly.jsdelivr.net/gh/ProbiusOfficial/My_pic@main/2023y-3m-24-d11-h27m1679628449061.png)\n\n配置API触发器：\n\n![](https://fastly.jsdelivr.net/gh/ProbiusOfficial/My_pic@main/2023y-3m-24-d11-h27m1679628459018.png)\n\n点击完成\n\n![](https://fastly.jsdelivr.net/gh/ProbiusOfficial/My_pic@main/2023y-3m-24-d11-h27m1679628472034.png)\n\n等待一段时间 来到**函数管理**选中**函数代码**，将[app.js](https://github.com/ProbiusOfficial/openai-proxy/blob/main/app.js) 和 [package.json](https://github.com/ProbiusOfficial/openai-proxy/blob/main/package.json) 替换为下面内容：\n\n```JavaScript\nconst express = require('express');\nconst { createProxyMiddleware } = require('http-proxy-middleware');\nconst app = express();\nconst port = 9000;\n\napp.get('/ok', (req, res) =\u003e {\n  res.send('Proxy service is running properly！');\n});\n\nconst openaiApiProxy = createProxyMiddleware('/', {\n  target: 'https://api.openai.com',\n  changeOrigin: true,\n  pathRewrite: {\n    '^/': '',\n  },\n});\n\napp.use(openaiApiProxy);\n\napp.listen(port, () =\u003e {\n  console.log(`Example app listening at http://localhost:${port}`);\n});\n\n```\n\n```json\n{\n  \"name\": \"origin\",\n  \"version\": \"0.0.0\",\n  \"private\": true,\n  \"scripts\": {\n    \"start\": \"node ./bin/www\"\n  },\n  \"dependencies\": {\n    \"cookie-parser\": \"~1.4.4\",\n    \"debug\": \"~2.6.9\",\n    \"express\": \"~4.16.1\",\n    \"http-errors\": \"~1.6.3\",\n    \"jade\": \"~1.11.0\",\n    \"morgan\": \"~1.9.1\",\n    \"http-proxy-middleware\": \"^2.0.6\"\n  }\n}\n```\n\n\n\n![](https://fastly.jsdelivr.net/gh/ProbiusOfficial/My_pic@main/2023y-3m-24-d11-h28m1679628483083.png)\n\n在部署处下拉，选择**自动配置依赖**\n\n![](https://fastly.jsdelivr.net/gh/ProbiusOfficial/My_pic@main/2023y-3m-24-d11-h28m1679628497091.png)\n\n最后点击部署即可。\n\n访问url/ok返回时，说明部署成功：\n\n![](https://fastly.jsdelivr.net/gh/ProbiusOfficial/My_pic@main/2023y-3m-24-d11-h28m1679628512018.png)\n\n而云函数的访问路径即可用于替换OpenAi的API地址https://api.openai.com\n\n（/release可以加也可以不加，你也可以在API网关里面进一步设置，使用自己的域名）\n\n### 如何使用\n\n云函数的访问路径即可用于替换OpenAi的API地址https://api.openai.com\n\n比如在 OpenAi Translator中 将云函数的url替换原本的openai url即可，亦或\n\n### 效果预览\n\n![](https://fastly.jsdelivr.net/gh/ProbiusOfficial/My_pic@main/2023y-3m-24-d11-h28m1679628525708.png)\n\n![](https://fastly.jsdelivr.net/gh/ProbiusOfficial/My_pic@main/2023y-3m-24-d11-h29m1679628586588.png)\n\n![](https://fastly.jsdelivr.net/gh/ProbiusOfficial/My_pic@main/2023y-3m-24-d11-h29m1679628597249.png)\n\n![](https://fastly.jsdelivr.net/gh/ProbiusOfficial/My_pic@main/2023y-3m-24-d11-h30m1679628613797.png)\n\n![](https://fastly.jsdelivr.net/gh/ProbiusOfficial/My_pic@main/2023y-3m-24-d11-h31m1679628672187.png)\n\n### 其他\n\n感谢文档：https://cloud.tencent.com/document/product/583/37920\n\n本项目代码所用代码由GPT强力驱动生成（x\n\n![](https://fastly.jsdelivr.net/gh/ProbiusOfficial/My_pic@main/2023y-3m-24-d11-h31m1679628687662.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprobiusofficial%2Fopenai-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprobiusofficial%2Fopenai-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprobiusofficial%2Fopenai-proxy/lists"}