#gpt-3.5-turbo returning 404 when using createCompletion
65 messages · Page 1 of 1 (latest)
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,
});
I have similar issues.
I also noticed the openai package was updated to 3.2, updating it didn't help either
same
Same issue here
openai.error.InvalidRequestError: Invalid URL (POST /v1/completions)
wait
Use openai.ChatCompletion.create
update your openai module
oh you mean createChatCompletion?
yes
sorry i was thinking of the python module lol
for the rest here's what you should use
I just finished switching my bot over to that
awesome!
API not for free trials ? 🥺
it does work. i have $18 worth of free credits i'm using for chat completion
they put mine under time limit and i dont even used it all
oof
could i have a template code?
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
I can use the davinci 003 but when I put the gpt 3.5 instead, it’s not working
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: ' ],
});
you have to update the openai module and then use the new method createChatCompletion instead of createCompletion
Ohh! Thanks! Haven’t notice that
i cant get it working it keeps saying i cant use await
An API for accessing new AI models developed by OpenAI
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
I got it working thanks to your help!! 
but also: I really thought the ChatGPT api model would remember previous interactions as a sessionID or something ...
💔
An API for accessing new AI models developed by OpenAI
@chilly forum i cant get it to work pleas help
Did you update your openai package to 3.2.0? Am not expert on JS, but await should work if u use it in async function
also when i do npm i open ai
npm i openai*
doesnt it automatically get updated
?
I simplified my code a bit, am hosting my bot on REPL, so i needed to check package.json aswell and change version there
could you send it in text if u dont mind? and also thanks
`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
if it still doesn't work check https://platform.openai.com/docs/api-reference/chat/create?lang=node.js where's example request - there's selectbox for curl,python,node.js on right side
An API for accessing new AI models developed by OpenAI
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)
you have to make your function async then
What does async throw u?
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()
pls remove your code - u got api key there
i see,gimme sec,ill throw it to repo and test it with my api key
yeah yeah,thx
could i get it in text plz
{ "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
Sure