I’m running a small test for the OpenAI API, but I keep encountering this error:
Error
In the Dashboard there is nothing displayed:
Dashboard1
Dashboard2
Here’s the code snippet I’m using:
<code>const handleChatGPT = async () => {
try {
const response = await openai.chat.completions.create({
model: "gpt-3.5-turbo",
messages: [
{ role: "system", content: "You are a poetic assistant, skilled in explaining complex programming concepts with creative flair." },
{ role: "user", content: "Compose a poem that explains the concept of recursion in programming." },
],
});
console.log("successful");
} catch (error) {
console.log(error.message);
}
};
</code>
<code>const handleChatGPT = async () => {
try {
const response = await openai.chat.completions.create({
model: "gpt-3.5-turbo",
messages: [
{ role: "system", content: "You are a poetic assistant, skilled in explaining complex programming concepts with creative flair." },
{ role: "user", content: "Compose a poem that explains the concept of recursion in programming." },
],
});
console.log("successful");
} catch (error) {
console.log(error.message);
}
};
</code>
const handleChatGPT = async () => {
try {
const response = await openai.chat.completions.create({
model: "gpt-3.5-turbo",
messages: [
{ role: "system", content: "You are a poetic assistant, skilled in explaining complex programming concepts with creative flair." },
{ role: "user", content: "Compose a poem that explains the concept of recursion in programming." },
],
});
console.log("successful");
} catch (error) {
console.log(error.message);
}
};
I’ve tried different user API keys and project API keys but nothing worked, always the same 4 logs