# Setting request\_timeout in openai v1.2.2

**URL:** <https://community.openai.com/t/setting-request-timeout-in-openai-v1-2-2/492772>\
**Category:** API\
**Created:** [November 10, 2023, 1:50pm UTC](https://community.openai.com/t/setting-request-timeout-in-openai-v1-2-2/492772 "2023-11-10T13:50:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lachezarmitov](https://avatars.discourse-cdn.com/v4/letter/l/cc9497/32.png) [@lachezarmitov](https://community.openai.com/u/lachezarmitov)\
**Post date:** [November 10, 2023, 1:50pm UTC](https://community.openai.com/t/setting-request-timeout-in-openai-v1-2-2/492772/1 "2023-11-10T13:50:58Z")

</div>

I often got a timeout 600s error when using the Chat completions API. So I found out that if you put a request\_timeout as a parameter it would stop the request after a certain amount of time. And this worked great until I had to update the SDK version from 0.28.1 to 1.2.2. Now the **`request_timeout`** parameter is gone and there is only the **`timeout`** parameter. But from my experience using **`timeout`** doesn’t stop the request even after it goes past the custom time set. This is what my previous request looked like:

```auto
response = openai.ChatCompletion.create(
                model='gpt-3.5-turbo-1106',
                messages=[
                    {"role": "system",
                     "content":
                     "I will give you a sentence. I want you to summarize the topic of the sentence in 3 words."
                     "These 3 words will be used to search for an image to fit the sentence so make sure the words make sense to the meaning of the sentence."
                     f"Answer by writing the 3 words only."
                     },
                    {"role": "user",
                     "content": f"This is the sentence: '{sentence}'."},
                ],
                # temperature=0.3,
                request_timeout=90,
            )

            message = response.choices[0]['message']
            # Get the content from the message
            content = message['content']

```

And this is what it looks like now:

```auto
 try:
            completion = client.chat.completions.create(
                model='gpt-3.5-turbo-1106',
                messages=[
                    {"role": "system",
                     "content":
                         "I will give you a sentence. I want you to summarize the topic of the sentence in 3 words."
                         "These 3 words will be used to search for an image to fit the sentence so make sure the words make sense to the meaning of the sentence."
                         f"Answer by writing the 3 words only."
                     },
                    {"role": "user",
                     "content": f"This is the sentence: '{sentence}'."},
                ],
                # temperature=0.3,
                timeout=90,
            )

            message = completion.choices[0].message
            # Get the content from the message
            content = message.content

```

---

<div class="post-metadata">

**Author:** ![\_j](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/_j/32/766292_2.png) [@\_j](https://community.openai.com/u/_j)\
**Post date:** [November 10, 2023, 1:56pm UTC](https://community.openai.com/t/setting-request-timeout-in-openai-v1-2-2/492772/2 "2023-11-10T13:56:27Z")

</div>

See the first 10 lines or so of the script I posted for different purpose here:

> [@Gpt-3.5-turbo-1106 is very slow](https://community.openai.com/t/gpt-3-5-turbo-1106-is-very-slow/492450/9):
>
> Oh noes Llama that can make 80 tokens a second? “I was the first one on the server and it was fast!” “So angry that this is only twice the rate that gpt-3.5-turbo has been producing for the last months.” Free benchmark code I just ran and bonus utilities. If you aren’t also making the same rate at a tier higher than me, wait for your payment to process. play_button python w openai == 1.2.2, tiktoken

---

<div class="post-metadata">

**Author:** ![lachezarmitov](https://avatars.discourse-cdn.com/v4/letter/l/cc9497/32.png) [@lachezarmitov](https://community.openai.com/u/lachezarmitov)\
**Post date:** [November 10, 2023, 2:17pm UTC](https://community.openai.com/t/setting-request-timeout-in-openai-v1-2-2/492772/3 "2023-11-10T14:17:09Z")

</div>

This indeed fixed it. Thank you! But now I am interested in what are the other values in the Timeout,except the default one, are about:

```auto
client = OpenAI(timeout=httpx.Timeout(15.0, read=5.0, write=10.0, connect=3.0))

```

Like the ` read`, `write` and` connect` parameters?

---

<div class="post-metadata">

**Author:** ![\_j](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/_j/32/766292_2.png) [@\_j](https://community.openai.com/u/_j)\
**Post date:** [November 10, 2023, 4:15pm UTC](https://community.openai.com/t/setting-request-timeout-in-openai-v1-2-2/492772/4 "2023-11-10T16:15:03Z")

</div>

You can read the httpx library docs. read should achieve the goal of timing out if there is a lack of SSE activity, but that’s a bit hard to test without doing your own simulator.
