In the following tutorial the process for setting up the API key for use in image generation is shown in detail again. For me it worked to just follow the steps mentioned there. Maybe this will help you two as well? If you are using this in a different use case you could build this in PowerApps and then view the raw code to compare it to yours.
Solution :
if you followed/cloned the quick start demo from the below link, you will face this issue ,
issue: the code cannot find the environment file
root cause : the environment file name is “.env.example”. while the environment file is defaulted in any code to be “.env” only
solution rename the environment file to be “.env”. this will enable the code to read the data inside the env file , otherwise the code search for the parameter in a file that it cannot find, which produces error that there is not key found.
Then check the process using:
fine_tune_events=openai.FineTune.list_events(id=fine_tune_response.id)
fine_tune_events
Get the model id using:
retrieve_response=openai.FineTune.retrieve(fine_tune_response.id)
fine_tuned_model=retrieve_response.fine_tuned_model
fine_tuned_model
I could not get the export command to work and setting the api ley in an environmental variable had no effect either but this worked for me too, so thank you!