Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

openai api 404 response

I’m trying to use chatgpt for my telegram bot, I used to use "text-davinci-003" model, it was working fine (even now it’s working fine) but I’m not satisfied with its responses. Now I’m trying to change the model to "gpt-3.5-turbo" and it’s throwing 404 response code with text "Error: Request failed with status code 404" and nothing else, here’s my code:

import { Configuration, OpenAIApi } from "openai";
import { env } from "../utils/env.js";

const model = "gpt-3.5-turbo"; // works fine when it's "text-davinci-003"
const configuration = new Configuration({
  apiKey: env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);

export async function getChatGptResponse(request) {
  try {
    const response = await openai.createCompletion({
      model,
      prompt: request, // request comes as a string
      max_tokens: 2000,
      temperature: 1,
      stream: false
    });

    console.log("Full response: ", response, `Choices: `, ...response.data.choices)
    return response.data.choices[0].text;
  } catch (err) {
    console.log(`ChatGPT error: ` + err);
    return err;
  }
}

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Did you try to use createChatCompletion rather than createCompletion:

const response = async (message) => {
  const response = await openai.createChatCompletion({
    model: "gpt-3.5-turbo",
    messages: [{role: "user", content: "Hello world"}],
  });

  return response.data.choices[0].message.content;
};
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading