when running the 1’st “response = get_completion(prompt)” I am getting :
I am doing the course so i have used -
openai.api_key = “sk-” since instructor says so.
AuthenticationError Traceback (most recent call last)
in
16 {text}
17 “”"
—> 18 response = get_completion(prompt)
19 print(response)
in get_completion(prompt, model)
1 def get_completion(prompt, model=“gpt-3.5-turbo”):
2 messages = [{“role”: “user”, “content”: prompt}]
----> 3 response = openai.ChatCompletion.create(
4 model=model,
5 messages=messages,
~\Anaconda3\lib\site-packages\openai\api_resources\chat_completion.py in create(cls, *args, **kwargs)
23 while True:
24 try:
—> 25 return super().create(*args, **kwargs)
26 except TryAgain as e:
27 if timeout is not None and time.time() > start + timeout:
In the notebook of the course you don’t have to change anything on the first cell - just run it. You don’t have to add your api key nor update anything in this cell.
1 Like
I am just running the code copied from Guidelines for Prompting > Setup in JupyterLab and get the AuthenticationError as well. I have not typed any new code. Here is the end of the Traceback:
AuthenticationError: No API key provided. You can set your API key in code using ‘openai.api_key = ’, or you can set the environment variable OPENAI_API_KEY=). If your API key is stored in a file, you can point the openai module at it with ‘openai.api_key_path = ’. You can generate API keys in the OpenAI web interface. See OpenAI Platform for details.
Please advise 
Asked and answered many times. Try the forum search. Note that your use case “I am just running the code copied from Guidelines for Prompting > Setup in JupyterLab” is not the same as running the notebook directly in the online environment provided by the course. If you’re running locally, you must obtain and utilize your own key.
Thank you for the tip and helping me understand my use case! I appreciate your time 