Error in loading openai.api_key

Hello,

I’m working on Pycharm and getting this error every time I try to load openai api key:

openai.error.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 API for details.

I tried to copy the key into a txt file, but the same problem.

Hope to get your help and thanks in advance!

Please use the forum Search tool for the topic “API”. You’ll find many replies on this topic.

Hi m_tu, welcome to the community! Yes, as mentioned above, there are a few other threads where users ran into similar issues, but generally speaking, the course notebook is designed to use the course’s built-in API key. If you are building your own application, you will need to use your own API key from OpenAI, in which case it should start something like ‘sk-’. Do note that one of those options you mentioned points to the key value itself, while the other points to the key file path. Hope that helps!

@Henry.L I just started this course, and I had the same question.

“the course notebook is designed to use the course’s built-in API key.”

Does this mean I can only run the notebook on deeplearningai’s website, for example:

But can’t execute it offline in my own pyCharm? Thanks

Also, does gpt-3.5-turbo model has a usage limit? I got this error message: “openai.error.RateLimitError: You exceeded your current quota, please check your plan and billing details.”

我也遇到了这个问题,你可以看看是不是一样的问题。
加载openai的api,需要openai.organization和openai.api_key,这两个并不是同一个数据,你看看是否将openai.organization填写成api_key了?
openai.organization在个人信息里,你可以找找看。如果没找到,直接询问chatGPT,如何找到openai.organization。

Hi Martin, yes the files should be utilizing a pre-existing python environment with a built-in API key, so you may run into some issues trying to run the notebooks as is in your own IDE like PyCharm. I would recommend trying out the notebooks in the web environment first to get a feel of things and then adapting snippets of code to put together your own offline script.

And yes, OpenAI imposes some usage limits based on your plan, which you can read more about here: [Rate Limits - OpenAI API]

Hope that helps answer your questions!