Issue with OpenAI API key while using it in Windows

Viewed 144

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.

1 Answers

This is a common issue with an earlier version of the openai's CLI. If you haven't already, make sure you upgrade to the most recent version by doing

pip install --upgrade openai

One possible workaround is to just use a python script to do what you would normally do in the CLI.

# To train a model:
import os
import openai
os.environ=["OPENAI_API_KEY"] = "sk-iQJX*****************************************mux"
os.system("openai api fine_tunes.create -t train_data.jsonl -m curie")
Related