openai-node icon indicating copy to clipboard operation
openai-node copied to clipboard

openai.createImage doesn't surface errors

Open domeccleston opened this issue 3 years ago • 3 comments

Describe the bug

If I try calling the OpenAI API with openai.createImage and my request is malformed, I just get a generic "request failed with status code 400". If I make the request with cURL instead, I can see the reason my request failed (invalid_request_error, rejected due to safety system).

Possible to surface these errors to the client?

To Reproduce

  1. Try to create an image from the Node client with the text "Elon Musk crying laughing emoji"
  2. Observe the error message
  3. Do the same via cURL
  4. Observe the verbose error message

Code snippets

No response

OS

macOS

Node version

16

Library version

3.1.0

domeccleston avatar Nov 05 '22 12:11 domeccleston

Could you try checking error.response.data or error.message to see if it's captured there? https://github.com/openai/openai-node#error-handling

If not, then we'll look into this! And we also might add this tip to the guide in our docs so it's easier to find.

jeevnayak avatar Nov 07 '22 22:11 jeevnayak

I'm experiencing this issue as well.

Dumping error.response.data throws a typerror reading property data of undefined. Dumpin error.message gives me error message circular error

{"error":"Converting circular structure to JSON\n    --> starting at object with constructor 'ClientRequest'\n    |     property 'socket' -> object with constructor 'TLSSocket'\n    --- property '_httpMessage' closes the circle"}

Using cURL worked successfully for me as a side not.

jaskaye17 avatar Dec 08 '22 05:12 jaskaye17

Hi @jaskaye17

I am facing the same issue. Did you find any workaround? Thanks:)

cc: @jeevnayak

tce-darshan avatar Jan 11 '23 18:01 tce-darshan

ran into a very similar error that I solved here: https://github.com/openai/openai-node/issues/125

leo-paz avatar Mar 31 '23 03:03 leo-paz

This is fixed in our upcoming v4, which surfaces error messages better: https://github.com/openai/openai-node/discussions/182

rattrayalex avatar Jul 10 '23 01:07 rattrayalex