3

I am having a problem with this code

import openai

openai.api_key = "api_key"

completion = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=[{"role": "user", "content": "Give me 3 ideas for apps I could build with openai apis "}])
print(completion.choices[0].message.content)

whenever i run it, it gives me a openai.error.AuthenticationError:

i tried many solutions like regenerating the api key and going through their docs many times but to no solution i come here.

2e0byo
  • 5,305
  • 1
  • 6
  • 26
ShadowDevi
  • 31
  • 1
  • 2
  • Which error is it? – 2e0byo May 22 '23 at 19:20
  • 1
    openai.error.AuthenticationError: – ShadowDevi May 22 '23 at 19:26
  • Ah I see. your title is ambiguous. – 2e0byo May 22 '23 at 20:13
  • Does the example code in the docs (with listing models) work? If not, and you have a valid api token, the only answers are 'post an issue on github' or (preferably) 'set a breakpoint and start reading the source'. If you're (at all) familiar with oauth2 flows you should be able to figure out what's going on. If you have no idea what that is, open an issue or whatever the normal support channel is: this isn't a *programming* error so much as something broken in your env. – 2e0byo May 22 '23 at 20:16
  • There is some issue going on atm, I have the same. – grumpyp May 25 '23 at 11:11
  • Alright, did they announce anything about fixing it? – ShadowDevi May 28 '23 at 01:47

2 Answers2

1

I come to the same error like this every time I create a new API key it gets deleted. I have solved this in organizations settings by changing the organizations name.

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 31 '23 at 06:48
0

What helped me was that you need to make sure you are using the right values for these two fields:

openai.organization = ""
openai.api_key = ""

Make sure that you are using the correct secret key value and Organization ID that you get from OpenAI.

yli12313
  • 21
  • 2