openai.error.AuthenticationError: No API key provided

Getting this error when I run test file: openai.error.AuthenticationError: No API key provided

On Mac, modified bash file with this command: nano ~/.bash_profile
added this line:
export OPENAI_API_KEY=sk-RnRrKB1M<rest of my key>
after saving file, I type this at terminal prompt:
echo $OPENAI_API_KEY
but no key is returned.

What am I doing wrong?

Hi, try restarting your terminal. To restart your terminal, close and reopen it.
After doing this, you can check if the OPENAI_API_KEY variable is set correctly by running:

echo $OPENAI_API_KEY