Comparing
High-level concurrency and networking framework on top of asyncio or Trio
The next generation HTTP client
| Metric | anyio | httpx |
|---|---|---|
| Ecosystem | Python | Python |
| Difficulty | Beginner ✓ | Intermediate |
| Weekly downloads | 0 | 119.1M↑ |
| Latest version | v4.13.0 | v0.28.1 |
| Recipes | 1 | 2↑ |
anyio only
Shared
httpx only
Use anyio when writing an async library or framework that you want to be runtime-agnostic. It's also useful in applications that want trio's structured concurrency model but need to interop with asyncio-based libraries like FastAPI or aiohttp.
Use httpx when building FastAPI or asyncio applications that call external APIs. Also reach for it when you need HTTP/2 support, a requests-compatible API with async support, or a single library that works in both sync and async contexts.
For application code that commits to asyncio (e.g. a FastAPI app), using asyncio directly is simpler — there's no need for the compatibility layer. anyio shines at the library level, not the application level.
For simple synchronous scripts where you already use requests, there's little reason to switch — requests has a larger ecosystem of auth libraries and middleware. For high-volume async scraping at scale, aiohttp's lower-level control may be more efficient.
anyio
httpx