In a Transformers setup using huggingface_hub 1.x, the Hub’s Python HTTP transport is HTTPX. Configure its synchronous client factory before starting the pipeline or model loader:

import httpx
from huggingface_hub import set_client_factory

def make_hub_client():
    return httpx.Client(
        proxy='http://proxy.example:8080',
        follow_redirects=True,
        timeout=30,
    )

set_client_factory(make_hub_client)

For permitted public-model downloads, the HTTP proxy list supplies candidates for this HTTP proxy URL. The example uses the 1.0.0 API. Use the client type expected by the installed Hub major version; another generation can use another HTTP library.

For environment-based discovery, set HTTP_PROXY and HTTPS_PROXY before launching Python instead. An HTTP listener can carry requests to HTTPS destinations.

The synchronous factory has a defined scope. Async clients use set_async_client_factory, while Xet transfers use a separate backend that does not consume this Python factory.

Identify the failed stage—Hub metadata, redirected content or Xet transfer—before choosing its configuration. A cached model can skip those requests entirely.

Ũhoro ũhĩtĩte