TypeError: openai.createImage is not a function

See the API docs. For openai 4.x:

import OpenAI from "openai";

const openai = new OpenAI();

async function main() {
  const image = await openai.images.generate({ prompt: "A cute baby sea otter" });

  console.log(image.data);
}
main();
2 Likes