openai.APIConnectionError when connection to gpt-4

junjie xu 20 Reputation points
2024-01-25T02:52:50.92+00:00

When I request my gpt-4 model, I am getting this error every time in my program:

  File "/Users/Documents/aigc/venv/lib/python3.9/site-packages/openai/_base_client.py", line 1055, in post
    return api_response.parse()
  File "/Users/Documents/aigc/venv/lib/python3.9/site-packages/openai/_base_client.py", line 834, in request
    ...
  File "/Users/Documents/aigc/venv/lib/python3.9/site-packages/openai/_base_client.py", line 890, in _request
    self._prepare_request(request)
  File "/Users/Documents/aigc/venv/lib/python3.9/site-packages/openai/_base_client.py", line 925, in _retry_request
    stream=stream,
  File "/Users/Documents/aigc/venv/lib/python3.9/site-packages/openai/_base_client.py", line 890, in _request
    self._prepare_request(request)
  File "/Users/Documents/aigc/venv/lib/python3.9/site-packages/openai/_base_client.py", line 925, in _retry_request
    stream=stream,
  File "/Users/Documents/aigc/venv/lib/python3.9/site-packages/openai/_base_client.py", line 897, in _request
    response = self._client.send(
openai.APIConnectionError: Connection error.


but gpt-3.5 model works fine. and when I try my gpt-4 model in Azure AI Studio playground, it still works fine. where is the problem?

Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
3,653 questions
{count} votes

Accepted answer
  1. navba-MSFT 27,465 Reputation points Microsoft Employee
    2024-01-29T06:36:05.04+00:00

    @junjie xu Thanks for getting back. I'm glad to see you were able to identify the cause of this issue. Thanks for posting your solution so that others experiencing the same thing can easily reference this. Since the Microsoft Q&A community has a policy that the question author cannot accept their own answer, they can only accept answers by others, I'll repost your solution in case you'd like to Accept the answer.

    . Issue: When I request my gpt-4 model, I am getting this error every time in my program: openai.APIConnectionError: Connection error. .

    Resolution: You have identified the cause of the issue which was due to the proxy. You hadn't turned off the proxy completely and it was interrupting the request if request time > 10s.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.