chatanywhere / GPT_API_free

Free ChatGPT API Key,免费ChatGPT API,支持GPT4 API(免费),ChatGPT国内可用免费转发API,直连无需代理。可以搭配ChatBox等软件/插件使用,极大降低接口使用成本。国内即可无限制畅快聊天。
MIT License
24.53k stars 1.86k forks source link

密钥失效 #51

Closed gogogo314 closed 1 year ago

gogogo314 commented 1 year ago

你好,我今天刚刚用这个项目申请了免费key,但是key目前已经失效了 程序报错:Incorrect API key provided: sk-EWUgz***HVxj

gogogo314 commented 1 year ago

import os os.environ['OPENAI_API_KEY'] = 'sk-***Vb7' from langchain.llms import OpenAI llm = OpenAI(model_name="text-davinci-003", max_tokens=1024) llm("怎么评价人工智能")

这是我的代码

chatanywhere commented 1 year ago

你没有修改base url吧

MrRace commented 1 year ago

改了base url一样报错:

import os
from langchain.llms import OpenAI
os.environ['OPENAI_API_KEY'] ="sk-XXXX"
# os.environ['HTTP_PROXY'] = "http://api.chatanywhere.com.cn"
# os.environ['HTTPS_PROXY'] = "http://api.chatanywhere.com.cn"
os.environ['OPENAI_API_BASE'] = 'https://api.chatanywhere.com.cn/v1'
llm = OpenAI(model_name="text-davinci-003", max_tokens=1024)
llm("怎么评价人工智能")
gogogo314 commented 1 year ago

@chatanywhere 还是不行 https://api.chatanywhere.com.cn/v1和https://api.chatanywhere.cn/v1,我都试了 我用的 我用的是 @MrRace 的代码

报错: `Retrying langchain.llms.openai.completion_with_retry.._completion_with_retry in 4.0 seconds as it raised APIError: HTTP code 401 from API (limit to use gpt-3.5-turbo and embeddings ). Retrying langchain.llms.openai.completion_with_retry.._completion_with_retry in 4.0 seconds as it raised APIError: HTTP code 401 from API (limit to use gpt-3.5-turbo and embeddings ). Retrying langchain.llms.openai.completion_with_retry.._completion_with_retry in 4.0 seconds as it raised APIError: HTTP code 401 from API (limit to use gpt-3.5-turbo and embeddings ). Retrying langchain.llms.openai.completion_with_retry.._completion_with_retry in 8.0 seconds as it raised APIError: HTTP code 401 from API (limit to use gpt-3.5-turbo and embeddings ). Retrying langchain.llms.openai.completion_with_retry.._completion_with_retry in 10.0 seconds as it raised APIError: HTTP code 401 from API (limit to use gpt-3.5-turbo and embeddings ). Traceback (most recent call last): File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\openai\api_requestor.py", line 753, in _interpret_response_line data = json.loads(rbody) File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\json__init__.py", line 346, in loads return _default_decoder.decode(s) File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\json\decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\json\decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "C:\Users\陈旭坤\Desktop\kor\use_example.py", line 9, in llm("怎么评价人工智能") File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\langchain\llms\base.py", line 363, in call self.generate([prompt], stop=stop, callbacks=callbacks, kwargs) File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\langchain\llms\base.py", line 225, in generate output = self._generate_helper( File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\langchain\llms\base.py", line 176, in _generate_helper raise e File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\langchain\llms\base.py", line 163, in _generate_helper self._generate( File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\langchain\llms\openai.py", line 336, in _generate response = completion_with_retry(self, prompt=_prompts, params) File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\langchain\llms\openai.py", line 106, in completion_with_retry return _completion_with_retry(kwargs) File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\tenacity__init.py", line 289, in wrapped_f return self(f, *args, **kw) File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\tenacity__init.py", line 379, in call do = self.iter(retry_state=retry_state) File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\tenacity__init__.py", line 325, in iter raise retry_exc.reraise() File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\tenacity\init__.py", line 158, in reraise raise self.last_attempt.result() File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\concurrent\futures_base.py", line 439, in result return self.get_result() File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\concurrent\futures_base.py", line 391, in get_result raise self._exception File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\tenacity\init.py", line 382, in call__ result = fn(*args, kwargs) File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\langchain\llms\openai.py", line 104, in _completion_with_retry return llm.client.create(*kwargs) File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\openai\api_resources\completion.py", line 25, in create return super().create(args, **kwargs) File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\openai\api_resources\abstract\engine_apiresource.py", line 153, in create response, , api_key = requestor.request( File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\openai\api_requestor.py", line 298, in request resp, got_stream = self._interpret_response(result, stream) File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\openai\api_requestor.py", line 700, in _interpret_response self._interpret_response_line( File "D:\C ( Software Install 2 )\Anaconda3\envs\py39_for_langchain\lib\site-packages\openai\api_requestor.py", line 755, in _interpret_response_line raise error.APIError( openai.error.APIError: HTTP code 401 from API (limit to use gpt-3.5-turbo and embeddings )`

chatanywhere commented 1 year ago

@gogogo314 你使用的免费key 免费key只能用embedding和gpt3