I’m trying to run the same code in my colab, I’ve generated my secret key also. But when I run the same I get this error.
“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.”
I’ve even tried changing openai.api_key = os.getenv(‘api-key’) to OPENAI_API_KEY= then I get syntax error.
I have the same issue, too. When I run the block of code in Jupyter notebook by Anaconda-Navigator on MacBook, it showed “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.”
However, one of my API key has been request succefully in October, another one is generated recently and never used.
Then add this snnippet of code:
export OPENAI_API_KEY=‘sk-myactualapikey’
In Jupyter Notebook, it’s hard to render your API key as how you do it in Google Security Manager.
Hey guys, I seem to solve my own problem. If this helps, I am more than happy to share here:
So the setting up of the key seems to not be the environment variable in colab. Therefore, I just simply modify the original openai.api_key as follows: