Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
AI and LLM integration

TypeError: Client.__init__() got an unexpected keyword argument 'proxies'

ErrorTypeError: Client.__init__() got an unexpected keyword argument 'proxies'

Short answer

httpx 0.28.0 removed its deprecated proxies argument. An old openai SDK, or your own http_client, still passes it. Upgrade openai to 1.55.3 or newer, and replace proxies= with proxy= in any client you build yourself. Pinning httpx below 0.28 is a temporary way out.

  • Applies to openai Python SDK 1.x, httpx 0.28
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Print the installed versions of both packages. openai below 1.55.3 together with httpx 0.28 or newer is the known bad pair.

    pip show openai httpx | grep -E "^(Name|Version)"
  2. 2Match what you see, then jump to its fix

    1. 1The traceback ends inside the openai package when you call OpenAI().openai SDK older than 1.55.3 with httpx 0.28 or newerFix
    2. 2The failing line is in your code, where httpx.Client or httpx.AsyncClient is created.Your own http_client passes proxies=Fix

What does the error look like?

  • TypeError: Client.__init__() got an unexpected keyword argument 'proxies'

Cause 1 of 2

openai SDK older than 1.55.3 with httpx 0.28 or newer

1Check

Compare the versions printed by the first step.

pip list 2>/dev/null | grep -iE "^(openai|httpx) "

2Fix

Upgrade the SDK. Release 1.55.3 added compatibility with httpx 0.28.0. If you cannot upgrade yet, keep httpx below 0.28 until you can.

pip install -U openai
# temporary only: pip install "httpx<0.28"

3Verify

Creating the client no longer raises.

python -c "from openai import OpenAI; OpenAI(api_key='x'); print('ok')"

Confirmed by github.com

Did this fix it?

Cause 2 of 2

Your own http_client passes proxies=

1Check

httpx 0.28.0 removed the deprecated proxies argument. Search your code.

grep -rn "proxies=" .

2Fix

Use proxy= for a single proxy, or mounts= for more complex setups, then pass the client to OpenAI.

import httpx
from openai import OpenAI
client = OpenAI(http_client=httpx.Client(proxy="http://proxy.example.com:8080"))

3Verify

The client is created without error.

python -c "import httpx; httpx.Client(proxy='http://proxy.example.com:8080'); print('ok')"

Confirmed by raw.githubusercontent.com

Did this fix it?

How do I stop it coming back?

  • Pin dependency versions in a lock file and upgrade them on purpose.
  • Read the changelog before bumping httpx.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.