hf discussions accepts image, video, and audio attachments
Introduced 2026-10-22 · score 0.99
HOW TO USE IT
When creating or updating a Hub discussion or pull request with media, upload each file with `--attach` and use its returned URL in the body; matching `` references are replaced, and other files are appended. For Python, call `HfApi.upload_attachment(path)` and embed its returned URL.
hf discussions create <owner>/<repo> --title "Fix rendering" --pr --body "Before: " --attach ./before.png --attach "./after.png#After the fix"from huggingface_hub import HfApi
api = HfApi()
url = api.upload_attachment("<path-to-media-file>")
api.comment_discussion("<owner>/<repo>", <discussion-number>, f"")WHY THIS HELPS
Attach media when creating or updating a Hub discussion or pull request with a description or comment.
BEFORE THIS CHANGE
The release note says this required calling an undocumented Hub endpoint by hand.
REQUIREMENTS AND LIMITATIONS
- Version: v2.3.0
- --attach FILE[#alt text]: Repeatable attachment file path; optional `#alt text` supplies image alt text.
- --pr: Create a pull request with `hf discussions create`.
- HfApi.upload_attachment(path): path (required): Local media file path; the method returns a URL for embedding.
- HfApi.comment_discussion(repo_id, discussion_num, comment) (required): Repository ID, discussion number, and comment body; the example embeds the returned attachment URL in the body.
- Prerequisite: Use `huggingface_hub` v2.3.0 or later for the documented change.
- `HfApi.upload_attachment(path)` uploads an image, video, or audio file.
- CLI attachment behavior applies to `hf discussions create` (including `--pr`), `comment`, and `edit.
FIRST-PARTY EVIDENCE
Check the installed version and the source before using it. Entry JSON