Unable to use API client=OpenAI()

When trying to use the API via Python, I can’t get past the:
client=OpenAI()
statement. My API key is working, but it returns this error on Spyder:

File ~/opt/anaconda3/lib/python3.9/site-packages/httpx/_transports/default.py:136 in init
self._pool = httpcore.ConnectionPool(

TypeError: init() got an unexpected keyword argument ‘socket_options’

and returns the following error using Jupyter Notebook:

File ~/opt/anaconda3/lib/python3.9/site-packages/httpx/_transports/default.py:136, in HTTPTransport.init(self, verify, cert, http1, http2, limits, trust_env, proxy, uds, local_address, retries, socket_options)
133 ssl_context = create_ssl_context(verify=verify, cert=cert, trust_env=trust_env)
135 if proxy is None:
→ 136 self._pool = httpcore.ConnectionPool(
137 ssl_context=ssl_context,
138 max_connections=limits.max_connections,
139 max_keepalive_connections=limits.max_keepalive_connections,
140 keepalive_expiry=limits.keepalive_expiry,
141 http1=http1,
142 http2=http2,
143 uds=uds,
144 local_address=local_address,
145 retries=retries,
146 socket_options=socket_options,
147 )
148 elif proxy.url.scheme in (“http”, “https”):
149 self._pool = httpcore.HTTPProxy(
150 proxy_url=httpcore.URL(
151 scheme=proxy.url.raw_scheme,
(…)
165 socket_options=socket_options,
166 )

TypeError: init() got an unexpected keyword argument ‘socket_options’

Thanks!
JH

httpx version 0.25.0 (sept 2023):

" Add socket_options argument to httpx.HTTPTransport and httpx.AsyncHTTPTransport classes."

Check your supporting library modules…

I hope this issue has already been resolved,
but just in case, please note that httpx 0.25.0 has dropped support for Python 3.7.

If you’re facing the socket_options TypeError, downgrading httpx to version 0.24.1 or earlier should fix the issue:

pip install "httpx<0.25.0"

Please carefully check to ensure that this downgrade does not affect other dependencies within your project.

Thank you. That was the problem. The request works now.