Chatgpt bot building .problem on connection to openai key

Hi there!

i want to use openai to build a chatbot. but i faced a problem right at the beginning. i generated an api key in openai website and i implemented the openai.api_key = ‘sk-…’ . but the first function in the guideline video is not working . it just print the exact sentences of the ‘prompt’.it seems it is not able to connect openai key . appreciate if anyone could help me on this issue.

1 Like

This thread might be helpful.

If not, you can find others by searching for “api key”.

Hi nedanm, welcome to the community! Just to check, are you trying this in the course’s Jupyter Notebook environment? For the course, you can leave the code unchanged, since it is using a default API key. You would only use your own ‘sk-…’ key when working outside of the course files. Hope that helps!

1 Like

Hi Henry,

Thank you so much for your help. I v tried that in google colab . I v downloaded my own key .bur whatever i do , it seems the code can connect with open ai.
Best regards
Neda

@nedanm if you want you can send me your notebook (PLEASE ERASE YOUR API KEY) and I can try it myself. If you decide to do this, please send me the notebook via direct message, not here.

Thank you!

1 Like

Hi Neda,

Yes Juan’s kind offer above might be quite helpful, that way we can try it out in the exact Google Colab environment you’re using. Additionally, feel free to let us know if it’s working in the course’s built-in Jupyter Notebook environment so that we can troubleshoot. Thanks!

Hi Nedanm,

 Please visit this site to generate api key.

 https://platform.openai.com/account/api-keys

 After generating api-key, copy the key and paste in the following code snippet. Key usually starts with sk-
import openai
openai.api_key = "paste your generated key."

thank you Vjay,
i will try that.

Best regards
Neda