Skip to content

openai.error.APIConnectionError: Error communicating with OpenAI #91

Closed
@celinemol

Description

@celinemol

Hello, we are getting this issue in our production environment, but seems to be working fine locally. Do you know what the issue might be?

Traceback (most recent call last):
  File "/env/lib/python3.9/site-packages/openai/api_requestor.py", line 279, in request_raw
    result = _thread_context.session.request(
  File "/env/lib/python3.9/site-packages/requests/sessions.py", line 529, in request
    resp = self.send(prep, **send_kwargs)
  File "/env/lib/python3.9/site-packages/requests/sessions.py", line 645, in send
    r = adapter.send(request, **kwargs)
  File "/env/lib/python3.9/site-packages/requests/adapters.py", line 519, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.openai.com', port=443): Max retries exceeded with url: /v1/engines/content-filter-alpha/completions (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f08403ee970>: Failed to establish a new connection: [Errno 110] Connection timed out'))


The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/app/beni_services/usecase.py", line 33, in execute
    response_parameters = self.do_execute()
  File "/app/product_catalog/use_cases/get_dynamic_filters.py", line 150, in do_execute
    product_details_using_gpt3 = self._get_product_details_using_gpt3(product_details=product_details)
  File "/app/product_catalog/use_cases/get_dynamic_filters.py", line 276, in _get_product_details_using_gpt3
    if self._safe_to_use_openai(openai_prompt):
  File "/app/product_catalog/use_cases/get_dynamic_filters.py", line 302, in _safe_to_use_openai
    response = openai.Completion.create(
  File "/env/lib/python3.9/site-packages/openai/api_resources/completion.py", line 31, in create
    return super().create(*args, **kwargs)
  File "/env/lib/python3.9/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 90, in create
    response, _, api_key = requestor.request(
  File "/env/lib/python3.9/site-packages/openai/api_requestor.py", line 100, in request
    result = self.request_raw(
  File "/env/lib/python3.9/site-packages/openai/api_requestor.py", line 289, in request_raw
    raise error.APIConnectionError("Error communicating with OpenAI") from e
openai.error.APIConnectionError: Error communicating with OpenAI

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixed in v1Issues addressed by the v1 beta

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions