Skip to content

Use of proxies kwarg in httpx==0.28.0 #1902

Closed

Description

@DJRHails

Confirm this is an issue with the Python library and not an underlying OpenAI API

  • This is an issue with the Python library

Describe the bug

httpx version 0.28.0 removes the deprecated proxies argument; this argument is hardcoded in the library at the moment.

To Reproduce

  1. Update to httpx version 0.28.0

Code snippets

  File "/var/lang/lib/python3.10/site-packages/openai/_client.py", line 337, in __init__
    super().__init__(
  File "/var/lang/lib/python3.10/site-packages/openai/_base_client.py", line 1438, in __init__
    self._client = http_client or AsyncHttpxClientWrapper(
  File "/var/lang/lib/python3.10/site-packages/openai/_base_client.py", line 1335, in __init__
    super().__init__(**kwargs)
TypeError: AsyncClient.__init__() got an unexpected keyword argument 'proxies'

OS

macOS

Python version

Python 3.10.12

Library version

openai-1.55.2

Activity

  1. stestagg commented on Nov 28, 2024

    @stestagg

    This is causing a fresh install of openai to be broken currently.

    Here's a reproducer: (Dockerfile)

    from alpine:edge
    
    RUN apk update
    RUN apk add python3 py3-pip
    
    RUN pip install  --break-system-packages openai
    RUN python -c 'import openai; client=openai.AsyncOpenAI(api_key="X")'
    

    Gives:

     => ERROR [5/5] RUN python -c 'import openai; client=openai.AsyncOpenAI(api_key="X")'                              0.4s
    ------
     > [5/5] RUN python -c 'import openai; client=openai.AsyncOpenAI(api_key="X")':
    0.307 Traceback (most recent call last):
    0.307   File "<string>", line 1, in <module>
    0.307   File "/usr/lib/python3.12/site-packages/openai/_client.py", line 337, in __init__
    0.307     super().__init__(
    0.307   File "/usr/lib/python3.12/site-packages/openai/_base_client.py", line 1438, in __init__
    0.307     self._client = http_client or AsyncHttpxClientWrapper(
    0.307                                   ^^^^^^^^^^^^^^^^^^^^^^^^
    0.307   File "/usr/lib/python3.12/site-packages/openai/_base_client.py", line 1335, in __init__
    0.308     super().__init__(**kwargs)
    0.308 TypeError: AsyncClient.__init__() got an unexpected keyword argument 'proxies'
    ------
    Dockerfile:7
    --------------------
       5 |
       6 |     RUN pip install  --break-system-packages openai
       7 | >>> RUN python -c 'import openai; client=openai.AsyncOpenAI(api_key="X")'
       8 |
    --------------------
    
  2. Pablo-Merino commented on Nov 28, 2024

    @Pablo-Merino

    Having this issue too, with the synchronous client. A temporary fix I've found is to hardcode the httpx version in my requirements to the previous release, which is 0.27.2.

    Just adding httpx==0.27.2 makes my code work again.

  3. dgellow commented on Nov 28, 2024

    @dgellow
    Contributor

    Hi, thank you for the reports, we (@stainless-api) are actively working on a fix.

    Edit: we have a patch under review right now and expect to push it to this repo in a few minutes

  4. RobertCraigie commented on Nov 28, 2024

    @RobertCraigie
    Contributor

    Thanks for the reports, this will be fixed shortly

  5. dgellow commented on Nov 28, 2024

    @dgellow
    Contributor

    Should be fixed once #1905 gets merged (all the credits to the amazing @RobertCraigie for the quick fix)

  6. RobertCraigie commented on Nov 28, 2024

    @RobertCraigie
    Contributor

    Sorry for the delay, we're trying to get a hold of someone with the credentials to publish a new release.

  7. stainless-app commented on Nov 28, 2024

    @stainless-app
    Contributor

    Fixed by #1905

  8. vvaezian commented on Dec 1, 2024

    @vvaezian

    @dgellow @RobertCraigie In the pyproject.toml file, the httpx version is defined as httpx>=0.23.0, <1. Isn't this too wide? It seems to me the dependent libraries versions should only include the current and tested versions. But <1 allows many future upgrades that can potentially break stuff like the current issue. Other dependent libraries are defined in the same manner and seems to have the same issue.

  9. dgellow commented on Dec 2, 2024

    @dgellow
    Contributor

    Hi @vvaezian, thanks for pointing that out. I tend to agree, though I'm not sure how strict the version range should be in this specific context. That's something we identified and will be discussing today as part of our internal post-mortem for that httpx v0.28.0 incident. I expect we will share an update later today in this thread.

  10. kristapratico commented on Dec 2, 2024

    @kristapratico
    Contributor

    @dgellow @RobertCraigie FYI it looks like we need the same fix in the CLI:

    http_client = httpx.Client(
    proxies=proxies or None,
    http2=can_use_http2(),
    )

  11. RobertCraigie commented on Dec 2, 2024

    @RobertCraigie
    Contributor

    ah good catch thank you!

  12. dgellow commented on Dec 5, 2024

    @dgellow
    Contributor

    @vvaezian Following up on your question, we decided against narrowing the version constraints. Instead we decided to invest into improving our testing setup to be sure we have coverage for nightly/dev versions of httpx (and other core dependencies), before they are released publicly.

  13. added a commit that references this issue on Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions