# I am getting AuthenticationError

**URL:** <https://community.deeplearning.ai/t/i-am-getting-authenticationerror/338838>\
**Category:** ChatGPT Prompt Engineering for Developers\
**Created:** [May 19, 2023, 1:17pm UTC](https://community.deeplearning.ai/t/i-am-getting-authenticationerror/338838 "2023-05-19T13:17:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zvi\_Boiangou](https://avatars.discourse-cdn.com/v4/letter/z/e19adc/32.png) [@Zvi\_Boiangou](https://community.deeplearning.ai/u/Zvi_Boiangou)\
**Post date:** [May 19, 2023, 1:17pm UTC](https://community.deeplearning.ai/t/i-am-getting-authenticationerror/338838/1 "2023-05-19T13:17:04Z")

</div>

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:

---

<div class="post-metadata">

**Author:** ![Juan\_Olano](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/juan_olano/32/27125_2.png) [@Juan\_Olano](https://community.deeplearning.ai/u/Juan_Olano)\
**Post date:** [May 19, 2023, 7:29pm UTC](https://community.deeplearning.ai/t/i-am-getting-authenticationerror/338838/2 "2023-05-19T19:29:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![LadyHermitage](https://avatars.discourse-cdn.com/v4/letter/l/3da27b/32.png) [@LadyHermitage](https://community.deeplearning.ai/u/LadyHermitage)\
**Post date:** [June 27, 2023, 6:32pm UTC](https://community.deeplearning.ai/t/i-am-getting-authenticationerror/338838/3 "2023-06-27T18:32:02Z")

</div>

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](https://platform.openai.com/account/api-keys) for details.

Please advise 🙂

---

<div class="post-metadata">

**Author:** ![ai\_curious](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/ai_curious/32/128003_2.png) [@ai\_curious](https://community.deeplearning.ai/u/ai_curious)\
**Post date:** [June 27, 2023, 7:50pm UTC](https://community.deeplearning.ai/t/i-am-getting-authenticationerror/338838/4 "2023-06-27T19:50:02Z")

</div>

> [@LadyHermitage](#):
>
> AuthenticationError: No API key provided.

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.

---

<div class="post-metadata">

**Author:** ![LadyHermitage](https://avatars.discourse-cdn.com/v4/letter/l/3da27b/32.png) [@LadyHermitage](https://community.deeplearning.ai/u/LadyHermitage)\
**Post date:** [June 27, 2023, 9:15pm UTC](https://community.deeplearning.ai/t/i-am-getting-authenticationerror/338838/5 "2023-06-27T21:15:05Z")

</div>

Thank you for the tip and helping me understand my use case! I appreciate your time 🙂
