Client = OpenAI() returns error "Client.__init__() got an unexpected keyword argument 'proxies'"

My environment:

  • Hardware: Apple M1 Pro
  • OS: Sonoma 14.6.1
  • Python 3.13.0

requirements.txt
annotated-types==0.7.0
anyio==4.6.2.post1
certifi==2024.8.30
distro==1.9.0
h11==0.14.0
httpcore==1.0.7
httpx==0.28.0
idna==3.10
jiter==0.8.0
openai==1.55.2
pydantic==2.10.2
pydantic_core==2.27.1
sniffio==1.3.1
tqdm==4.67.1
typing_extensions==4.12.2

My code:

from openai import OpenAI
client = OpenAI()

When I run this file using command

python -u src/main.py

It returns error TypeError: Client.init() got an unexpected keyword argument ‘proxies’
Full error message as below

Traceback (most recent call last):
  File "src/main.py", line 5, in <module>
    client = OpenAI()
  File "venv/lib/python3.13/site-packages/openai/_client.py", line 123, in __init__
    super().__init__(
    ~~~~~~~~~~~~~~~~^
        version=__version__,
        ^^^^^^^^^^^^^^^^^^^^
    ...<6 lines>...
        _strict_response_validation=_strict_response_validation,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "venv/lib/python3.13/site-packages/openai/_base_client.py", line 857, in __init__
    self._client = http_client or SyncHttpxClientWrapper(
                                  ~~~~~~~~~~~~~~~~~~~~~~^
        base_url=base_url,
        ^^^^^^^^^^^^^^^^^^
    ...<5 lines>...
        follow_redirects=True,
        ^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "venv/lib/python3.13/site-packages/openai/_base_client.py", line 755, in __init__
    super().__init__(**kwargs)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^
TypeError: Client.__init__() got an unexpected keyword argument 'proxies'

How to solve this problem? Thanks

3 Likes

I’m having the same problem also. Something changed around lunch time. My other environment I built yesterday is working but not my fresh environment. I’m not sure if one of the libraries have changed, I’m still trying to trace it through.

I’m having the same problem

Same problem here.

OS: Windows 11 Home
Python: 3.12.6

Packages:

$ pip list
Package Version


aiosmtplib 3.0.2
aiosqlite 0.20.0
alembic 1.14.0
amqp 5.3.1
annotated-types 0.7.0
anyio 4.6.2.post1
billiard 4.2.1
black 24.10.0
blinker 1.9.0
cachetools 5.5.0
celery 5.4.0
certifi 2024.8.30
cffi 1.17.1
cfgv 3.4.0
charset-normalizer 3.4.0
click 8.1.7
click-didyoumean 0.3.1
click-plugins 1.1.1
click-repl 0.3.0
colorama 0.4.6
cryptography 44.0.0
debugpy 1.8.9
distlib 0.3.9
distro 1.9.0
dnspython 2.7.0
email_validator 2.2.0
fastapi 0.115.5
fastapi-mail 1.4.2
filelock 3.16.1
flake8 7.1.1
flower 2.0.1
gitdb 4.0.11
GitPython 3.1.43
google-auth 2.36.0
google-auth-oauthlib 1.2.1
greenlet 3.1.1
gspread 6.1.4
h11 0.14.0
httpcore 1.0.7
httplib2 0.22.0
httpx 0.28.0
humanize 4.11.0
identify 2.6.3
idna 3.10
iniconfig 2.0.0
Jinja2 3.1.4
jiter 0.8.0
kombu 5.4.2
linkali-api 0.0.1
Mako 1.3.6
MarkupSafe 3.0.2
mccabe 0.7.0
mypy-extensions 1.0.0
nodeenv 1.9.1
oauth2client 4.1.3
oauthlib 3.2.2
openai 1.55.2
packaging 24.2
pathspec 0.12.1
pip 24.2
platformdirs 4.3.6
pluggy 1.5.0
pre_commit 4.0.1
prometheus_client 0.21.0
prompt_toolkit 3.0.48
pyasn1 0.6.1
pyasn1_modules 0.4.1
pycodestyle 2.12.1
pycparser 2.22
pydantic 2.10.2
pydantic_core 2.27.1
pydantic-settings 2.6.1
pyflakes 3.2.0
PyJWT 2.10.1
pyparsing 3.2.0
pytest 8.3.3
python-dateutil 2.9.0.post0
python-dotenv 1.0.1
python-multipart 0.0.17
pytz 2024.2
PyYAML 6.0.2
redis 5.2.0
requests 2.32.3
requests-oauthlib 2.0.0
rsa 4.9
sentry-sdk 2.19.0
six 1.16.0
smmap 5.0.1
sniffio 1.3.1
SQLAlchemy 2.0.36
sqlmodel 0.0.22
starlette 0.41.3
tornado 6.4.2
tqdm 4.67.1
typing_extensions 4.12.2
tzdata 2024.2
urllib3 2.2.3
uvicorn 0.32.1
vine 5.1.0
virtualenv 20.28.0
wcwidth 0.2.13

I updated to openai==1.55.3 and it works now. Checking the latest versions I can see that version 1.55.3 was released just a few minutes ago.

pip install --force-reinstall -v “openai==1.55.3”

5 Likes

openai==1.55.3 changing to this version fixed this issue

4 Likes

This’s work for me, thanks!

1 Like

I had the same issue on my fastapi server, unfortunately i added proxies as None as suggested by uvicorn.

So the issue was openai and changing the version to 1.55.3 fixed the issue for me.
Thanks

1 Like

I had it pulling the openai library as a dependency on langchain. Explicitly adding the openai version above to requirements fixed it.

The problem comes from incompatibility with the latest httpx==0.28.0 version and previous versions of openai. Openai v1.55.3 fixes the incompatibility issue, but you can also downgrade your httpx version to fix the error.

3 Likes

Thank you! worked wonderfully. pinning openai==1.55.3 and httpx==0.27.2 did it for me.

5 Likes

Thanks you! Upgrading openai to 1.55.3 worked!

2 Likes

Rock star. Thank you for identifying this!

1 Like

FYI I also confirmed pinning works for either independently (httpx 0.27.2 is compatible with older versions) and openai 1.55.3 resolves the newer concern.

I would recommend openai>=1.55.3 so you get the newer httpx also.

it is not mandatory that you use latest openai version to resolve connection error with openai. ( client proxies Error)

The httpx should be 0.27.2 even if you are using 1.7.2 version from openai
and it should be set to 0.27.2 or above if you are using httpx version 0.28.0.

Note: the google trans api does not support 0.28.0 or any other version but 0.13.3

4 Likes

Client = OpenAI() returns error “Client.init() got an unexpected keyword argument ‘proxies’”

openai==1.55.3 upgrade fixed this, thanks to all! :+1:

Thank you, Viktor. This helped

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.