I’m having trouble debugging this error. I’m able successfully make a request to openai.createCompletion(), but openai.createImage() gives me the TypeError mentioned in the title of this post.
const imageResponse = await fetch("/api/imagegen", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ title: title }),
});
/imagegen.js
import { Configuration, OpenAIApi } from "openai";
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
export default async function (req, res) {
console.log(openai);
const image = await openai.createImage({
prompt: generatePrompt(req.body.title),
n: 1,
size: "1024x1024",
});
res.status(200).json({ result: image.data.choices[0].text });
}
function generatePrompt(title) {
return `${title} in the style of high-quality food photography`;
}