OpenAI's Migration to HTTPX: Why They Abandoned the requests Library

OpenAI migrates its Python SDK to HTTPX for async support, HTTP/2, and unified maintenance.
OpenAI has migrated its Python SDK's HTTP layer from requests to HTTPX, driven by the need for native async/await support, HTTP/2 multiplexing, and simplified dependency management. HTTPX's dual sync/async design eliminates the need for separate libraries, while its modern architecture benefits high-concurrency AI applications. This move, mirrored by Anthropic and major AI frameworks, signals a broader paradigm shift in Python networking toward async-first development.
Introduction: A Technical Migration Worth Noting
Recently, OpenAI announced the migration of its Python SDK's underlying HTTP communication layer to HTTPX, a topic that sparked discussion in the tech community on Hacker News (41 upvotes, 15 comments). While this may seem like a mere infrastructure-level technology choice, for the millions of developers calling the OpenAI API daily, understanding the technical rationale behind this change helps us better grasp the evolving trends in modern Python network programming.
This article will analyze the advantages of HTTPX, the motivations behind the migration, and the potential impact on the developer ecosystem from a technical perspective.

What Is HTTPX: The Modern Successor to requests
HTTPX is a modern Python HTTP client library, widely regarded as the successor to the classic requests library. It was developed by the Encode team (the same team that maintains well-known async frameworks like Starlette and Uvicorn), and its design philosophy is better aligned with the needs of contemporary Python applications.
It's worth noting that the Encode team plays a pivotal role in Python's async web ecosystem. Starlette is a lightweight ASGI (Asynchronous Server Gateway Interface) framework that provides the underlying foundation for higher-level frameworks like FastAPI; Uvicorn is currently the most popular ASGI server implementation, built on uvloop and httptools with excellent performance. The creation of HTTPX was a natural extension of this team's effort to build a complete async web ecosystem — since the server side had fully embraced async, the client-side library should naturally follow suit. This full-stack async mindset, spanning from server to client, gave HTTPX a more forward-looking architectural vision from the very beginning.
Core Features of HTTPX
The most notable features of HTTPX include:
-
Dual Sync and Async Support: This is its biggest differentiator from
requests. HTTPX provides both a synchronous API nearly identical torequestsand native support for theasync/awaitasynchronous programming model, allowing developers to meet different use-case requirements without switching libraries.To appreciate the significance of this feature, we need to revisit the evolution of async programming in Python. Python introduced the
asynciostandard library in version 3.4 and officially addedasync/awaitsyntax sugar in version 3.5, simplifying async programming from the previously complex patterns based on callbacks or generators to a linear writing style that closely resembles synchronous code. However, a core challenge of async programming is its "contagious" nature — once any part of the call chain uses async, the entire call stack needs to be async, meaning the underlying HTTP client must also provide an async interface. Becauserequestswas designed entirely around a synchronous blocking model, with its internal deep dependency onurllib3's connection pool mechanism unable to directly adapt to theasyncioevent loop, it cannot support async calls through simple wrapping. HTTPX was designed from scratch to treat both sync and async as first-class citizens, providing both synchronous and asynchronous transport implementations through thehttpcoreunderlying transport library, making the upper-layer API switch nearly seamless. -
HTTP/2 Support: Unlike
requests, which only supports HTTP/1.1, HTTPX can leverage HTTP/2 features like multiplexing to deliver performance improvements in high-concurrency scenarios.HTTP/2 (also known as h2) is a major upgrade to the HTTP protocol, standardized by the IETF in 2015. Compared to HTTP/1.1, it introduces several key improvements: Multiplexing allows multiple requests/responses to be sent and received simultaneously over a single TCP connection, completely solving the "head-of-line blocking" problem in HTTP/1.1 — where requests on the same connection must be queued and processed sequentially, typically forcing browsers to open 6-8 parallel connections to improve concurrency. Additionally, HTTP/2 supports header compression (HPACK), which maintains a dynamic table to avoid repeatedly transmitting identical request headers — particularly effective for scenarios involving frequent API calls where each request carries similar authentication headers and content-type headers. For the typical usage pattern of the OpenAI API — numerous small JSON requests paired with potentially lengthy streaming responses — HTTP/2 multiplexing can significantly reduce TCP connection establishment overhead, while header compression reduces bandwidth waste from redundant authentication information.
-
Comprehensive Type Annotations: Modern Python projects increasingly prioritize type safety, and HTTPX provides complete type hints that work well with static analysis tools like
mypy. -
Connection Pooling and Timeout Control: Offers more granular and intuitive connection management and timeout configuration.
Why OpenAI Chose to Migrate from requests to HTTPX
For a foundational library like the OpenAI SDK that serves a massive number of developers, the choice of HTTP client directly impacts performance, maintainability, and user experience.
Async Capability as the Key Driver
A defining characteristic of AI applications is their I/O-intensive nature — significant time is spent waiting for network requests carrying model inference results. The traditional synchronous request model is inefficient when handling concurrent calls, while async programming can significantly boost throughput. The official OpenAI SDK needs to provide both a synchronous client (OpenAI) and an async client (AsyncOpenAI), and HTTPX's dual-mode design perfectly fits this requirement, eliminating the need to maintain two different underlying libraries for the two interfaces.
Reducing Dependencies and Unifying Maintenance
Previously, supporting both sync and async typically required introducing two libraries — requests (sync) plus aiohttp (async) — which not only increased dependency complexity but also made it difficult to unify code logic. After migrating to HTTPX, OpenAI can cover both scenarios with a single library, reducing maintenance costs and minimizing the risk of dependency conflicts in user environments.
A deeper explanation of the respective roles of requests and aiohttp is warranted here. requests was released by Kenneth Reitz in 2011, and its "HTTP for Humans" design philosophy fundamentally changed how the Python community approached HTTP programming. Before requests, developers had to work directly with the standard library's urllib/urllib2, which had cumbersome and error-prone interfaces. With its exceptionally elegant API design, requests quickly became one of the most downloaded third-party libraries in the Python ecosystem, still exceeding 300 million downloads per month. However, the architectural foundation of requests — the synchronous blocking I/O model — gradually became a bottleneck as Python's async programming gained momentum. aiohttp emerged as a product of the async era, built on asyncio to provide high-performance async HTTP client and server implementations. But aiohttp's API style differs significantly from requests (e.g., requiring explicit session lifecycle management, different exception type hierarchies, etc.), making it quite painful to maintain both sync and async codebases simultaneously. The elegance of HTTPX lies in the fact that its synchronous API is almost fully compatible with requests (even featuring similar Response object attributes and method naming), while its async API only requires adding the await keyword before method calls. Both share the same parameter system and behavioral semantics, allowing SDK maintainers to cover both execution modes with nearly identical code logic.
Community Discussion: How Developers View This Migration
In the Hacker News discussion, developers expressed perspectives from various angles on this migration.
Stability and Compatibility Concerns
Some developers focused on whether the migration would introduce breaking changes. As a widely integrated SDK, any underlying library swap could affect existing application behavior — things like exception types, retry logic, and proxy configuration details. This kind of infrastructure migration typically requires thorough backward compatibility handling and comprehensive migration documentation.
HTTPX Maturity Discussion
Although HTTPX is quite mature and adopted by numerous projects, some conservative developers remain cautious about its reliability in edge cases compared to requests, which has over a decade of battle-tested history. However, with mainstream framework ecosystems like FastAPI extensively using HTTPX, these concerns are gradually fading.
The rise of FastAPI provides important context for understanding this ecosystem shift. FastAPI was released by Sebastián Ramírez in 2018, built on Starlette (also by the Encode team) and Pydantic. With automatic API documentation generation, type-annotation-based data validation, and async performance comparable to Node.js and Go, it quickly became the fastest-growing project in the Python web framework space, with over 75,000 GitHub stars. FastAPI's official documentation recommends HTTPX as the testing client (via TestClient), and its built-in httpx.AsyncClient is the standard tool for async integration testing. This deep integration means that any team building backend services with FastAPI is already relying on HTTPX in their daily development and testing workflows. As more and more AI application backends choose FastAPI as their service framework (its async characteristics are particularly well-suited for handling long-running large model inference requests), having HTTPX simultaneously serve as the SDK's underlying HTTP client creates a highly consistent and thoroughly validated technology stack.
Practical Impact on Developers
Transparent and Seamless for Most Developers
For the vast majority of developers calling the OpenAI API through the official SDK, this migration is transparent — you don't need to modify any business code, as the SDK handles all HTTP communication details internally. This is precisely the value of good abstraction design.
Performance Gains in High-Concurrency Scenarios
For high-concurrency scenarios (such as batch request processing or building AI Agent systems), the connection reuse and HTTP/2 support brought by HTTPX can deliver tangible performance improvements. Using the AsyncOpenAI async client combined with asyncio, developers can process large volumes of API calls concurrently with greater efficiency.
Specifically, in AI Agent systems, a typical workflow may involve multi-turn conversations, tool calls, and parallel sub-task dispatch. For example, a ReAct (Reasoning + Acting) architecture Agent might need to simultaneously call a search API, database queries, and multiple LLM inference endpoints within a single reasoning cycle. In synchronous mode, these requests can only execute serially, with total latency equal to the sum of all request latencies; in async mode, using asyncio.gather() or asyncio.TaskGroup, these requests can be dispatched in parallel, with total latency determined only by the slowest request. Combined with HTTPX's HTTP/2 multiplexing, these parallel requests can even be completed over a single TCP connection, further reducing connection establishment and TLS handshake overhead. For production-grade AI applications that need to complete complex reasoning chains within second-level response times, the significance of this performance optimization cannot be overlooked.
A Trendsetting Signal for Technology Choices
As an industry benchmark, OpenAI's technology choices often serve as a trendsetter. This migration also sends a signal to the community: when building modern Python network applications, HTTPX is becoming the default recommended choice. If you're designing a library or service that needs to support both sync and async, consider following this practice.
In fact, OpenAI is not the only heavyweight project making this choice. Anthropic's Python SDK is also built on HTTPX, and mainstream AI orchestration frameworks like LangChain and LlamaIndex widely use HTTPX in their HTTP call layers. This industry-wide collective migration trend marks a paradigm shift in Python network programming similar to the one from urllib to requests years ago — only this time, the driving force comes from the widespread adoption of async programming and the rigid demand of AI applications for high-concurrency I/O.
Conclusion
While OpenAI's migration to HTTPX is an underlying technical decision, it reflects the overall direction of evolution in the Python ecosystem: async-first, type-safe, unified abstraction. With its modern design, HTTPX is gradually replacing requests as the de facto standard for the next generation of Python HTTP clients.
For developers, this reminds us to consider a library's long-term maintainability and support for future programming paradigms when making technology choices. For AI application developers, understanding the communication mechanisms underlying the SDK also helps make better architectural decisions in high-concurrency, high-performance scenarios.
Related articles

vLLM v0.29.0rc4 Released: Fixing the TRT-LLM Inference Synchronization Bottleneck Explained
Deep dive into vLLM v0.29.0rc4: fixing unnecessary GPU sync in TRT-LLM ragged prefill to eliminate CPU-GPU overhead and boost inference throughput.

PyTorch Conference 2026: Hardware Acceleration and Compute Infrastructure Outlook
In-depth analysis of PyTorch Conference 2026 hardware acceleration core topics, covering heterogeneous chip adaptation, compilation stack evolution, torch.compile optimization, and distributed compute scheduling, examining future trends and industry impact of AI compute infrastructure.

OpenAI and Cursor Part Ways as Anthropic Seizes the Opportunity in AI Coding Market
OpenAI's partnership with AI coding tool Cursor shows cracks as Anthropic co-founder publicly seizes the opportunity. Deep dive into the power dynamics between model providers and applications, and how multi-model architecture trends are reshaping the AI coding ecosystem.