I'm trying to use OpenAI's API to generate recipes for a website, but I keep getting the error in the title
code:
const handleGenerateRecipe = async () => {
try {
const response = await axios.post("https://api.openai.com/v1/completions", {
prompt: `Generate a ${recipeType} recipe`,
max_tokens: 60,
n: 1,
stop: "\n",
}, {
headers: {
Authorization: `Bearer ${process.env.API_KEY}`,
"Content-Type": "application/json",
},
});
setRecipe(response.data.choices[0].text.trim());
} catch (error) {
console.error(error);
}
};
I got the API key from my account, but I can't figure out why the API key is not working.
Tried regenerating my keys