TypeError: Client.__init__() got an unexpected keyword argument 'proxies'
TypeError: 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.
Fix it fast
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)"2Match what you see, then jump to its 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
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
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:
- stegnor.comMy company site: 804 pages from a Python and Jinja generator, with 15 free browser tools.
- MenuloA restaurant discovery platform in Germany, kept current by a Python ingestion pipeline.
- ShopGoAn e-commerce aggregator with a Python scraping engine behind its catalog, past 10K Google Play downloads.
Related fixes
AI
Azure OpenAI says the API deployment for this resource does not exist
The API deployment for this resource does not exist
Azure OpenAI does not take a model name in the model field.
2 causes, each with a fixAI
Azure OpenAI fails with an SSL certificate verification error
httpx.ConnectError: [SSL: CERTIFICATE_VERIFY_FAILED]
The client checks the endpoint's certificate against its CA bundle, which is certifi by default.
2 causes, each with a fixAI
The OpenAI client says the API key is missing
Missing credentials. Please pass an `api_key`
OpenAI() looks for an api_key argument first and then the OPENAI_API_KEY environment variable.
3 causes, each with a fixAI
OpenAI says the model is a chat model and not supported in the v1/completions endpoint
This is a chat model and not supported in the v1/completions endpoint
The v1/completions endpoint accepts completion models such as gpt-3.5-turbo-instruct.
3 causes, each with a fixAI
Old openai.ChatCompletion or openai.Embedding code breaks on a new SDK
APIRemovedInV1
The Python SDK was rewritten in version 1.0.
2 causes, each with a fixAI
TypeError when you index an OpenAI response like a dictionary
TypeError: 'ChatCompletion' object is not subscriptable
Since SDK 1.0 the OpenAI Python library returns Pydantic model objects instead of dictionaries, so response['choices'] fails.
2 causes, each with a fix