NousResearch/hermes-agent · error · ImportError
httpx is required for Entra ID bearer auth on Microsoft Foun
Error message
httpx is required for Entra ID bearer auth on Microsoft Foundry Anthropic-style endpoints. It is normally a transitive dependency of the openai/anthropic SDKs.
What it means
build_bearer_http_client() needs httpx to construct the per-request Authorization-injecting client for Foundry Anthropic-style endpoints. httpx is expected as a transitive dependency of the openai/anthropic SDKs; its absence means the environment is unusually stripped (the code even marks the branch 'pragma: no cover').
Source
Thrown at agent/azure_identity_adapter.py:517
typically the result of :func:`build_token_provider`.
``httpx_kwargs`` are forwarded verbatim to ``httpx.Client(...)`` so
callers can attach a ``timeout``, ``transport``, ``proxy``, etc.
Raises ``ImportError`` if ``httpx`` is not installed (it is a
transitive dependency of both ``openai`` and ``anthropic`` SDKs, so
in practice always available when this helper is reached).
"""
if not is_token_provider(token_provider):
raise ValueError(
"build_bearer_http_client requires a zero-arg callable "
"token provider"
)
try:
import httpx
except ImportError as exc: # pragma: no cover — httpx ships with openai/anthropic
raise ImportError(
"httpx is required for Entra ID bearer auth on Microsoft Foundry "
"Anthropic-style endpoints. It is normally a transitive "
"dependency of the openai/anthropic SDKs."
) from exc
def _inject_bearer(request: "httpx.Request") -> None:
try:
token = materialize_bearer_for_http(token_provider)
except ValueError as exc:
# Token provider failed (chain exhausted, token service unreachable,
# az login expired, etc.). Strip any auth headers the SDK
# may have set — including our own placeholder sentinel
# ``entra-id-bearer-via-http-hook`` from
# ``_build_anthropic_client_with_bearer_hook`` — so the
# outbound request hits Azure with NO Authorization rather
# than with the placeholder. Azure returns a clean 401
# "missing auth" that is easier to diagnose than a 401
# against the sentinel string, and the sentinel neverView on GitHub (pinned to c896c09c42)
Solutions
- pip install httpx
- Reinstall the openai/anthropic SDK so transitives are restored: pip install --force-reinstall anthropic
- Recreate the venv from the project's lockfile (uv sync / pip install -e '.').
Example fix
pip install httpx
Defensive patterns
Strategy: validation
Validate before calling
import importlib.util
assert importlib.util.find_spec("httpx") is not None, "httpx missing — pip install httpx" Try / catch
try:
client = build_bearer_http_client(provider)
except ImportError as e:
if "httpx is required" in str(e):
run("pip install httpx"); client = build_bearer_http_client(provider) Prevention
- Do not prune transitive dependencies of the openai/anthropic SDKs.
- Include httpx in Foundry deployment requirement lists.
When it happens
Trigger: Selecting Entra bearer auth on a Foundry Anthropic endpoint in an environment where httpx was never installed alongside the SDKs (agent/azure_identity_adapter.py:517).
Common situations: Minimal dependency set where openai/anthropic were vendored without httpx; dependency pruning tools (pip-autoremove) removed it; corrupted venv.
Related errors
- The 'azure-identity' package is required for Azure AI Foundr
- The 'boto3' package is required for the AWS Bedrock provider
- Expected exported session JSON or JSONL
- File is empty
- Failed to initialize OpenAI client: {e}
AI-assisted analysis of NousResearch/hermes-agent@c896c09c42 (2026-08-14).
Data as JSON: /api/errors/ac94f7f93014a855.
Report an issue: GitHub.