6

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.

4 Answers4

3

Use the following in the windows command prompt

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

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")
cigien
  • 57,834
  • 11
  • 73
  • 112
0

When assigning the API key in command line, dont use double quotes like:

API_KEY=ab-123123123123123231

This will solve the issue

0

Hi this code will solve the problem. Make sure you set your environment variable properly before =OPENAI_API_KEY in this case:

Get-ExecutionPolicy
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
$headers = @{
"Authorization" = "Bearer $env:OPENAI_API_KEY"
"model" = "text-davinci-002"
}
Invoke-WebRequest -Uri "https://api.openai.com/v1/models" -Headers  $headers
Get-ChildItem Env:OPENAI_API_KEY

Best, Alexis

Alexis
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 21 '23 at 16:30