TypeError: openai.createImage is not a function

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 }),


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) {
    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`;

Solved: I had to upgrade openai to 3.1.0

1 Like

I have upgraded to 3.1.0 but still the same error