I’m trying to train using Google Colab. Despite establishing the API, I am struck with the following error: " Error: No API key provided. (HINT: set your API key in code using "openai.api_key = <API-KEY>", or you can set the environment variable OPENAI_API_KEY=<API-KEY>). You can generate API keys in the OpenAI web interface. See [https://onboard.openai.com](https://onboard.openai.com/) for details, or email [support@openai.com](mailto:support@openai.com) if you have any questions."
My code is as follows:
!pip install --upgrade openai
import openai
!export OPENAI_API_KEY="(actual API)"
!openai api fine_tunes.create -t "/content/Untitled spreadsheet (2)_prepared.jsonl" -m "ada"
1 Like
rachel
2
As far as I can tell, exporting a bash variable using !export VAR doesn’t work in colab (e.g. try
!export VAR="hello"
!echo $VAR
)
But you can set the env var with
os.environ["OPENAI_API_KEY"] = api_key
7 Likes
This saved me, thank you.
I am getting following error on Google cola
/bin/bash: os.environ[OPENAI_API_KEY]: command not found