openai / openai-python

The official Python library for the OpenAI API

Home Page:https://pypi.org/project/openai/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

configure retry behavior

david-wb opened this issue · comments

Is there a way to configure this SDK to retry failed API calls?

My experiments are breaking half way through because of occasional errors such as

openai.error.APIError: The server had an error while processing your request. Sorry about that! You can retry your request, or contact support@openai.com if the error persists. (Please include the request ID [...] in your email.)

These are costing money and preventing experiments from running to completion, so I'd love to find a robust way to retry failed requests 2-3 times. Thank you for your input.

Hi! Thanks for the issue report.

Errors like this one usually indicate something wrong deeper in our stack. I believe we already have retry logic for specific types of errors but this one is usually too broad to take action on.

If you haven't done so already, I think the right way forward might be to email support@openai.com with the request ID in the error message. They should be able to dig into the errors you're seeing. I'd be happy to revisit this issue once we know more about the issue you're facing

@hallacy I'll send a support request, but in the meantime I resorted to simply catching openai.error.APIError and retrying manually, and that works well enough for my case. Thank you.