#gpt-3.5-turbo returning 404 when using createCompletion

65 messages · Page 1 of 1 (latest)

mellow ravine
#

I was using the text-davinci-003 model for a Discord chat bot right before this and it worked just fine. Since I switched my model to gpt-3.5-turbo I've been getting the error "Request failed with status code 404". Am I missing something?

#
const result = await openai.createCompletion({
  model: 'gpt-3.5-turbo',
  prompt: `${conversationContext(client.user.tag)}
           ${conversationLog}
           ${client.user.tag}:
           `,
  max_tokens: 256,
  temperature: 0.7,
});
mellow ravine
#

I also noticed the openai package was updated to 3.2, updating it didn't help either

spark tree
#

Same issue here

#

openai.error.InvalidRequestError: Invalid URL (POST /v1/completions)

#

wait

spark tree
#

update your openai module

mellow ravine
spark tree
#

sorry i was thinking of the python module lol

mellow ravine
spark tree
#

I just finished switching my bot over to that

mellow ravine
#

awesome!

quasi river
#

API not for free trials ? 🥺

mellow ravine
quasi river
mellow ravine
#

oof

quiet kiln
#

could i have a template code?

winter rapids
#

I've had the same issue @mellow ravine then i updated my openai module and used the createchatcompletion but still doesn' work

#

it throws me 400 error

silent hinge
#

I can use the davinci 003 but when I put the gpt 3.5 instead, it’s not working

winter rapids
#

const response = await openai.createChatCompletion({
model: "gpt-3.5-turbo",
prompt: My prompt\n${lastThreeInteractions}\nEstudiante:${input}\nProfesor:,
temperature: 0.7,
max_tokens: 500,
top_p: 1,
frequency_penalty: 0,
presence_penalty: 0.6,
stop: [ 'mystop1: ', 'mystop2: ' ],
});

winter rapids
silent hinge
#

Ohh! Thanks! Haven’t notice that

quiet kiln
winter rapids
chilly forum
#

Didn't work for me either, then I read documentation and instead of prompt, it's using messages

There's even example, how to use it correctly

`const { Configuration, OpenAIApi } = require("openai");

const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);

const completion = await openai.createChatCompletion({
model: "gpt-3.5-turbo",
messages: [{role: "user", content: "Hello world"}],
});
console.log(completion.data.choices[0].message);
`

=> your prompt will go to Content

wide ridge
quiet kiln
#

@chilly forum i cant get it to work pleas help

chilly forum
quiet kiln
#

could you just send my the code my brain aint brainin

#

me*

#

XD

quiet kiln
#

npm i openai*

#

doesnt it automatically get updated

#

?

chilly forum
#

I simplified my code a bit, am hosting my bot on REPL, so i needed to check package.json aswell and change version there

quiet kiln
#

could you send it in text if u dont mind? and also thanks

chilly forum
#

`client.on("messageCreate", async msg => {
const completion = await openai.createChatCompletion({
model: "gpt-3.5-turbo",
temperature: 0.6,
messages: [{role:"user", content: "You are friendly user bot named Bob.\n
${msg.author.username}: ${msg.content}\n
Bob:"}],
stop: ["Bob:", "${msg.author.username}:"]
});

msg.reply(completion.data.choices[0].message);

});`

#

async is important,without it code will throw error

SyntaxError: await is only valid in async functions and the top level bodies of modules

quiet kiln
#

i know i have alr checked it but like.... it keeps tellin me that await cannot be called without async(which alos throws me another error)

mellow ravine
chilly forum
#

What does async throw u?

quiet kiln
#

hol up i lost my code brrb in 20 sec

#

XD

#

is this code alr?:const { Configuration, OpenAIApi } = require("openai");

const start = async () => {
try {

const configuration = new Configuration({
apiKey: "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",
});
const openai = new OpenAIApi(configuration);

const completion = await openai.createChatCompletion({
model: "gpt-3.5-turbo",
messages: [{role: "user", content: "Hello world"}],
});
console.log(completion.data.choices[0].message);

} catch (error) {
console.log(error)
}
}

start()

chilly forum
#

pls remove your code - u got api key there

quiet kiln
#

its fine

#

i changed it

#

its my past 1

#

had it in a davinci 3 project

chilly forum
#

i see,gimme sec,ill throw it to repo and test it with my api key

quiet kiln
#

yeah yeah,thx

chilly forum
#

This works for me tho

#

Package.json

quiet kiln
#

could i get it in text plz

chilly forum
#

{ "name": "nodejs", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC", "dependencies": { "@types/node": "^18.0.6", "node-fetch": "^3.2.6", "openai": "^3.2.0" } }

And code is same as yours,only i used my API key there

quiet kiln
#

can u join my rpl?

#

ill dm u if thats alr

chilly forum
#

Sure