NextChat icon indicating copy to clipboard operation
NextChat copied to clipboard

部署 Vercel 设置 OPENAI_API_KEY 环境变量无效

Open leonfancy opened this issue 3 years ago • 19 comments

部署 Vercel 设置 OPENAI_API_KEY 环境变量无效。只能在前端设置 API KEY,但是这样的话 KEY 只有保存在本地。难道这个项目不支持在服务端设置 API KEY?

leonfancy avatar Apr 03 '23 05:04 leonfancy

请提供 vercel 控制台 log 截图。

Yidadaa avatar Apr 03 '23 05:04 Yidadaa

image 看不出什么有用的东西

leonfancy avatar Apr 03 '23 05:04 leonfancy

修改完环境变量重新部署 vercel 了没?

Yidadaa avatar Apr 03 '23 05:04 Yidadaa

重新部署试过,删了项目重新部署也试过。都不行

leonfancy avatar Apr 03 '23 05:04 leonfancy

  1. 提供一下环境变量页的截图
  2. 确认 api key 可用?

Yidadaa avatar Apr 03 '23 05:04 Yidadaa

确认可用哦,因为我在前端填 API KEY 就可以用

image

leonfancy avatar Apr 03 '23 05:04 leonfancy

我试过 fork 部署,以及直接点你这个项目deploy 按钮部署都不行

leonfancy avatar Apr 03 '23 05:04 leonfancy

是否在设置页填写了你自己设置的 CODE? 请提供设置页截图。

Yidadaa avatar Apr 03 '23 05:04 Yidadaa

image

leonfancy avatar Apr 03 '23 05:04 leonfancy

把你的 CODE 填到 Access Code 上去。

Yidadaa avatar Apr 03 '23 05:04 Yidadaa

啊?Code 原来是这个意思?若然可以了。 我以为设置了 CODE的话,前端会弹出一个什么输入密码的框框。

leonfancy avatar Apr 03 '23 05:04 leonfancy

这个code值是什么?在哪里获取

sswws avatar May 21 '23 07:05 sswws

我设置了CODE,在前台也重新输入CODE,但依然不行,必须在前台输入API KEY才可以。唉,不知道为什么vercel已经设置了环境变量,前台还要输入一次KEY,好麻烦。

liuzhoucheng avatar Aug 11 '23 13:08 liuzhoucheng

Bot detected the issue body's language is not English, translate it automatically.


I set the CODE and re-enter the CODE in the front desk, but it still doesn't work. You must enter the API KEY in the front desk. Alas, I don’t know why vercel has already set the environment variable, and the front desk needs to enter the KEY again, which is very troublesome.

Issues-translate-bot avatar Aug 11 '23 13:08 Issues-translate-bot

{ "error": { "message": "Incorrect API key provided: Incorrec**************ided. You can find your API key at https://platform.openai.com/account/api-keys.", "type": "invalid_request_error", "param": null, "code": "invalid_api_key" } } 这个报错是为啥啊

2001016 avatar May 31 '24 07:05 2001016

我的api可以在其他地方使用但是这里使用就显示这个问题

2001016 avatar May 31 '24 07:05 2001016

Bot detected the issue body's language is not English, translate it automatically.


My api can be used elsewhere but when used here it shows this problem

Issues-translate-bot avatar May 31 '24 07:05 Issues-translate-bot

不知道为啥api在这里用不了

2001016 avatar May 31 '24 07:05 2001016

Bot detected the issue body's language is not English, translate it automatically.


I don’t know why the API can’t be used here

Issues-translate-bot avatar May 31 '24 07:05 Issues-translate-bot