HeadlinesBriefing favicon HeadlinesBriefing.com

OpenAI Python SDK Migrates to HTTPX2

Hacker News •
×

The OpenAI Python SDK has migrated to HTTPX2 for its synchronous and asynchronous HTTP clients. HTTPX2 is now installed automatically with the SDK, replacing the previous httpx package. This change affects applications that interact with the SDK's HTTP layer, but existing API calls, parsed response models, streaming, authentication, retries, and timeouts continue to work if you use the default client. No extra installation is required; however, if your application imported httpx solely because the SDK depended on it, you must now add httpx as your own dependency or migrate those imports to httpx2.

TLS certificate verification has also changed. HTTPX2 uses the operating system's trust store instead of the certifi bundle, which may break certificate verification in minimal container images, corporate TLS-inspecting proxies, or custom certifi setups. To fix this, install CA certificates in the system trust store or set the `SSL_CERT_FILE` or `SSL_CERT_DIR` environment variables. Alternatively, you can pass an `ssl.SSLContext` with your own CA bundle via the `verify` parameter when constructing a custom client.

For custom clients, use `httpx2.Client` and `httpx2.AsyncClient` directly, or use the provided `DefaultHttpx2Client` and `DefaultAsyncHttpx2Client` helpers to preserve the SDK's recommended defaults. The old `DefaultHttpxClient` names still work but now construct HTTPX2 clients. For granular timeout control, use `httpx2.Timeout` with parameters like `connect` and `read`. This migration ensures the SDK stays current with modern HTTP standards.