huggingface/huggingface.js
Use Hugging Face with JavaScript
What it solves
This project provides a comprehensive set of JavaScript and TypeScript libraries that allow developers to programmatically interact with the Hugging Face ecosystem. It eliminates the need to write raw API calls to manage models, datasets, and spaces, and provides a streamlined way to integrate AI models into web and Node.js applications.
How it works
The project is organized as a collection of specialized packages:
- @huggingface/hub: Handles repository management, including creating, deleting, and uploading/downloading files to the Hub.
- @huggingface/inference: Provides a client to call over 100,000 serverless Inference Providers or dedicated Inference Endpoints for tasks like chat completion, text-to-image, and translation.
- @huggingface/mcp-client: Implements a Model Context Protocol (MCP) client and a small agent library for tool-using AI agents.
- @huggingface/tiny-agents: A model-agnostic library for building AI agents capable of using tools.
- @huggingface/gguf & @huggingface/dduf: Parsers for GGUF and DDUF file formats used in ML models.
- @huggingface/jinja: A minimalistic implementation of the Jinja templating engine for ML chat templates.
- @huggingface/ollama-utils: Utilities for maintaining compatibility between Ollama and Hugging Face Hub models.
Who it’s for
JavaScript and TypeScript developers building AI-powered applications in modern browsers, Node.js (>=18), Bun, or Deno.
Highlights
- Multi-runtime support: Works across browsers, Node.js, Bun, and Deno without polyfills.
- Broad model access: Easy access to thousands of models via serverless or dedicated endpoints.
- @huggingface/inference: Supports streaming chat completions and multimodal inputs.
- Agentic capabilities: Includes tools for building AI agents via the MCP client and tiny-agents library.