About Capturing Errors Silently

You can capture rare errors silently with Sentry for logging and notification and return something meaningful to the user.

import sentry_sdk
try:
    response = client.chat.completions.create(**request_data)
except openai.RateLimitError as err:
    sentry_sdk.capture_exception(err)
    print("Temporary error. Please try again later.")

Tips and Tricks Programming Python 3 Sentry