OpenAI Error: No API key provided

Hi @fr.sxtyxm and @muskanrxl89

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.

Creating a PowerApps custom connector for Dall-e image generation using OpenAI and Postman - YouTube

You can refer to the following Video for Setup for text based models: ChatGPT Custom Connector for Power Platform | How to use Chat GPT API in Power Apps & Automate - YouTube

This works thanks Specifying the key elsewhere does not for some reason.

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.

Training the model the long way worked for me:
openai.api_key=“sk-…”

upload_response=openai.File.create(file=open(“…jsonl”, “rb”), purpose=‘fine-tune’)
file_id=upload_response.id
upload_response

fine_tune_response=openai.FineTune.create(training_file=file_id, model=“curie”)
fine_tune_response

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

Call for response using:
answer=openai.Completion.create(
model=fine_tuned_model,
prompt=new_prompt,
max_tokens=300,
temperature=0,
)
answer[“choices”][0][“text”]

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!