openai-node
openai-node copied to clipboard
openai.createImage doesn't surface errors
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
- Try to create an image from the Node client with the text "Elon Musk crying laughing emoji"
- Observe the error message
- Do the same via cURL
- Observe the verbose error message
Code snippets
No response
OS
macOS
Node version
16
Library version
3.1.0
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.
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.
Hi @jaskaye17
I am facing the same issue. Did you find any workaround? Thanks:)
cc: @jeevnayak
ran into a very similar error that I solved here: https://github.com/openai/openai-node/issues/125
This is fixed in our upcoming v4, which surfaces error messages better: https://github.com/openai/openai-node/discussions/182