Search code examples
pythonopenai-apichatgpt-api

OpenAI API error: "The model 'curie:ft-personal-2023-09-15-06-05-01' does not exist" when trying to delete a fine-tuned model


Created a model from a jsonl file with prompts. I enter the command:

openai -k sk-blablablablablabla api fine_tunes.list

It shows information about this model:

{
  "object": "list",
  "data": [
    {
      "object": "fine-tune",
      "id": "ft-yrlmcjagdwijfrnvkldsn",
      "hyperparams": {
        "n_epochs": 4,
        "batch_size": 1,
        "prompt_loss_weight": 0.01,
        "learning_rate_multiplier": 0.1
      },
      "organization_id": "org-kouf8eihlsamclsl",
      "model": "curie",
      "training_files": [
        {
          "object": "file",
          "id": "file-IyrkYUiefjwkq",
          "purpose": "fine-tune",
          "filename": "data_prepared.jsonl",
          "bytes": 417,
          "created_at": 1694757803,
          "status": "processed",
          "status_details": null
        }
      ],
      "validation_files": [],
      "result_files": [
        {
          "object": "file",
          "id": "file-jofepw8489hfidkdwfiw",
          "purpose": "fine-tune-results",
          "filename": "compiled_results.csv",
          "bytes": 742,
          "created_at": 1694757902,
          "status": "processed",
          "status_details": null
        }
      ],
      "created_at": 1694757804,
      "updated_at": 1694757903,
      "status": "succeeded",
      "fine_tuned_model": "curie:ft-personal-2023-09-15-06-05-01"
    }
  ],
  "next_starting_after": null
}

But I can't remove it. I'm trying different things:

openai -k sk-blablablablablabla api models.delete -i <FINE_TUNED_MODEL>
openai -k sk-blablablablablabla api models.delete -i curie:ft-personal-2023-09-15-06-05-01
openai -k sk-blablablablablabla api models.delete -i ft-wyysqbYRFKo2p0ezNXa6F5sc

Tried it through Python code too:

import os
import openai
from dotenv import load_dotenv, find_dotenv

load_dotenv(find_dotenv())

def init_api():
    openai.api_key = os.getenv("AI_API_KEY")

init_api()

openai.Model.delete("curie:ft-personal-2023-09-15-06-05-01")

I got the following error:

The model 'curie:ft-personal-2023-09-15-06-05-01' does not exist (HTTP status code: 404)

Solution

  • You said that you got the following error: The model 'curie:ft-personal-2023-09-15-06-05-01' does not exist.

    Meaning you have probably already successfully deleted your fine-tuned model. Consequently, it doesn't exist anymore when you try to delete it for the second, third, fourth, etc. time.

    Use the Models API to list all models. You shouldn't see curie:ft-personal-2023-09-15-06-05-01.

    Python:

    import os
    import openai
    
    openai.api_key = os.getenv("OPENAI_API_KEY")
    
    openai.Model.list()
    

    NodeJS:

    import OpenAI from "openai";
    
    const openai = new OpenAI();
    
    async function main() {
      const list = await openai.models.list();
    
      for await (const model of list) {
        console.log(model);
      }
    }
    main();