Friday, October 23, 2026|20°C Partly Cloudy
Next edition scheduled
Your Personal Daily Intelligence
Edition 2026-08-29

TECHNOLOGY

OpenAI Python SDK Adopts HTTPX2 for HTTP Clients

The OpenAI Python SDK now uses HTTPX2 for its synchronous and asynchronous HTTP clients, replacing the previous httpx package.

By Hacker News · 56d ago · Source: Hacker News

Full article

The OpenAI Python SDK now uses HTTPX2 for its synchronous and asynchronous HTTP clients, replacing the previous httpx package. The default OpenAI client continues to work without modification; existing API calls, response models, streaming, authentication and timeout settings remain functional. Applications that previously imported httpx only because of transitive SDK installation should add httpx or replace imports with httpx2.

The SDK documentation notes that HTTPX2 changes the default TLS trust store from the certifi bundle to the operating‑system trust store, which can break certificate verification in minimal container images without system certificates, environments using corporate proxy inspection, or deployments that relied on custom certifi bundles. Users can set SSL_CERT_FILE or SSL_CERT_DIR environment variables, or provide an SSLContext through the verify parameter when configuring a custom client.

The SDK provides DefaultHttpx2Client and DefaultAsyncHttpx2Client helpers that preserve timeout, connection‑pool and redirect defaults. Developers can instantiate HTTPX2 clients directly, or set openai.http_client = openai.DefaultHttpx2Client() to make the change explicit.

HTTPX objects have been renamed to HTTPX2 equivalents, including Client, AsyncClient, Timeout, URL, Limits, HTTPTransport, AsyncHTTPTransport and MockTransport. Timeout arguments remain numeric, and string URLs are unchanged. Custom transport subclasses, mounted transports, proxy settings and connection‑pool instrumentation must target the HTTPX2 transport interfaces.

Authentication handlers and hooks now receive HTTPX2 request and response objects; custom auth classes and tracing middleware must be updated to support HTTPX2.

Parsed SDK response models are unchanged; when using a native HTTPX2 client, transport objects are HTTPX2 types and raw responses can be cast to httpx2.Response. SDK exceptions such as APITimeoutError remain catchable, though the underlying cause will be an HTTPX2 exception for native clients.

The openai[aiohttp] extra uses an HTTPX2‑native transport and does not install legacy httpx or the httpx‑aiohttp adapter; new code should use DefaultAioHttpClient, which is an HTTPX2 client.

Test mocks must intercept HTTPX2 requests and return HTTPX2 responses; RESPX integrations require an HTTPX2‑compatible version, while legacy‑only versions cannot intercept the default client. A temporary escape hatch allows continued use of a legacy HTTPX client by installing httpx and casting the client type.

Legacy HTTPX support is provided as a migration aid and may be discontinued in future releases. Users retaining existing httpx‑aiohttp integrations can install the httpx‑aiohttp package and inject its legacy client, but the recommended path is to adopt openai[aiohttp] and DefaultAioHttpClient.

The SDK will continue to support HTTPX2 while planning to phase out legacy HTTPX, encouraging developers to review their client configurations for compatibility.

Source transparency

Publisher
Hacker News
Reliability
high
Published
8/29/2026, 10:00:22 AM
Retrieved
8/29/2026, 10:00:22 AM
Relevance
80%
Confidence
85%
Read original at Hacker News

Botwin's Morning Wire publishes the full source article for reading convenience. Please visit the publisher for the original presentation and any updates.