Core HTTP client for HuggingFace Hub API interactions.
Provides authenticated GET, POST, PATCH, PUT, DELETE with:
- Bearer token authentication (with env-var fallback)
- JSON encoding/decoding via Req's built-in middleware
- Pagination via Link headers
- Consistent HubApiError on failures
- Private Hub endpoint support
Configuration
config :huggingface_client,
hub_url: "https://my-enterprise-hub.co",
default_token: "hf_xxx"Environment variable fallback (in order)
HF_TOKEN, HUGGINGFACE_TOKEN, HUGGING_FACE_HUB_TOKEN
Summary
Functions
Builds Authorization header list from a token (or nil/false).
Returns a lazy stream across paginated API responses, following Link headers.
Returns a raw binary chunk stream from an SSE endpoint.
Pipe into HuggingfaceClient.Inference.SSE.parse_stream/1 to decode events.
Functions
Builds Authorization header list from a token (or nil/false).
@spec default_token() :: String.t() | nil
@spec delete(String.t(), String.t() | nil | false, keyword()) :: :ok | {:error, Exception.t()}
@spec get(String.t(), String.t() | nil | false, keyword()) :: {:ok, term()} | {:error, Exception.t()}
@spec hub_url() :: String.t()
@spec paginated_stream(String.t(), String.t() | nil | false, keyword()) :: Enumerable.t()
Returns a lazy stream across paginated API responses, following Link headers.
@spec stream_raw(String.t(), String.t() | nil | false, keyword()) :: Enumerable.t()
Returns a raw binary chunk stream from an SSE endpoint.
Pipe into HuggingfaceClient.Inference.SSE.parse_stream/1 to decode events.