Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openai.error.AuthenticationError: Incorrect API key provided #4084

Closed
1 task done
skabaw opened this issue May 10, 2023 · 8 comments
Closed
1 task done

openai.error.AuthenticationError: Incorrect API key provided #4084

skabaw opened this issue May 10, 2023 · 8 comments
Labels
API access Trouble with connecting to the API setup Issues with getting Auto-GPT setup on local machines

Comments

@skabaw
Copy link

skabaw commented May 10, 2023

⚠️ Search for existing issues first ⚠️

  • I have searched the existing issues, and there is no existing issue for my problem

Which Operating System are you using?

Linux

Which version of Auto-GPT are you using?

Latest Release

GPT-3 or GPT-4?

GPT-4

Steps to reproduce 🕹

First installation of recent AutoGPT from GitHub repository, ubuntu, Python 3.10.6

Current behavior 😯

stuck on wrong key (see log)

Expected behavior 🤔

2, 3....

Your prompt 📝

List all prime numbers less than 100

Your Logs 📒

Using Browser: chrome
Traceback (most recent call last):
File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/home/skaba/autogpt/Auto-GPT/autogpt/main.py", line 5, in
autogpt.cli.main()
File "/home/skaba/autogpt/env/lib/python3.10/site-packages/click/core.py", line 1130, in call
return self.main(*args, **kwargs)
File "/home/skaba/autogpt/env/lib/python3.10/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/home/skaba/autogpt/env/lib/python3.10/site-packages/click/core.py", line 1635, in invoke
rv = super().invoke(ctx)
File "/home/skaba/autogpt/env/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/skaba/autogpt/env/lib/python3.10/site-packages/click/core.py", line 760, in invoke
return __callback(*args, *kwargs)
File "/home/skaba/autogpt/env/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
return f(get_current_context(), args, kwargs)
File "/home/skaba/autogpt/Auto-GPT/autogpt/cli.py", line 90, in main
run_auto_gpt(
File "/home/skaba/autogpt/Auto-GPT/autogpt/main.py", line 186, in run_auto_gpt
agent.start_interaction_loop()
File "/home/skaba/autogpt/Auto-GPT/autogpt/agent/agent.py", line 113, in start_interaction_loop
assistant_reply = chat_with_ai(
File "/home/skaba/autogpt/Auto-GPT/autogpt/llm/chat.py", line 244, in chat_with_ai
assistant_reply = create_chat_completion(
File "/home/skaba/autogpt/Auto-GPT/autogpt/llm/llm_utils.py", line 166, in create_chat_completion
response = api_manager.create_chat_completion(
File "/home/skaba/autogpt/Auto-GPT/autogpt/llm/api_manager.py", line 55, in create_chat_completion
response = openai.ChatCompletion.create(
File "/home/skaba/autogpt/env/lib/python3.10/site-packages/openai/api_resources/chat_completion.py", line 25, in create
return super().create(args, kwargs)
File "/home/skaba/autogpt/env/lib/python3.10/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 153, in create
response, _, api_key = requestor.request(
File "/home/skaba/autogpt/env/lib/python3.10/site-packages/openai/api_requestor.py", line 226, in request
resp, got_stream = self._interpret_response(result, stream)
File "/home/skaba/autogpt/env/lib/python3.10/site-packages/openai/api_requestor.py", line 619, in _interpret_response
self._interpret_response_line(
File "/home/skaba/autogpt/env/lib/python3.10/site-packages/openai/api_requestor.py", line 682, in _interpret_response_line
raise self.handle_error_response(
openai.error.AuthenticationError: Incorrect API key provided: your-ope
-key. You can find your API key at https://platform.openai.com/account/api-keys.

@k-boikov k-boikov added setup Issues with getting Auto-GPT setup on local machines API access Trouble with connecting to the API labels May 10, 2023
@k-boikov
Copy link
Contributor

Check you .env, the key needs to be right after the "=".

@joshduplaa
Copy link

joshduplaa commented May 10, 2023

If you're not on the pay as you go pricing plan for the API key on you OpenAI account you will keep getting this error. Leaving the free credit tier is how I fixed this.

Edit: let me know if this fixed your problem as well.

@anonhostpi
Copy link

anonhostpi commented May 10, 2023

To clarify what @joshduplaa said, there is a difference between platform.openai.com and chat.openai.com, including billing.

Both tools manage billing separately. Make sure that you are on platform.openai.com's paid plan.

@skabaw
Copy link
Author

skabaw commented May 11, 2023 via email

@skabaw
Copy link
Author

skabaw commented May 11, 2023 via email

@skabaw
Copy link
Author

skabaw commented May 11, 2023

I have eventually resolved the problem. The .env file I use is an edited copy of .env.template. In the original template, however, the OPENAI_API_KEY is listed twice, once commented and once uncommented. I edited the first appearance and removed the ### but didn't notice the second appearance. Apparently, after reading the correct api key, the system also reads the second one - incorrect, namely, non-existing - and reports wrong api key.

@skabaw skabaw closed this as completed May 11, 2023
@anonhostpi
Copy link

Interesting find

@anonhostpi
Copy link

Noted that in my tracker: Gist | Alt. Thanks for that @skabaw!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API access Trouble with connecting to the API setup Issues with getting Auto-GPT setup on local machines
Projects
None yet
Development

No branches or pull requests

4 participants