#Error in documentation

15 messages · Page 1 of 1 (latest)

light timber
#

On the NodeJS lib https://beta.openai.com/docs/guides/images/usage, the response contains a data object, with the whole response of the API.
The response of the API also contains a data object.

Change the Documentation to image_url = response.data.data[0].url;
Or change the lib to make it image_url = response.data[0].url;

#

Error in Docuemntation

#

Error in docuemntation

meager violet
#

Were you able to figure out the right response code? I'm having trouble figuring out how to feed the response url into a display image.

light timber
#

the documentation example is wrong, it is a common mistake with APIs
the problem is that the lib wraps the return of the API into a object called data
the ther API returns its data into a json that has an item called data, which contains everything on the response

so, in the end, the response.data contains an key called data, and yo uend up with response.data.data

#

since the API returns an array for each image, you will have tyo iterate over response.data.data, and each item is an object that contains the property url

meager violet
#

I think I understand. My problem is that I keep getting "list object has no attribute "data"
which, clearly doesn't make sense?

light timber
#

uhhh, try console.log(response.data) and take a look on how the structure is

#

maybe send a screenshot of the code

#

im assuming you are on NodeJS, right?

meager violet
#

Python, but I'm trying to figure out the translations

light timber
#

ohhh

#

well, I'm not sure if the same happens on python

quasi veldt
#

Should be fixed

gloomy stream
#

nice work guys and girls