[Python] GPT-3 fine tuning Error: Incorrect API key provided

Discussão em 'Python' iniciado por Stack, Maio 7, 2025.

  1. Stack

    Stack Membro Participativo

    I'm following this tutorial to fine-tune a GPT-3 model. However, when I run this part of the code:

    # Enter credentials
    %env OPENAI_API_KEY= "<MY OPENAI KEY>"
    !openai api fine_tunes.create \
    -t dw_train.jsonl \
    -v dw_valid.jsonl \
    -m $model \
    --n_epochs $n_epochs \
    --batch_size $batch_size \
    --learning_rate_multiplier $learning_rate_multiplier \
    --prompt_loss_weight $prompt_loss_weight


    I get this error:


    Error: Incorrect API key provided: "sk-czja*****************************************gk0". You can find your API key at https://beta.openai.com. (HTTP status code: 401)
    ​

    The curious thing is that the API key is correct. So much so that, if I use it to make a prompt, it works perfectly. Example:

    def GPT_Completion(texts):
    response = openai.Completion.create(
    engine="text-davinci-002",
    prompt = texts,
    temperature = 0.6,
    top_p = 1,
    max_tokens = 64,
    frequency_penalty = 0,
    presence_penalty = 0
    )
    return print(response.choices[0].text)

    GPT_Completion("My dear friend,")


    What could be causing this error? I thought maybe the GPT-3 training could require a paid account. However, I did not find this restriction on the OpenAI website.

    The whole code I'm using is here.

    Continue reading...

Compartilhe esta Página