ChatGPT Suddenly Stops Working on Our Web-based Platform

Hello Community,

For about three days, we have been using ChatGPT with Python on our web-based platform, TSSFL Stack - https://www.tssfl.com (see here https://tssfl.com/viewtopic.php?t=6651) via SageMathCell that is built on top of Node.js. It has been working very great. The idea behind is everyone can use their own key with the following code snippet

#Replace the API Key with yours
input = """
Write your question, comment or anything that you need help with.
"""

print("%s" % input, "\n")

import openai
openai.api_key = "Put Your API Key Here"

model_engine = "gpt-3.5-turbo"

response = openai.ChatCompletion.create(
    model='gpt-3.5-turbo',
    n=1,
    messages=[
        {"role": "system", "content": "You are a very helpful intelligent Assistant."},
        {"role": "user", "content": input},
    ])

message = response.choices[0]['message']
print("{}: \n\n{}".format(message['role'], message['content']))

to accomplish what they want with ChatGPT.

This is no longer working since about three days. How to fix the problem, what is wrong or what might have been changed by OpenAI ?

Appreciating your support,

TSSFL

Did you got any error-message back? Can you provide some further details on this?

Hi @linus, Thank you.

Here is the error,

Timeout: Request timed out: HTTPSConnectionPool(host='api.openai.com', port=443): Max retries exceeded with url: /v1/chat/completions (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7f7b8a57da20>, 'Connection to api.openai.com timed out. (connect timeout=600)'))

Bear in mind that api.openai.com is whitelisted to work with SageMathCell: sagecell/firewall at master · sagemath/sagecell · GitHub

Thank you

Hi @raul_pablo_garrido_c

I generated a new key, tested it without any success.

Thank you.

Another troubleshooting step would be to do a simple API-Call not inside your application to check if this would be a Issue with your Account or keys.

I’m tempted to assume this would be the case because you mentioned that it worked for you some time.

@linus

It works well locally, i.e., with my desktop but does not work with our application. Looks like OpenAI blocked the usage, they prevented API calls from other sites! Why would they do that ?

@linus @raul_pablo_garrido_c

Where there is a problem ? Here is the full error message:

---------------------------------------------------------------------------
TimeoutError                              Traceback (most recent call last)
File /home/sc_serv/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/urllib3/connection.py:174, in HTTPConnection._new_conn(self)
    173 try:
--> 174     conn = connection.create_connection(
    175         (self._dns_host, self.port), self.timeout, **extra_kw
    176     )
    178 except SocketTimeout:

File /home/sc_serv/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/urllib3/util/connection.py:95, in create_connection(address, timeout, source_address, socket_options)
     94 if err is not None:
---> 95     raise err
     97 raise socket.error("getaddrinfo returns an empty list")

File /home/sc_serv/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/urllib3/util/connection.py:85, in create_connection(address, timeout, source_address, socket_options)
     84     sock.bind(source_address)
---> 85 sock.connect(sa)
     86 return sock

TimeoutError: [Errno 110] Connection timed out

During handling of the above exception, another exception occurred:

ConnectTimeoutError                       Traceback (most recent call last)
File /home/sc_serv/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/urllib3/connectionpool.py:703, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    702 # Make the request on the httplib connection object.
--> 703 httplib_response = self._make_request(
    704     conn,
    705     method,
    706     url,
    707     timeout=timeout_obj,
    708     body=body,
    709     headers=headers,
    710     chunked=chunked,
    711 )
    713 # If we're going to release the connection in ``finally:``, then
    714 # the response doesn't need to know about the connection. Otherwise
    715 # it will also try to release it and we'll have a double-release
    716 # mess.

File /home/sc_serv/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/urllib3/connectionpool.py:386, in HTTPConnectionPool._make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
    385 try:
--> 386     self._validate_conn(conn)
    387 except (SocketTimeout, BaseSSLError) as e:
    388     # Py2 raises this as a BaseSSLError, Py3 raises it as socket timeout.

File /home/sc_serv/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/urllib3/connectionpool.py:1042, in HTTPSConnectionPool._validate_conn(self, conn)
   1041 if not getattr(conn, "sock", None):  # AppEngine might not have  `.sock`
-> 1042     conn.connect()
   1044 if not conn.is_verified:

File /home/sc_serv/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/urllib3/connection.py:358, in HTTPSConnection.connect(self)
    356 def connect(self):
    357     # Add certificate verification
--> 358     self.sock = conn = self._new_conn()
    359     hostname = self.host

File /home/sc_serv/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/urllib3/connection.py:179, in HTTPConnection._new_conn(self)
    178 except SocketTimeout:
--> 179     raise ConnectTimeoutError(
    180         self,
    181         "Connection to %s timed out. (connect timeout=%s)"
    182         % (self.host, self.timeout),
    183     )
    185 except SocketError as e:

ConnectTimeoutError: (<urllib3.connection.HTTPSConnection object at 0x7f75fe86c3a0>, 'Connection to api.openai.com timed out. (connect timeout=600)')

During handling of the above exception, another exception occurred:

MaxRetryError                             Traceback (most recent call last)
File /home/sc_serv/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/requests/adapters.py:489, in HTTPAdapter.send(self, request, stream, timeout, verify, cert, proxies)
    488 if not chunked:
--> 489     resp = conn.urlopen(
    490         method=request.method,
    491         url=url,
    492         body=request.body,
    493         headers=request.headers,
    494         redirect=False,
    495         assert_same_host=False,
    496         preload_content=False,
    497         decode_content=False,
    498         retries=self.max_retries,
    499         timeout=timeout,
    500     )
    502 # Send the request.
    503 else:

File /home/sc_serv/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/urllib3/connectionpool.py:815, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    812     log.warning(
    813         "Retrying (%r) after connection broken by '%r': %s", retries, err, url
    814     )
--> 815     return self.urlopen(
    816         method,
    817         url,
    818         body,
    819         headers,
    820         retries,
    821         redirect,
    822         assert_same_host,
    823         timeout=timeout,
    824         pool_timeout=pool_timeout,
    825         release_conn=release_conn,
    826         chunked=chunked,
    827         body_pos=body_pos,
    828         **response_kw
    829     )
    831 # Handle redirect?

File /home/sc_serv/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/urllib3/connectionpool.py:815, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    812     log.warning(
    813         "Retrying (%r) after connection broken by '%r': %s", retries, err, url
    814     )
--> 815     return self.urlopen(
    816         method,
    817         url,
    818         body,
    819         headers,
    820         retries,
    821         redirect,
    822         assert_same_host,
    823         timeout=timeout,
    824         pool_timeout=pool_timeout,
    825         release_conn=release_conn,
    826         chunked=chunked,
    827         body_pos=body_pos,
    828         **response_kw
    829     )
    831 # Handle redirect?

File /home/sc_serv/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/urllib3/connectionpool.py:787, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    785     e = ProtocolError("Connection aborted.", e)
--> 787 retries = retries.increment(
    788     method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
    789 )
    790 retries.sleep()

File /home/sc_serv/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/urllib3/util/retry.py:592, in Retry.increment(self, method, url, response, error, _pool, _stacktrace)
    591 if new_retry.is_exhausted():
--> 592     raise MaxRetryError(_pool, url, error or ResponseError(cause))
    594 log.debug("Incremented Retry for (url='%s'): %r", url, new_retry)

MaxRetryError: HTTPSConnectionPool(host='api.openai.com', port=443): Max retries exceeded with url: /v1/chat/completions (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7f75fe86c3a0>, 'Connection to api.openai.com timed out. (connect timeout=600)'))

During handling of the above exception, another exception occurred:

ConnectTimeout                            Traceback (most recent call last)
File /home/sc_serv/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/openai/api_requestor.py:516, in APIRequestor.request_raw(self, method, url, params, supplied_headers, files, stream, request_id, request_timeout)
    515 try:
--> 516     result = _thread_context.session.request(
    517         method,
    518         abs_url,
    519         headers=headers,
    520         data=data,
    521         files=files,
    522         stream=stream,
    523         timeout=request_timeout if request_timeout else TIMEOUT_SECS,
    524     )
    525 except requests.exceptions.Timeout as e:

File /home/sc_serv/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/requests/sessions.py:587, in Session.request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
    586 send_kwargs.update(settings)
--> 587 resp = self.send(prep, **send_kwargs)
    589 return resp

File /home/sc_serv/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/requests/sessions.py:701, in Session.send(self, request, **kwargs)
    700 # Send the request
--> 701 r = adapter.send(request, **kwargs)
    703 # Total elapsed time of the request (approximately)

File /home/sc_serv/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/requests/adapters.py:553, in HTTPAdapter.send(self, request, stream, timeout, verify, cert, proxies)
    552     if not isinstance(e.reason, NewConnectionError):
--> 553         raise ConnectTimeout(e, request=request)
    555 if isinstance(e.reason, ResponseError):

ConnectTimeout: HTTPSConnectionPool(host='api.openai.com', port=443): Max retries exceeded with url: /v1/chat/completions (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7f75fe86c3a0>, 'Connection to api.openai.com timed out. (connect timeout=600)'))

The above exception was the direct cause of the following exception:

Timeout                                   Traceback (most recent call last)
Cell In [1], line 1
----> 1 exec("""#Replace the API Key with yours
      2 input = \"\"\"
      3 Write your question, comment or anything that you need help with.
      4 \"\"\"
      5 
      6 print(\"%s\" % input, \"\\n\")
      7 
      8 import openai
      9 openai.api_key = \"sk....."
     10 
     11 model_engine = \"gpt-3.5-turbo\"
     12 
     13 response = openai.ChatCompletion.create(
     14     model='gpt-3.5-turbo',
     15     n=1,
     16     messages=[
     17         {\"role\": \"system\", \"content\": \"You are a very helpful intelligent Assistant.\"},
     18         {\"role\": \"user\", \"content\": input},
     19     ])
     20 
     21 message = response.choices[0]['message']
     22 print(\"{}: \\n\\n{}\".format(message['role'], message['content']))""")

File <string>:13

File /home/sc_serv/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/openai/api_resources/chat_completion.py:25, in ChatCompletion.create(cls, *args, **kwargs)
     23 while True:
     24     try:
---> 25         return super().create(*args, **kwargs)
     26     except TryAgain as e:
     27         if timeout is not None and time.time() > start + timeout:

File /home/sc_serv/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/openai/api_resources/abstract/engine_api_resource.py:153, in EngineAPIResource.create(cls, api_key, api_base, api_type, request_id, api_version, organization, **params)
    127 @classmethod
    128 def create(
    129     cls,
   (...)
    136     **params,
    137 ):
    138     (
    139         deployment_id,
    140         engine,
   (...)
    150         api_key, api_base, api_type, api_version, organization, **params
    151     )
--> 153     response, _, api_key = requestor.request(
    154         "post",
    155         url,
    156         params=params,
    157         headers=headers,
    158         stream=stream,
    159         request_id=request_id,
    160         request_timeout=request_timeout,
    161     )
    163     if stream:
    164         # must be an iterator
    165         assert not isinstance(response, OpenAIResponse)

File /home/sc_serv/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/openai/api_requestor.py:216, in APIRequestor.request(self, method, url, params, headers, files, stream, request_id, request_timeout)
    205 def request(
    206     self,
    207     method,
   (...)
    214     request_timeout: Optional[Union[float, Tuple[float, float]]] = None,
    215 ) -> Tuple[Union[OpenAIResponse, Iterator[OpenAIResponse]], bool, str]:
--> 216     result = self.request_raw(
    217         method.lower(),
    218         url,
    219         params=params,
    220         supplied_headers=headers,
    221         files=files,
    222         stream=stream,
    223         request_id=request_id,
    224         request_timeout=request_timeout,
    225     )
    226     resp, got_stream = self._interpret_response(result, stream)
    227     return resp, got_stream, self.api_key

File /home/sc_serv/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/openai/api_requestor.py:526, in APIRequestor.request_raw(self, method, url, params, supplied_headers, files, stream, request_id, request_timeout)
    516     result = _thread_context.session.request(
    517         method,
    518         abs_url,
   (...)
    523         timeout=request_timeout if request_timeout else TIMEOUT_SECS,
    524     )
    525 except requests.exceptions.Timeout as e:
--> 526     raise error.Timeout("Request timed out: {}".format(e)) from e
    527 except requests.exceptions.RequestException as e:
    528     raise error.APIConnectionError(
    529         "Error communicating with OpenAI: {}".format(e)
    530     ) from e

Timeout: Request timed out: HTTPSConnectionPool(host='api.openai.com', port=443): Max retries exceeded with url: /v1/chat/completions (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x7f75fe86c3a0>, 'Connection to api.openai.com timed out. (connect timeout=600)'))

I’m also getting the error, I made a mistake and ended up flooding the api without knowing it was happening. And, now I can’t use the API at all

@farbour Seems no one has clue on this problem!