Denis Prosvietov
Denis Prosvietov

Reputation: 5

OpenAI API error when fine-tuning: "This is not a chat model and thus not supported in the v1/chat/completions endpoint"

I've fine-tuned a model using the OpenAI API. Now I want to use this fine-tuned model.

This is my code:

 const response = await openai.chat.completions.create({
    model: process.env.FINE_TUNE_MODEL,
    messages: [
      {
        role: "system",
        content: prompt,
      },
      {
        role: "user",
        content: inputText,
      },
    ],
    temperature: 0,
    top_p: 1,
    frequency_penalty: 0,
    presence_penalty: 0,
});

But there's a 404 error while executing this function.

This is the error message:

NotFoundError: 404 This is not a chat model and thus not supported in the v1/chat/completions endpoint. Did you mean to use v1/completions?

How can I use the fine-tuned model to generate a text?

Upvotes: 0

Views: 153

Answers (1)

Rok Benko
Rok Benko

Reputation: 22930

Problem

You fine-tuned one of the non-chat models but wanted to use the API endpoint, which is compatible only with the chat models.

The API endpoint you need to use for a fine-tuned model depends on the model you fine-tune.

As of today, you can fine-tune the following models:

  • gpt-4o-mini-2024-07-18 (chat model),
  • gpt-4o-2024-05-13 (chat model),
  • gpt-4-0613 (chat model),
  • gpt-3.5-turbo-0125 (chat model),
  • gpt-3.5-turbo-1106 (chat model),
  • gpt-3.5-turbo-0613 (chat model),
  • babbage-002 (non-chat model), and
  • davinci-002 (non-chat model).

Solution

Use the following rule:

  • If you fine-tune a chat model, use the /v1/chat/completions API endpoint.
  • If you fine-tune a non-chat model, use the /v1/completions API endpoint.

In other words:

  • If you fine-tune a chat model, use the client.chat.completions.create method.
  • If you fine-tune a non-chat model, use the client.completions.create method.

Upvotes: 0

Related Questions