环境:
阿里云硅谷地区服务器,ubuntu22

操作步骤

1.安装nginx

apt install nginx

2.编辑文件/etc/nginx/sites-enabled/default,内容替换如下

server {
        listen 80;
        location / {
                proxy_pass https://api.openai.com;
                proxy_set_header Host api.openai.com;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_ssl_server_name on;
        }
}

3.重新加载nginx

nginx -s reload

4.浏览器访问服务器ip地址:http://x.x.x.x,返回以下内容代表成功

{“message”: “Welcome to the OpenAI API! Documentation is available at https://platform.openai.com/docs/api-reference”}

5.代码中使用服务器地址http://x.x.x.x替换https://api.openai.com即可

Logo

一站式 AI 云服务平台

更多推荐