Error with OpenAI 1.56.0 - Client.__init__() got an unexpected keyword argument 'proxies'

I’m trying to run the data validator with this bash command

openai tools fine_tunes.prepare_data -f training_data.jsonl

However, I’m getting this error

Traceback (most recent call last):
  File "/Users/Development/OpenAIFineTuning/myenv/bin/openai", line 8, in <module>
    sys.exit(main())
             ~~~~^^
  File "/Users/Development/OpenAIFineTuning/myenv/lib/python3.13/site-packages/openai/cli/_cli.py", line 129, in main
    _main()
    ~~~~~^^
  File "/Users/Development/OpenAIFineTuning/myenv/lib/python3.13/site-packages/openai/cli/_cli.py", line 179, in _main
    http_client = httpx.Client(
        proxies=proxies or None,
        http2=can_use_http2(),
    )
TypeError: Client.__init__() got an unexpected keyword argument 'proxies'

I’m seeing that other people got this same error but solved it by upgrading openai to v1.55.3.

However, I’ve tried with both v1.55.3 and v1.56 and I’m still getting the same error.

Would appreciate any help!

5 Likes

It is your environment: ill-advised Python 3.13, and deprecated method in the httpx library installed. It is no help that there is no requirements.txt in the python sdk repo, but a requirements.lock file has all pinned versions including the httpx past the deprecation employed.

The cli/_tools/fine_tunes.py hasn’t been touched for over a year. It will reject more valid training file than it would validate at this point.

(edit: the latest OpenAI Python client resolves this issue)

4 Likes

The issue is with the update of httpx to 0.28.
They removed the deprecated keyword proxies.
Until OpenAI pushes an update downgrade httpx to 0.27.2 to fix the issue.

21 Likes

This saved me some pain this morning. Thanks!

Thanks!! Saved me som time to :slight_smile:

Did you manage to solve the problem?

Hey everyone,
None of the solution mentioned above is working for me I am using Google colab and working on quite a very important research project that is required to be completed ideally in next 12hours. Any other quick fixes that I may do?

Have already put openai==1.56.1 and httpx==0.27.2

2 Likes

I’m using python’s requests library in google colab meanwhile to interact with OpenAI compatible servers

Same issue here. Code that worked yesterday is not working due to this error:
TypeError: Client.init() got an unexpected keyword argument ‘proxies’

i figured it out. On google colab write:

%%capture
!pip install openai==1.55.3 httpx==0.27.2 --force-reinstall --quiet

then in a new cell write:

import os
os.kill(os.getpid(), 9)

then it worked for me

30 Likes

Thanks. It worked for me !

Thank you. That worked for me.

It worked for me, Thank you.

I was not experiencing the issue last week but run into it this morning. Thanks for your post here! It works for me. I did not use the os.kill though…not sure if that’s a must step…

That totally worked. Thanks!

I tried downgrading the httpx library and upgrading the OpenAI library, but the issue persisted. What worked for me was creating a custom HTTP client to handle the proxies argument and assigning it to my OpenAI client:

import httpx

class CustomHTTPClient(httpx.Client):
    def __init__(self, *args, **kwargs):
        kwargs.pop("proxies", None)  # Remove the 'proxies' argument if present
        super().__init__(*args, **kwargs)

# my_class.py
class MyClass:
    def __init__(self):
        self.client = OpenAI(http_client=CustomHTTPClient())
1 Like

If you are using pip, the unrestricted version dependencies of the openai wheel will overwrite the installed httpx. httpx has to come last or as a second pip run with “httpx<0.28”.

The proper replacement for proxies is either proxy or mount parameter.

Downgrade the httpx to version- 0.27.2 to resolve this error. It will work.

Getting

‘ERROR: pip’s dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
jupyter-server 1.24.0 requires anyio<4,>=3.1.0, but you have anyio 4.7.0 which is incompatible.’

Anyone else have this issue?

Tried uninstalling anyio and reinstalling 3.7.0 but no luck

Considering pypi has jupyter-server 2.14.2, and gating anyio<4 was removed in 2.2.1, likely few have the issue.

Do you have something that installed IT with version<2?