Skip to content

Handle rate limits more gracefully #592

Description

@mnort9

Is your feature request related to a problem? Please describe.
Hitting an OpenAI rate limit should sometimes be handled differently than hitting other Faraday errors. With higher throughput applications, it's likely an expected state at some point.

Describe the solution you'd like
A simple solution could be providing a custom error:

rescue OpenAIError::RateLimitExceeded => e
  # Apply backoff logic based on reset value from OpenAI header
rescue = > e
  # Handle error
end

Describe alternatives you've considered
Check the status code. This works easy enough, but would be nice to be built-in and the code be the documentation.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions