huggingface-tool-builder

作者: huggingface

Use this skill when the user wants to build tool/scripts or achieve a task where using data from the Hugging Face API would help. This is especially useful…

npx skills add https://github.com/huggingface/skills --skill huggingface-tool-builder

Hugging Face API Tool Builder

Your purpose is now is to create reusable command line scripts and utilities for using the Hugging Face API, allowing chaining, piping and intermediate processing where helpful. You can access the API directly, as well as use the hf command line tool. Model and Dataset cards can be accessed from repositories directly.

Script Rules

Make sure to follow these rules:

  • Scripts must take a --help command line argument to describe their inputs and outputs
  • Non-destructive scripts should be tested before handing over to the User
  • Shell scripts are preferred, but use Python or TSX if complexity or user need requires it.
  • IMPORTANT: Use the HF_TOKEN environment variable as an Authorization header. For example: curl -H "Authorization: Bearer ${HF_TOKEN}" https://huggingface.co/api/. This provides higher rate limits and appropriate authorization for data access.
  • Investigate the shape of the API results before commiting to a final design; make use of piping and chaining where composability would be an advantage - prefer simple solutions where possible.
  • Share usage examples once complete.

Be sure to confirm User preferences where there are questions or clarifications needed.

Sample Scripts

Paths below are relative to this skill directory.

Reference examples:

  • references/hf_model_papers_auth.sh — uses HF_TOKEN automatically and chains trending → model metadata → model card parsing with fallbacks; it demonstrates multi-step API usage plus auth hygiene for gated/private content.
  • references/find_models_by_paper.sh — optional HF_TOKEN usage via --token, consistent authenticated search, and a retry path when arXiv-prefixed searches are too narrow; it shows resilient query strategy and clear user-facing help.
  • references/hf_model_card_frontmatter.sh — uses the hf CLI to download model cards, extracts YAML frontmatter, and emits NDJSON summaries (license, pipeline tag, tags, gated prompt flag) for easy filtering.

Baseline examples (ultra-simple, minimal logic, raw JSON output with HF_TOKEN header):

  • references/baseline_hf_api.sh — bash
  • references/baseline_hf_api.py — python
  • references/baseline_hf_api.tsx — typescript executable

Composable utility (stdin → NDJSON):

  • references/hf_enrich_models.sh — reads model IDs from stdin, fetches metadata per ID, emits one JSON object per line for streaming pipelines.

Composability through piping (shell-friendly JSON output):

  • references/baseline_hf_api.sh 25 | jq -r '.[].id' | references/hf_enrich_models.sh | jq -s 'sort_by(.downloads) | reverse | .[:10]'
  • references/baseline_hf_api.sh 50 | jq '[.[] | {id, downloads}] | sort_by(.downloads) | reverse | .[:10]'
  • printf '%s\n' openai/gpt-oss-120b meta-llama/Meta-Llama-3.1-8B | references/hf_model_card_frontmatter.sh | jq -s 'map({id, license, has_extra_gated_prompt})'

High Level Endpoints

The following are the main API endpoints available at https://huggingface.co

/api/datasets
/api/models
/api/spaces
/api/collections
/api/daily_papers
/api/notifications
/api/settings
/api/whoami-v2
/api/trending
/oauth/userinfo

Accessing the API

The API is documented with the OpenAPI standard at https://huggingface.co/.well-known/openapi.json.

IMPORTANT: DO NOT ATTEMPT to read https://huggingface.co/.well-known/openapi.json directly as it is too large to process.

IMPORTANT Use jq to query and extract relevant parts. For example,

Command to Get All 160 Endpoints

curl -s "https://huggingface.co/.well-known/openapi.json" | jq '.paths | keys | sort'

Model Search Endpoint Details

curl -s "https://huggingface.co/.well-known/openapi.json" | jq '.paths["/api/models"]'

You can also query endpoints to see the shape of the data. When doing so constrain results to low numbers to make them easy to process, yet representative.

Using the HF command line tool

The hf command line tool gives you further access to Hugging Face repository content and infrastructure.

❯ hf --help
Usage: hf [OPTIONS] COMMAND [ARGS]...

  Hugging Face Hub CLI

Options:
  --help                Show this message and exit.

Commands:
  auth                 Manage authentication (login, logout, etc.).
  buckets              Commands to interact with buckets.
  cache                Manage local cache directory.
  collections          Interact with collections on the Hub.
  datasets             Interact with datasets on the Hub.
  discussions          Manage discussions and pull requests on the Hub.
  download             Download files from the Hub.
  endpoints            Manage Hugging Face Inference Endpoints.
  env                  Print information about the environment.
  extensions           Manage hf CLI extensions.
  jobs                 Run and manage Jobs on the Hub.
  models               Interact with models on the Hub.
  papers               Interact with papers on the Hub.
  repos                Manage repos on the Hub.
  skills               Manage skills for AI assistants.
  spaces               Interact with spaces on the Hub.
  sync                 Sync files between local directory and a bucket.
  upload               Upload a file or a folder to the Hub.
  upload-large-folder  Upload a large folder to the Hub.
  version              Print information about the hf version.
  webhooks             Manage webhooks on the Hub.

The hf CLI command has replaced the now deprecated huggingface-cli command.

來自 huggingface 的更多技能

Hugging Face Cli
huggingface
Execute Hugging Face Hub operations using the `hf` CLI. Use when the user needs to download models/datasets/spaces, upload files to Hub repositories, create repos, manage local cache, or run compute jobs on HF infrastructure. Covers authentication, file transfers, repository creation, cache operations, and cloud compute.
official
Hugging Face Datasets
huggingface
在 Hugging Face Hub 上建立與管理資料集。支援初始化儲存庫、定義配置/系統提示、串流更新資料列,以及基於 SQL 的資料集查詢/轉換。設計與 HF MCP 伺服器搭配使用,以實現完整的資料集工作流程。
official
Hugging Face Evaluation
huggingface
在 Hugging Face 模型卡中新增與管理評估結果。支援從 README 內容中提取評估表格、從 Artificial Analysis API 匯入分數,以及使用 vLLM/lighteval 執行自訂模型評估。可搭配 model-index 中繼資料格式使用。
official
Hugging Face Jobs
huggingface
在 Hugging Face Jobs 基礎架構上執行任何工作負載。涵蓋 UV 腳本、基於 Docker 的工作、硬體選擇、成本估算、使用令牌進行身份驗證、機密管理、超時配置以及結果持久化。專為通用計算工作負載設計,包括數據處理、推理、實驗、批次作業以及任何基於 Python 的任務。
official
Hugging Face Model Trainer
huggingface
使用 TRL(Transformer 強化學習)在 Hugging Face Jobs 基礎設施上訓練或微調語言模型。涵蓋 SFT、DPO、GRPO 及獎勵模型訓練方法,以及用於本地部署的 GGUF 轉換。包含資料集準備、硬體選擇、成本估算與模型持久化的指導。
official
Hugging Face Paper Publisher
huggingface
在 Hugging Face Hub 上發佈與管理研究論文。支援建立論文頁面、將論文連結至模型/資料集、聲明作者身份,以及生成基於 Markdown 的專業研究文章。
official
Hugging Face Tool Builder
huggingface
使用 Hugging Face API 建立可重複使用的腳本與工具。適用於串接或組合 API 呼叫,或需要重複執行/自動化的任務。建立可重複使用的命令列腳本,從 Hugging Face Hub 擷取、豐富或處理資料。
official
Hugging Face Trackio
huggingface
Track and visualize ML training experiments with Trackio. Use when logging metrics during training (Python API) or retrieving/analyzing logged metrics (CLI). Supports real-time dashboard visualization, HF Space syncing, and JSON output for automation.
official