# Is "request\_timeout" parameter real?

**URL:** <https://community.openai.com/t/is-request-timeout-parameter-real/377446>\
**Category:** API\
**Tags:** api\
**Created:** [September 17, 2023, 9:57am UTC](https://community.openai.com/t/is-request-timeout-parameter-real/377446 "2023-09-17T09:57:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nikola1jankovic](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/nikola1jankovic/32/36961_2.png) [@nikola1jankovic](https://community.openai.com/u/nikola1jankovic)\
**Post date:** [September 17, 2023, 9:57am UTC](https://community.openai.com/t/is-request-timeout-parameter-real/377446/1 "2023-09-17T09:57:32Z")

</div>

I have occasional, but repeating problems with the requests to OpenAI timing out.

`Request timed out: HTTPSConnectionPool(host='api.openai.com', port=443): Read timed out. (read timeout=600).`

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.

1. Does this parameter exist, have someone managed to make it work?
2. 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?

---

<div class="post-metadata">

**Author:** ![\_j](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/_j/32/719663_2.png) [@\_j](https://community.openai.com/u/_j)\
**Post date:** [September 17, 2023, 10:24am UTC](https://community.openai.com/t/is-request-timeout-parameter-real/377446/2 "2023-09-17T10:24:00Z")

</div>

Yes, it works. Set it to 4 seconds, get an error in four seconds.

---

<div class="post-metadata">

**Author:** ![Foxalabs](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/foxalabs/32/738355_2.png) [@Foxalabs](https://community.openai.com/u/Foxalabs)\
**Post date:** [September 17, 2023, 10:25am UTC](https://community.openai.com/t/is-request-timeout-parameter-real/377446/3 "2023-09-17T10:25:23Z")

</div>

Hi,

So looking around the forum, I found this comment

> [![](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/phuib/48/57959_2.png)](https://community.openai.com/u/phuib)
> 
> [phuib](https://community.openai.com/u/phuib)
> 
> [Mar 28](https://community.openai.com/t/how-to-set-a-timeout-on-an-api-function-call-using-using-the-python-library/4213/7)
> 
> Setting `request_timeout` worked for me.  
> e.g.
> 
> ```auto
> openai.Completion.create(request_timeout=1)
> 
> ```
> 
> I was able to get this exception message.
> 
> > Request timed out: HTTPSConnectionPool(host=‘[api.openai.com](http://api.openai.com/)’, port=443): Read timed out. (read timeout=1)

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.

---

<div class="post-metadata">

**Author:** ![10basetom](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/10basetom/32/43457_2.png) [@10basetom](https://community.openai.com/u/10basetom)\
**Post date:** [November 5, 2023, 5:27am UTC](https://community.openai.com/t/is-request-timeout-parameter-real/377446/4 "2023-11-05T05:27:08Z")

</div>

It’s not working with the JS library for me.

```auto
chatCompletion = await openai.chat.completions.create({
  ...
  request_timeout: 4,
});

```

**Error: 500 Internal Server Error (400 Unrecognized request argument supplied: request\_timeout)**

---

<div class="post-metadata">

**Author:** ![aus4](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/aus4/32/248827_2.png) [@aus4](https://community.openai.com/u/aus4)\
**Post date:** [November 14, 2023, 10:00pm UTC](https://community.openai.com/t/is-request-timeout-parameter-real/377446/5 "2023-11-14T22:00:58Z")

</div>

Also getting an error on the parameter in Python:

```auto
TypeError: Completions.create() got an unexpected keyword argument 'request_timeout'

```

```auto
completion = client.chat.completions.create(
                model="gpt-3.5-turbo",
                messages=[
                    {"role": "system", "content": "You are an assistant, skilled in marketing and discernment."},
                    {"role": "user", "content": "What's 2 + 2"
                       }
                ],
                request_timeout=10,  
            )
            return completion.choices[0].message

```

---

<div class="post-metadata">

**Author:** ![\_j](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/_j/32/719663_2.png) [@\_j](https://community.openai.com/u/_j)\
**Post date:** [November 14, 2023, 10:04pm UTC](https://community.openai.com/t/is-request-timeout-parameter-real/377446/6 "2023-11-14T22:04:16Z")

</div>

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.
