feat(api)!: migrate to HTTPX2 - #3594
Draft
apcha-oai wants to merge 1 commit into
Draft
Conversation
Castiron-Internal-PR: openai/openai-python-internal#19 Castiron-Source-SHA: 4e6fde5c2ff2e0ddcf7a6421317ad8af3f20f46c Castiron-Public-Base-SHA: ea17fda
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes HTTPX2 the default HTTP client for the next major Python SDK release. See the HTTPX Migration Guide for complete customer-facing migration instructions.
Customer migration
OpenAI()andAsyncOpenAI()use HTTPX2 automatically; API calls, parsed responses, streaming, retries, authentication, and numeric timeouts retain their existing interfaces.pip install openaiinstalls HTTPX2 instead of HTTPX. Applications importinghttpxthrough the SDK's former transitive dependency must migrate tohttpx2or installhttpxexplicitly.certifi. This can break certificate verification even with the default client; configure the system trust store,SSL_CERT_FILE,SSL_CERT_DIR, or a customssl.SSLContextas needed.openai[aiohttp]andDefaultAioHttpClient()remain supported through an HTTPX2-native transport without installing HTTPX orhttpx-aiohttp.httpx.Client,httpx.AsyncClient, andhttpx-aiohttpclients remain supported when passed throughhttp_client. This compatibility is runtime-only; legacy clients are not supported by static type checkers such as mypy or Pyright. Legacy HTTPX support is provided as a migration aid and may be discontinued.See httpx2.md for examples and detailed migration cases.
Implementation notes
Vendored dependencies
We've vendored a few dependencies in so that we can avoid installing
httpxby default for both normal dependencies and dev dependencies. This was the fastest path to unblock migration; we are happy to upstreamthese changes if it makes sense for those package's dependencies.
tests/respx2so existing request-mocking tests work without HTTPX.aiohttpbringing inhttpxby default for now.Issues