NextChat
NextChat copied to clipboard
[Bug] 使用自定义接口后,不能使用环境变量里面设置的API_Key
现象
1.在环境变量中设置了CODE及API_Key。部署后,打开页面,在“设置”页面设置访问密码,勾选“自定义接口”并设置访问地址; 2.如果此时同时设置API_Key,可以顺利访问; 3.如果此时不设置API_Key,会提示:"Incorrect API key provided: nk-01234***@ab. ......"。其中给出的带掩码的Key,其实是访问密码。
疑问
使用“自定义接口“的情况下,环境变量的API_Key无效吗?
Bot detected the issue body's language is not English, translate it automatically.
Title: [Bug] After using a custom interface, the API_Key set in the environment variable cannot be used
Phenomenon
- Set CODE and API_Key in the environment variables. After deployment, open the page, set the access password on the "Settings" page, check "Custom Interface" and set the access address;
- If you set API_Key at the same time, you can access it smoothly;
- If API_Key is not set at this time, it will prompt: "Incorrect API key provided: nk-01234***@ab. ...". The masked Key given is actually the access password.
Question
When using "custom interface", is the API_Key of the environment variable invalid?
能否调整成,只要API_Key为空,就尝试使用环境变量里面的API_Key。毕竟,把自己部署的东西分享给别人的时候,并不希望泄露自己的API_Key。
Bot detected the issue body's language is not English, translate it automatically.
Can it be adjusted so that as long as API_Key is empty, try to use the API_Key in the environment variable? After all, when you share your deployed things with others, you don't want to reveal your API_Key.
能否调整成,只要API_Key为空,就尝试使用环境变量里面的API_Key。毕竟,把自己部署的东西分享给别人的时候,并不希望泄露自己的API_Key。
同求, 能不能在环境变量中 也加入 自定义 接口地址
Bot detected the issue body's language is not English, translate it automatically.
Can it be adjusted so that as long as API_Key is empty, try to use the API_Key in the environment variable? After all, when you share your deployed things with others, you don't want to reveal your API_Key.
Also asking, can you add a custom interface address to the environment variables?
你们也是有点6的,BASE_URL看不见? 编辑: 点踩的你们是来搞笑的?哑巴?
Bot detected the issue body's language is not English, translate it automatically.
能否调整成,只要API_Key为空,就尝试使用环境变量里面的API_Key。毕竟,把自己部署的东西分享给别人的时候,并不希望泄露自己的API_Key。
同求, 能不能在环境变量中 也加入 自定义 接口地址
是的,这也是一个很好的方法。既可以分享给身边不方便自己搞的人,又不会造成不必要的泄露。
Bot detected the issue body's language is not English, translate it automatically.
Can it be adjusted so that as long as the API_Key is empty, try to use the API_Key in the environment variable. After all, when you share your deployed things with others, you don't want to reveal your API_Key.
I would like to ask, can you also add a custom interface address to the environment variables?
Yes, this is a good approach too. It can be shared with people around you who are inconvenient to do it yourself without causing unnecessary leakage.
自定义接口一直都有环境变量。 https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/blob/0cf66141860413f378b883660fdeaec2e909d90c/README_CN.md?plain=1#L81-L87 如果你在设置里选择了自定义接口选项,会使用下面给出的自定义API_key。如果你一想在服务器端使用自定义地址,为何不在环境变量里直接设置BASE_URL和OPENAI_API_KEY。
Bot detected the issue body's language is not English, translate it automatically.
Custom interfaces always have environment variables. https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/blob/0cf66141860413f378b883660fdeaec2e909d90c/README_CN.md?plain=1#L81-L87 If you select the custom interface option in the settings, the custom API_key given below will be used. If you want to use a custom address on the server side, why not set BASE_URL and OPENAI_API_KEY directly in the environment variables.
Bot detected the issue body's language is not English, translate it automatically.
Custom interfaces always have environment variables.
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/blob/0cf66141860413f378b883660fdeaec2e909d90c/README_CN.md?plain=1#L81-L87
If you select the custom interface option in the settings, the custom API_key given below will be used. If you want to use a custom address on the server side, why not set BASE_URL and OPENAI_API_KEY directly in the environment variables.
Don't you understand what he means? As long as BASEURL is set, OPENAI_API_KEY in the environment variable will become invalid. Users must manually fill in APIKEY when logging in to use it.
你们也是有点6的,BASE_URL看不见? 编辑: 点踩的你们是来搞笑的?哑巴?
自定义接口一直都有环境变量。
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/blob/0cf66141860413f378b883660fdeaec2e909d90c/README_CN.md?plain=1#L81-L87
如果你在设置里选择了自定义接口选项,会使用下面给出的自定义API_key。如果你一想在服务器端使用自定义地址,为何不在环境变量里直接设置BASE_URL和OPENAI_API_KEY。
我尝试将在web设置中配置好后可以正常使用的自定义接口地址移入环境变量的BASE_URL使用,但报错: {"error":{"message":"We could not parse the JSON body of your request. (HINT: This likely means you aren't using your HTTP library correctly. The OpenAI API expects a JSON payload, but what was sent was not valid JSON. If you have trouble figuring out how to fix this, please contact us through our help center at help.openai.com.)","type":"invalid_request_error","param":null,"code":null}}
你们也是有点6的,BASE_URL看不见? 编辑: 点踩的你们是来搞笑的?哑巴?
自定义接口一直都有环境变量。
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/blob/0cf66141860413f378b883660fdeaec2e909d90c/README_CN.md?plain=1#L81-L87
如果你在设置里选择了自定义接口选项,会使用下面给出的自定义API_key。如果你一想在服务器端使用自定义地址,为何不在环境变量里直接设置BASE_URL和OPENAI_API_KEY。
我尝试将在web设置中配置好后可以正常使用的自定义接口地址移入环境变量的BASE_URL使用,但报错: {"error":{"message":"We could not parse the JSON body of your request. (HINT: This likely means you aren't using your HTTP library correctly. The OpenAI API expects a JSON payload, but what was sent was not valid JSON. If you have trouble figuring out how to fix this, please contact us through our help center at help.openai.com.)","type":"invalid_request_error","param":null,"code":null}}
一般base_url是不带v1等请求路径的,请确保baseurl和apikey都格式正确,比如说无空格之类的。别的情况请f12截取completions请求或者相关日志。
你们也是有点6的,BASE_URL看不见? 编辑: 点踩的你们是来搞笑的?哑巴?
自定义接口一直都有环境变量。 https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/blob/0cf66141860413f378b883660fdeaec2e909d90c/README_CN.md?plain=1#L81-L87
如果你在设置里选择了自定义接口选项,会使用下面给出的自定义API_key。如果你一想在服务器端使用自定义地址,为何不在环境变量里直接设置BASE_URL和OPENAI_API_KEY。
我尝试将在web设置中配置好后可以正常使用的自定义接口地址移入环境变量的BASE_URL使用,但报错: {"error":{"message":"We could not parse the JSON body of your request. (HINT: This likely means you aren't using your HTTP library correctly. The OpenAI API expects a JSON payload, but what was sent was not valid JSON. If you have trouble figuring out how to fix this, please contact us through our help center at help.openai.com.)","type":"invalid_request_error","param":null,"code":null}}
一般base_url是不带v1等请求路径的,请确保baseurl和apikey都格式正确,比如说无空格之类的。别的情况请f12截取completions请求或者相关日志。
我尝试在 base_url 末尾加上了 /v1/chat/completions 请求路径,报错:{"error":{"message":"Invalid URL (POST /v1/chat/completions/v1/chat/completions)","type":"invalid_request_error","param":null,"code":null}},看样子 base_url 已经自带了 v1 请求路径 p.s. 自定义接口使用的是 search2ai
completions 请求截取(域名使用domain替代):
curl 'https://domain/api/openai/v1/chat/completions' \
-H 'accept: application/json, text/event-stream' \
-H 'accept-language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6' \
-H 'content-type: application/json' \
-H 'dnt: 1' \
-H 'origin: https://domain' \
-H 'priority: u=1, i' \
-H 'referer: https://domain/' \
-H 'sec-ch-ua: "Not)A;Brand";v="99", "Microsoft Edge";v="127", "Chromium";v="127"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "Windows"' \
-H 'sec-fetch-dest: empty' \
-H 'sec-fetch-mode: cors' \
-H 'sec-fetch-site: same-origin' \
-H 'sec-gpc: 1' \
-H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.0.0' \
--data-raw '{"messages":[{"role":"system","content":"\nYou are ChatGPT, a large language model trained by OpenAI.\nKnowledge cutoff: 2021-09\nCurrent model: gpt-3.5-turbo\nCurrent time: Mon Aug 12 2024 11:03:17 GMT+1000 (澳大利亚东部标准时间)\nLatex inline: \\(x^2\\) \nLatex block: $$e=mc^2$$\n\n"},{"role":"user","content":"今天全天ipswich的天气如何"},{"role":"assistant","content":"{\"error\":{\"message\":\"Invalid URL (POST /v1/chat/completions/v1/chat/completions)\",\"type\":\"invalid_request_error\",\"param\":null,\"code\":null}}"},{"role":"user","content":"今天全天ipswich的天气如何"}],"stream":true,"model":"gpt-3.5-turbo","temperature":0.5,"presence_penalty":0,"frequency_penalty":0,"top_p":1}'