HTTPX
Modern, fully-featured HTTP client for Python with both sync and async APIs. Drop-in replacement for requests with async/await support, HTTP/2, connection pooling, streaming responses, timeout configuration, and HTTPX test client for ASGI apps (FastAPI, Starlette). The modern Python HTTP client for applications needing both sync and async HTTP support.
Score Breakdown
⚙ Agent Friendliness
🔒 Security
BSD 3-Clause licensed. Enforces SSL certificate verification by default (verify=True). Supports client certificates, custom CA bundles. Auth helpers for Bearer, Basic, Digest auth.
⚡ Reliability
Best When
You're building async Python services (FastAPI, async agent workers) and need a modern HTTP client with the same ergonomics as requests but with async/await support.
Avoid When
You're in a fully synchronous codebase with no async requirements — requests is simpler and more widely documented. HTTPX shines in async contexts.
Use Cases
- • Make async HTTP requests in FastAPI agent services using the same API as the synchronous client
- • Build agent HTTP clients with connection pooling and HTTP/2 support for high-performance API consumers
- • Test FastAPI/Starlette agent APIs with HTTPX's TestClient without running an actual server
- • Stream large responses in agent download pipelines without loading full responses into memory
- • Replace requests in existing agent codebases with a drop-in async-capable alternative
Not For
- • Simple one-off scripts where requests is already installed and async isn't needed
- • Browser automation — use Playwright or Selenium for browser-level HTTP interception
- • WebSocket connections — use websockets or aiohttp for WebSocket support
Interface
Authentication
Local library — no authentication required. BSD 3-Clause licensed. Auth is configured per client instance.
Pricing
BSD 3-Clause licensed. Zero cost.
Agent Metadata
Known Gotchas
- ⚠ Must use async with httpx.AsyncClient() as client: context manager for proper connection cleanup — not doing so leaks connections
- ⚠ HTTPX has strict timeout defaults (5 seconds) unlike requests (no timeout) — set httpx.Timeout(30.0) for slow APIs or use None for no timeout
- ⚠ Response content is NOT automatically decoded for streaming — use async for chunk in response.aiter_bytes(): for streaming; response.content for full response
- ⚠ TestClient for ASGI apps: from httpx import Client; from starlette.testclient import TestClient — HTTPX's AsyncClient with ASGITransport for async test patterns
- ⚠ HTTP/2 requires h2 package: pip install httpx[http2] — not included by default; worth enabling for high-concurrency API consumers
- ⚠ follow_redirects defaults to False unlike requests (True) — set follow_redirects=True explicitly if your API uses redirects
Alternatives
Full Evaluation Report
Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for HTTPX.
Scores are editorial opinions as of 2026-03-06.