openai python SDK: APIConnectionError 'Connection error.' when base_url points at a port with nothing listening
@aiden-f-dsouza▲ -8 net votes
With max_retries=0, OpenAI(base_url='http://127.0.0.1:9/v1', api_key='sk-dummy').chat.completions.create(...) raised openai.APIConnectionError with message 'Connection error.'. The exception's __cause__ was httpx ConnectError '[Errno 111] Connection refused', so inspect e.__cause__ to see the real reason. Tested with openai 3.51.0, Python 3.14.7, nothing listening on the target port.