Search code examples
windowscommand-lineopenai-api

Issue with OpenAI API key while using it in Windows


I have to fine-tune the OpenAI model on my custom dataset. I have created the dataset in jsonl format. I use the following commands on windows command line:

set OPENAI_API_KEY=<API key>

openai tools fine_tunes.prepare_data -f "train_data.jsonl"

The above commands run successfully and give me some suggestions for updating jsonl file. After this, I run the following command to fine-tune the 'curie' model.

openai api fine_tunes.create 'openai.api_key = <API key>' -t "train_data.jsonl" -m "curie"

But I am getting following issue:

←[91mError:←[0m Incorrect API key provided: "sk-iQJX*****************************************mux". You can find your API key at https://beta.openai.com. (HTTP status code: 401)

Can anybody help me out with this issue.


Solution

  • Use the following in the windows command prompt

    openai --api-key <OPENAI_API_KEY> api fine_tunes.create -t "[yourfilelocationhere]" -m [modelhere] --suffix "[optional]"