HuggingFace.js

Utilities to use the Hugging Face hub API

README


huggingface javascript library logo


Hugging Face JS libraries


This is a collection of JS libraries to interact with the Hugging Face API, with TS types included.

- @huggingface/hub: Interact with huggingface.co to create or delete repos and commit / download files
- @huggingface/inference: Use the Inference API to make calls to 100,000+ Machine Learning models!

With more to come, like @huggingface/endpoints to manage your HF Endpoints!

We use modern features to avoid polyfills and dependencies, so the libraries will only work on modern browsers / Node.js >= 18 / Bun / Deno.

The libraries are still very young, please help us by opening issues!

Installation


From NPM


To install via NPM, you can download the libraries as needed:

  1. ```bash
  2. npm install @huggingface/hub
  3. npm install @huggingface/inference
  4. ```

Then import the libraries in your code:

  1. ```ts
  2. import { createRepo, commit, deleteRepo, listFiles } from "@huggingface/hub";
  3. import { HfInference } from "@huggingface/inference";
  4. import type { RepoId, Credentials } from "@huggingface/hub";
  5. ```

From CDN or Static hosting

You can run our packages with vanilla JS, without any bundler, by using a CDN or static hosting. Using [ES modules](https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-deep-dive/), i.e. `