httpx

Full-featured HTTP client for Python — supports both sync and async APIs, HTTP/1.1 and HTTP/2, connection pooling, timeouts, redirects, authentication, and streaming. httpx features: httpx.Client() for sync, httpx.AsyncClient() for async, identical API for both, HTTP/2 support (http2=True), connection limits, timeout control (connect/read/write/pool), cookie jars, proxy support, SSL verification, streaming responses, multipart upload, custom transports, event hooks, and drop-in requests compatibility for sync usage. Designed for modern async Python including FastAPI test clients.

Evaluated Mar 06, 2026 (0d ago) v0.27.x
Homepage ↗ Repo ↗ Developer Tools python httpx http async http2 requests client
⚙ Agent Friendliness
70
/ 100
Can an agent use this?
🔒 Security
90
/ 100
Is it safe for agents?
⚡ Reliability
88
/ 100
Does it work consistently?

Score Breakdown

⚙ Agent Friendliness

MCP Quality
--
Documentation
92
Error Messages
90
Auth Simplicity
98
Rate Limits
98

🔒 Security

TLS Enforcement
92
Auth Strength
90
Scope Granularity
88
Dep. Hygiene
92
Secret Handling
88

HTTP client. TLS verification enabled by default (verify=True). Do not disable verify=False in production. Authorization headers logged in debug mode — disable in production. Proxy support may expose auth credentials. Timeout configuration critical — no timeout can hang agent indefinitely.

⚡ Reliability

Uptime/SLA
90
Version Stability
88
Breaking Changes
85
Error Recovery
88
AF Security Reliability

Best When

Async Python applications needing HTTP client — httpx is the standard async HTTP client with sync compatibility, ideal for FastAPI services, async agents, and any code needing HTTP/2.

Avoid When

Simple synchronous scripts (use requests), websocket-heavy applications (use websockets), or browser automation (use playwright).

Use Cases

  • Agent async HTTP — async with httpx.AsyncClient() as client: resp = await client.get(url, params=params, timeout=30.0); data = resp.raise_for_status().json() — async requests; agent makes non-blocking HTTP calls in async context; raise_for_status() raises httpx.HTTPStatusError for 4xx/5xx; timeout= applies to full request
  • Agent connection pool — with httpx.Client(limits=httpx.Limits(max_connections=100, max_keepalive_connections=20), timeout=10.0) as client: for url in urls: resp = client.get(url) — pooled sync client; agent reuses connections for multiple requests to same host; context manager ensures pool cleanup; Limits controls concurrency
  • Agent HTTP/2 — async with httpx.AsyncClient(http2=True) as client: resp = await client.get(url) — HTTP/2; agent uses HTTP/2 multiplexing for APIs that support it; requires httpx[http2] extra (pip install httpx[http2]); reduces connection overhead for multiple concurrent requests to same host
  • Agent streaming download — async with httpx.AsyncClient() as client: async with client.stream('GET', url) as resp: async for chunk in resp.aiter_bytes(chunk_size=8192): process(chunk) — streaming; agent downloads large files without loading into memory; aiter_bytes/aiter_text/aiter_lines for different streaming modes
  • Agent auth and headers — client = httpx.Client(base_url='https://api.example.com', headers={'Authorization': f'Bearer {token}'}, auth=httpx.BasicAuth(user, pass)); resp = client.get('/endpoint') — persistent config; agent creates client with base_url and auth applied to all requests; headers merged per-request

Not For

  • Simple scripts without async — for synchronous-only scripts, requests is simpler with more community resources and plugins
  • High-performance websockets — httpx supports websockets but specialized libs (websockets, aiohttp) have better WS support
  • Browser automation — httpx is a raw HTTP client; for JS rendering use playwright or selenium

Interface

REST API
No
GraphQL
No
gRPC
No
MCP Server
No
SDK
Yes
Webhooks
No

Authentication

Methods: none
OAuth: No Scopes: No

No auth — HTTP client library. Supports BasicAuth, DigestAuth, Bearer token via headers, and custom auth flows.

Pricing

Model: open_source
Free tier: Yes
Requires CC: No

httpx is BSD 3-Clause licensed. Free for all use.

Agent Metadata

Pagination
none
Idempotent
Partial
Retry Guidance
Not documented

Known Gotchas

  • Always use context manager for client — httpx.Client() / httpx.AsyncClient() must be closed to release connections; use 'with httpx.Client() as client:' or 'async with httpx.AsyncClient() as client:'; NOT closing causes connection leaks and ResourceWarning; do not use httpx.get() for repeated requests — it creates new client each time
  • raise_for_status() raises on 4xx/5xx — response.raise_for_status() raises httpx.HTTPStatusError; response itself does not raise; agent code: always call raise_for_status() after request unless checking status manually; HTTPStatusError has .response attribute with full response; .response.text for error body
  • Timeout applies to each phase separately — httpx.Timeout(5.0) applies 5s to connect, 5s to read, 5s to write; total request can take 3x timeout; httpx.Timeout(connect=5, read=30, write=10) for fine-grained control; None disables timeout (dangerous for agent code); httpx.Timeout(5.0, pool=1.0) for pool wait
  • HTTP/2 requires extra install — pip install httpx[http2] installs h2 package; just httpx does NOT include HTTP/2; AsyncClient(http2=True) without h2 installed: ImportError; agent code: if HTTP/2 needed, add httpx[http2] to requirements.txt not just httpx
  • Redirects followed by default — follow_redirects=False disables; default follows up to 20 redirects; history accessible via response.history list; agent code that should not follow redirects (webhook validation): set follow_redirects=False explicitly; each redirect is a separate request in history
  • Streaming response must be used as context manager — async with client.stream('GET', url) as response: — MUST be context manager; after context exit, response body closed; agent code: consume entire stream inside context; if stream not consumed fully: aclose() to avoid connection leak; response.read() materializes full body (defeats streaming purpose)

Alternatives

Full Evaluation Report

Comprehensive deep-dive: security analysis, reliability audit, agent experience review, cost modeling, competitive positioning, and improvement roadmap for httpx.

AI-powered analysis · PDF + markdown · Delivered within 30 minutes

$99

Package Brief

Quick verdict, integration guide, cost projections, gotchas with workarounds, and alternatives comparison.

Delivered within 10 minutes

$3

Score Monitoring

Get alerted when this package's AF, security, or reliability scores change significantly. Stay ahead of regressions.

Continuous monitoring

$3/mo

Scores are editorial opinions as of 2026-03-06.

5229
Packages Evaluated
26151
Need Evaluation
173
Need Re-evaluation
Community Powered