I have gone through the forum and have noticed that some users are recommending using request_timeout parameter, to shorten that time, and repeat the request after. However, others are recommending creating own function in Python to do that. Also, the parameter is not mentioned in the OpenAI documentation.
Does this parameter exist, have someone managed to make it work?
If not and if I need to do it by myself, I am not really clear the logic behind that. I have implemented the exponential backoff strategy, as suggested by OpenAI - but, if the timeout is 600 seconds, this means that the next retry will come after 10 minutes? Should I somehow cut the request if it takes more than, let’s say 30 seconds?
I can’t find reference to it in the OpenAI docs, but it is mentioned in the git repo, I think the folks that are managing it themselves are doing so by .create(ing) the object and then if a reply is not received within a specific period they are calling the .close method and generating their own exceptions.
You can set a timeout for the new python library when setting up your OpenAI object.
client = OpenAI(timeout=60)
Or for streaming, you can get really specific and set the parameters on the httpx library as exposed through the openai parameters.
client = OpenAI(timeout=httpx.Timeout(15.0, read=5.0, write=10.0, connect=3.0))
Then instead of a parameter error, you’ll get a timeout error to handle after the time elapses.