I put a forward proxy on my firewall with a bad cert SSL catcher, and configured the OS to use it. It broke my Python chatbot.
Then added this to make it work again:
import os
from openai import OpenAI
try:
os.environ['NO_PROXY'] = os.environ['NO_PROXY'] + ',' + 'api.openai.com'
except:
os.environ['NO_PROXY'] = 'api.openai.com'
client = OpenAI()
The httpx library that the openai python SDK module uses respects this no_proxy environment variable.