openai / openai-node

The official Node.js / Typescript library for the OpenAI API
https://www.npmjs.com/package/openai
Apache License 2.0
7.64k stars 819 forks source link

Dall-e-2 image generations stopped working! #460

Closed demiro closed 10 months ago

demiro commented 10 months ago

Confirm this is a Node library issue and not an underlying OpenAI API issue

Describe the bug

This is really quite bad… already the API is quite frankly being documented poorly… announcements not working…

now for some reason, dall-e-2 images generation stopped working (have not updated node package)… getting 500 errors now…

so I updated the modules to 4.16.1, checked the documentation for the new dall-e-3 model and functionality… and my typescript throws error

Property ‘createImage’ does not exist on type ‘OpenAI’.

How can you allow for older versions to fail when you introduce new one? Without announcing breaking changes… and urge to update before you introduce the changes? Why is new one not working???

To Reproduce

image

Code snippets

mage = await openai.createImage({
      model: 'dall-e-3',
      prompt: `Create a photo in style of ${photoRequest.style} and should be of ${photoRequest.description}`,
      n: actualVariants,
      size: '1024x1024',
    });

OS

windows

Node version

Node v18.18.0

Library version

openai 4.16.1

RobertCraigie commented 10 months ago

You're using the v3 API, please read the migration guide: https://github.com/openai/openai-node/discussions/217

You're looking for the openai.images.generate method.

demiro commented 10 months ago

You're using the v3 API, please read the migration guide: #217

You're looking for the openai.images.generate method.

so this is where I am confused!

so I was using 4.12.1 for a while now and ALL WAS WORKING fine till yesterday.. (with dall-e-2 - or the default model, since I did not specify one:

image = await openai.images.generate({ prompt: Create a photo in style of ${photoRequest.style} and should be of ${photoRequest.description}, n: actualVariants, size: '1024x1024', });

after months using this, yesterday it stopped working, abruptly.. so I went to check the documentation, and the documentation says:

image

I tried it, and was not working... (image above)... so, I went and updated opeanai package to 4.16.1 ... and tried again, still not working...

but, after I reverted to my old code (what I had before ADDING the model property as you suggested) then it worked... and is working fine now...

so, PLEASE, at least fix the documentation and don't refer to OLD methd (openai.createImage)...

AND next time, make sure you don;t introduce a breaking change (making a property obligatory without telling the devs about the breaking change) --- meaning ... in this case if a model is not provided... don't throw an error, but use dall-e-2 as default...

any ways, it can stay closed, since I sorted it out... but just beware

athyuttamre commented 10 months ago

Apologies for the confusion here, our docs have a few out of date samples. We will fix that ASAP.

To clarify, the model parameter in the v1/images/generations endpoint is optional, and defaults to dall-e-2 when not specified. You can verify that with a curl request such as this:

$ curl https://api.openai.com/v1/images/generations -u :$OPENAI_API_KEY -H 'Content-Type: application/json' -d '{"prompt": "A happy dog"}'

{
  "created": 1699519055,
  "data": [
    {
      "url": "https://..."
    }
  ]
}

It's possible you were running into errors as our API was undergoing an outage today. We apologize for the inconvenience.