Skip to content
Back to skills

Huggingface Hub Knowledge Patch

ASecurity

Hugging Face Hub

  • 25 stars
  • 0 votes
  • 0 copies
  • 17 views
  • Added September 5, 2026
developmentpythonrustgoapibackendperformance

Works with

  • terminal
  • cli
  • api

Security analysis

A100/100

Pro scans all 6 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add Nevaberry/nevaberry-plugins --skill huggingface-hub-knowledge-patch --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Huggingface Hub Knowledge Patch?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Huggingface Hub Knowledge Patch
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nevaberry-huggingface-hub-knowledge-patch/badge)](https://www.skillsdirectory.com/skills/nevaberry-huggingface-hub-knowledge-patch)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: huggingface-hub-knowledge-patch
description: Hugging Face Hub
version: null
license: MIT
metadata:
  author: Nevaberry
---


# Hugging Face Hub Compatibility

Load this skill when migrating Hub clients or working with downloads, uploads,
repository APIs, authentication, inference, Spaces, jobs, or sandboxes.
The references contain the complete guidance and examples by task.

| Reference | Topics |
| --- | --- |
| [Client Migration and Compatibility](references/client-migration.md) | Removed APIs and CLI commands, HTTP client factories, transport, exceptions, Python support, CLI input |
| [Files, Caches, and Upload Workflows](references/files-cache-uploads.md) | Downloads, revisions, offline behavior, Hub and Xet caches, uploads, filesystem listings, bucket transactions, dataset queries, model files |
| [Inference, Endpoints, and Spaces](references/inference-spaces.md) | Hardware, endpoint deployment, providers, Space resources and OAuth, jobs, metrics, experimental sandboxes and network policies |
| [Repository Writes and Authentication](references/repositories-auth.md) | OpenAPI, endpoints, tokens, gated access, commits, cards, webhooks, discussions, attachments, paper metadata |

## Removed APIs and deprecations

In v1, replace `configure_http_backend` with `set_client_factory` and
`set_async_client_factory`; move per-call `proxies=` settings to the HTTPX client.
`force_filename` was removed: open the path returned by `hf_hub_download`.
Replace `InferenceApi` with `InferenceClient` for synchronous calls or
`AsyncInferenceClient` for asynchronous calls. Deprecated TensorFlow and Keras
utilities were removed; handle serialization and callbacks in the framework,
then publish the resulting files through `HfApi`.

For Python API removals in 2.0:

| API, argument, or operation | Migration |
| --- | --- |
| `upload_large_folder`, `HfApi.upload_large_folder` | Use `upload_folder`. |
| Space duplication | Use `duplicate_repo`. |
| `space_storage` | Pass `space_volumes` to `create_repo` or `duplicate_repo`. |
| `request_space_storage`, `delete_space_storage` | Use `set_space_volumes`, `delete_space_volumes`. |
| `repo_type_and_id_from_hf_id` | Use `parse_hf_uri`. |
| `InferenceEndpointType.PROTECTED` | Use `InferenceEndpointType.AUTHENTICATED`; `create_inference_endpoint(type="protected")` raises `ValueError`. |
| `list_models(model_name=...)` | Pass `search` in place of `model_name`. |
| `text_generation(stop_sequences=...)` | Pass `stop` in place of `stop_sequences`. |
| Boolean `InferenceClient(token=...)` values | Pass a token string or `None`. |

Direct access to `huggingface_hub.constants.INFERENCE_ENDPOINT_IMAGE_KEYS`
raises `AttributeError`; remove dependencies on that constant when building
endpoint image payloads.
Organization API tokens are deprecated: use a personal token whose scope covers
the resource and operation, issued to a user with the required organization role.

In v1, remove the `hf_transfer` extra and `HF_HUB_ENABLE_HF_TRANSFER`.
Set `HF_XET_HIGH_PERFORMANCE=1` to opt into Xet's high-performance transfer mode.

## CLI migrations

For CLI removals in 2.0:

| Removed command or flag | Migration |
| --- | --- |
| `huggingface-cli` | Use `hf`. |
| `hf repo` | Use `hf repos`. |
| `hf repo-files delete` | Use `hf repos delete-files`. |
| `hf upload-large-folder` | Use `hf upload`. |
| `--storage` on `hf repos create` or `hf repos duplicate` | Pass `--volume`. |
| `hf jobs ps` | Use `hf jobs ls`. |
| `hf jobs scheduled ps -f/--filter` | Use `hf jobs scheduled ls` with `--status` or `--label`. |
| `--claude` on `hf skills add` or `hf skills update` | Drop the flag; installation for that client is automatic. |

In 1.30, `-f`/`--filter` on scheduled job listings becomes a no-op with a warning.
`hf jobs scheduled ls` defaults to active jobs; use `--status active|suspended`,
repeatable `-l`/`--label key=value`, or `--name NAME` for `--label name=NAME`.
`HfApi.list_scheduled_jobs` gains a `labels` argument.

## HTTP clients and exception handling

v1 uses HTTPX for Hub requests. Replace `requests.HTTPError` handlers with the Hub
exception appropriate to the operation, or catch `httpx.HTTPError` for HTTPX
failures generally. Version 2.0 uses `httpx2` and `httpcore2` clients and transport
exceptions. In custom factories and HTTP exception handlers, import `httpx` from
`huggingface_hub.utils` to support late 1.x starting at 1.30.0 and 2.x:

```python
from huggingface_hub import set_async_client_factory, set_client_factory
from huggingface_hub.utils import httpx

set_client_factory(httpx.Client)
set_async_client_factory(httpx.AsyncClient)
```

`httpx2` defaults to the operating system certificate store and honors
`SSL_CERT_FILE` and `SSL_CERT_DIR`. Configure logging for `httpx2` and `httpcore2`;
use `authlib>=1.8.0` with the `oauth` extra.
In 2.3.0, handle inference request timeouts with `InferenceTimeoutError`.
Catch `EgressLimitError` for HTTP 402 with the `EgressLimitReached` error code.

## Authentication and repository writes

- `HF_HUB_DISABLE_IMPLICIT_TOKEN=1` makes ordinary Hub reads anonymous by default
  even when a token can be resolved. Pass `token=True` for a private read using
  that token; `token=False` forces anonymous access where supported.
- `HF_TOKEN_PATH` selects the saved token file while preserving cache locations.
  `HF_TOKEN`, when set, takes precedence over that file.
- For HTTP downloads through `/resolve/`, follow redirects and strip the Hub
  `Authorization` header if the origin changes. SDK download methods handle this.
- Gated access checks approval for the token's issuing user. For an inaccessible
  repository returning not-found, check identity, repository type, and token scope.
- On repositories hiding requester identities, use `AccessRequest.request_id`
  with `accept_access_request`, `reject_access_request`, or `cancel_access_request`;
  `username` and `fullname` can be `None`.
- `hf auth revoke` accepts raw tokens without login. Top-level `revoke_tokens([...])`
  sends batches of 1,000; the Hub emails owners and acknowledges existing and unknown
  tokens identically.
- Pass the inspected branch head as `parent_commit` to `HfApi.create_commit`;
  the commit fails if another writer advances the branch before the write.
- Webhook updates require the complete configuration, including settings to retain.

## Downloads, caches, and uploads

- Use `dry_run=True` on `hf_hub_download` or `snapshot_download` to get the download
  plan without transferring file contents.
- `HF_HUB_ETAG_TIMEOUT` controls the metadata wait before falling back to available
  cached state; a short timeout can resolve a mutable branch or tag to an older commit.
- Downloads using `local_dir` store reuse metadata in `.cache/huggingface` inside
  the destination. Exclude that directory when publishing the downloaded tree.
- `snapshot_download(force_download=True)` surfaces failed Hub resolution even
  when a cached snapshot exists.
- Use `hf cache ls`, `hf cache rm`, and `hf cache prune` to inspect entries, remove
  selected entries, and remove unreferenced content. These can leave chunks in the
  separate `HF_XET_CACHE`. Cache revision totals count shared blobs once; the cache
  CLI also deduplicates shared blobs with `--limit` or `--filter`.
- `upload_large_folder` keeps progress in `.cache/huggingface` in the source folder.
  Retry with the same folder and destination; use a staging destination if consumers
  must see files together, since uploads can create multiple commits. For 2.0,
  migrate to `upload_folder` as described above.
- Uploads queued with `run_as_future=True` run in order on the same client. Keep
  the process alive and call `future.result()` to surface upload errors.

## Filesystem listings and bucket transactions

`exists(path, refresh=True)` and `invalidate_cache(path)` clear cached misses for
new repos, branches, or buckets. Refreshed directory listings drop deleted entries;
`ls()` returns an empty list for a newly created empty bucket.
`HfFileSystem(live_follow=True)` opens a background connection per listed bucket
and invalidates affected listing and metadata caches as changes arrive. It defaults
to off and works as an fsspec storage option. Use `refresh=True` for new commits in
model, dataset, and Space repositories.

`HfFileSystem.transaction` uploads staged bucket writes on successful block exit
and discards them if the block raises. Commit uploads files individually and can
leave earlier files uploaded after failure. Repository writes, `rm`, and `cp_file`
raise `NotImplementedError` inside a transaction.

## Endpoints and inference routing

`hf endpoints hardware` lists valid vendor, region, accelerator, instance type,
and instance size combinations. By default it shows hardware the namespace can
deploy on, hourly price per replica, and accelerator quota. The SDK equivalent is
`HfApi().list_inference_endpoints_hardware()`.

`create_inference_endpoint` and `update_inference_endpoint` accept `custom_image`
with a top-level `url` or keyed by API engine name: `vLLM`, `sGLang`, `tgi`, or `tei`.
`hf endpoints deploy` and `hf endpoints update` accept `--engine`,
`--tensor-parallel-size`, and `--data-parallel-size`. vLLM and SGLang default to one
accelerator; configure parallelism for all allocated accelerators on multi-accelerator
instances, where the API rejects the single-accelerator default.

Endpoint creation and updates can return before replicas are ready. Wait for readiness
and handle terminal failures before sending traffic. `scale_to_zero` preserves the
configuration and allows request-triggered cold starts; paused endpoints need resume.
Endpoints returned by `HfApi` use the originating client's token for later operations.

With a Hub token and explicit `provider`, `chat_completion` uses the Hub router's
`/v1/chat/completions` with `model` set to `org/model:provider`. Calls authenticated
with a provider API key go directly to that provider.

## Spaces, jobs, and experimental sandboxes

`suggested_hardware` and `suggested_storage` in README front matter show resource
recommendations; allocate hardware and persistent storage through Space settings or
the Hub API. `preload_from_hub` fetches selected Hub files during builds; pin the
source revision for reproducible rebuild fetches.

Enable Space OAuth with `hf_oauth: true`; configure server credentials separately for
private Hub repository access. Space OAuth always uses S256 PKCE and runs as a public
client with `token_endpoint_auth_method="none"` when `OAUTH_CLIENT_SECRET` is absent.
Cookies are signed with a key derived from `SPACE_SIGNING_SECRET`, which persists across restarts
and replicas; existing users must sign in again after upgrading.

Access wakes sleeping Spaces and can incur a cold start; paused Spaces need explicit
restart. Hardware requests are asynchronous: check runtime state before relying on
requested hardware. Handle enum members and raw strings for `JobStatus.stage` and
`SpaceRuntime.stage`.

In 2.2.0, `hf jobs stats` and `HfApi.fetch_job_metrics` default to the latest sample
per job. Use `-f`/`--follow` or `follow=True` to stream until completion. CLI snapshots
expose raw API metrics with `--format json`, `--format agent`, or `--format quiet`.
`hf jobs run` reconnects to logs until a final stage; Ctrl+C exits the CLI immediately
and leaves the remote job running.

The Sandbox API and CLI are experimental. Share only within the same trust boundary.
`Sandbox.create` and `pool.create` accept `network="none"` to block outbound
connections while retaining volumes, or `network={"allow": [...]}` for selected
CIDRs, IP addresses, or hostnames, with optional ports on individual addresses or
hostnames. The policy covers every sandbox process; creation raises `SandboxError`
if the server cannot enforce it.

Files in this skill

  • SKILL.md10.4 KB
  • coverage.json802 B
  • references/client-migration.md3.5 KB
  • references/files-cache-uploads.md3.5 KB
  • references/inference-spaces.md5 KB
  • references/repositories-auth.md2.3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.