Skip to content

Get response data when the status is not in 200-300 #54

@noobnooc

Description

@noobnooc

I used this package to access the OpenAI API. However, when the response has a status code outside of the range 200-300, an error occurs. The UnsuccessfulResponseError object only includes a responseStatus field, but OpenAI responded with a JSON error message like the following:

{
  "error": {
    "param": null,
    "message": "Rate limit reached for default-gpt-3.5-turbo in organization org-xxx on requests per minute. Limit: 20 / min. Current: 30 / min. Contact support@openai.com if you continue to have issues. Please add a payment method to your account to increase your rate limit. Visit https:\/\/platform.openai.com\/account\/billing to add a payment method.",
    "code": null,
    "type": "requests"
  }
}

I would like to retrieve the message from this error response, but I couldn't find a way to do it. Is it possible to do so with the current version? If not, could you please add this functionality in a future release?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions