CLI Companion

  • Hugging Face CLI
    • login
    • whoami
    • repo create
    • upload
    • download
    • lfs-enable-largefiles
    • scan-cache
    • delete-cache
  • Hapi CLI
    • new
    • start
    • build
    • test
    • plugin create
    • route add
  • Cloudflared
    • tunnel
    • tunnel run
    • tunnel list
    • tunnel delete
    • access
    • access tcp
    • update

    The `huggingface-cli repo create` command is used to create new repositories (models, datasets, or Spaces) on the Hugging Face Hub directly from your command line.

    Syntax

    bash
    huggingface-cli repo create <repo_id> [--type {model,dataset,space}] [--organization ORGANIZATION] [--private] [--repo-id-file REPO_ID_FILE] [--token TOKEN]

    Arguments

    * `<repo_id>` (positional, required):

    * The ID of the repository you want to create. This will be the name of your repository on the Hugging Face Hub. It typically follows the format `username/repo_name` for personal repositories or `organization/repo_name` for organization repositories. Example: `my-awesome-model` or `my-org/my-new-dataset`.

    * `--type {model,dataset,space}` (optional):

    * Specifies the type of repository to create. If not provided, it defaults to `model`.

    * `model`: For storing machine learning models.

    * `dataset`: For storing datasets.

    * `space`: For creating Hugging Face Spaces (interactive ML apps).

    * `--organization ORGANIZATION` (optional):

    * The ID of the organization under which the repository should be created. If this argument is omitted, the repository will be created under your personal user account. You must be a member of the specified organization to create repositories under it.

    * `--private` (optional):

    * A flag that, if present, creates the repository as a private one. Private repositories are only accessible to you and collaborators you explicitly invite. If this flag is omitted, the repository will be created as public by default.

    * `--repo-id-file REPO_ID_FILE` (optional):

    * Reads the repository ID from a specified file instead of taking it as a command-line argument. This can be useful for automation or when the repo ID is dynamically generated.

    * `--token TOKEN` (optional):

    * Your Hugging Face API token. If not provided, the CLI will look for a token in the environment variables (e.g., `HF_TOKEN`) or in the `~/.cache/huggingface/token` file (after running `huggingface-cli login`).

    Usage Examples

    1. **Create a public model repository under your personal account:**

    bash
    huggingface-cli repo create my-awesome-model

    *This will create a new public model repository named `my-awesome-model` under your authenticated Hugging Face user account.*

    2. **Create a private dataset repository:**

    bash
    huggingface-cli repo create my-private-data --type dataset --private

    *This creates a private dataset repository called `my-private-data` under your personal account. Only you and invited collaborators will be able to access it.*

    3. **Create a public Space repository under an organization:**

    bash
    huggingface-cli repo create my-org/my-cool-space --type space --organization my-org

    *This command creates a public Space repository named `my-cool-space` under the `my-org` organization. You must be a member of `my-org`.*

    4. **Create a private model repository using a specific token:**

    bash
    huggingface-cli repo create another-private-model --private --token hf_YOUR_API_TOKEN_HERE

    *This creates a private model repository `another-private-model` using the provided API token for authentication.*

    Explanation

    `huggingface-cli repo create` is a foundational command for initiating new projects on the Hugging Face Hub. Before using it, ensure you are logged in to the Hugging Face CLI by running `huggingface-cli login`. The command handles the backend creation of the repository, making it ready for you to push content using Git or the Hugging Face `upload` commands. You will typically follow this command by initializing a Git repository locally and pushing your files, or by directly uploading files with `huggingface-cli upload`.