Skip to content

gateway: serve the HF /api/ subset (revision, tree) so snapshot_download works against a namespace host #2617

Open

Description

@thiras

Follow-up to #2593 (public gateway) and the HF_ENDPOINT shim.

Today. https://<ns>.<host> serves GET|HEAD /<repo>/resolve/<rev>/<file> with X-Repo-Commit, ETag/X-Linked-Etag and X-Linked-Size, so hf_hub_download works. snapshot_download, HfApi.model_info, list_repo_files and the transformers/datasets loaders that call them first ask /api/models/<repo>/revision/<rev> (and /api/datasets/...) and /api/models/<repo>/tree/<rev>?recursive=true, which the gateway does not serve (adr/appendix-gateway.md § HF_ENDPOINT says so).

Ask. Serve the read-only /api/ subset from the bundle manifest: revision/<rev> returning {"sha": <commit>, "siblings": [{"rfilename": ...}], ...} and tree/<rev> returning the entries under <repo>/ with path, size, oid/lfs.oid (the entry hash), paginated as the hub does. Same revision rule as resolve (main or the commit); 404 otherwise. Cheap: the manifest is cached already. Decide what oid is (BLAKE3 hex is not a git blob sha; #2595 may give a SHA-256 alias).

Why. snapshot_download is how most model code fetches a repo; without /api/ a HF_ENDPOINT pointed at the gateway fails before the first file.

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    • Status
      Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions