ChatHuggingFace
This will help you getting started with langchain_huggingface
chat models. For detailed documentation of all ChatHuggingFace
features and configurations head to the API reference. For a list of models supported by Hugging Face check out this page.
Overview
Integration details
Integration details
Class | Package | Local | Serializable | JS support | Package downloads | Package latest |
---|---|---|---|---|---|---|
ChatHuggingFace | langchain-huggingface | ✅ | beta | ❌ |
Model features
Tool calling | Structured output | JSON mode | Image input | Audio input | Video input | Token-level streaming | Native async | Token usage | Logprobs |
---|---|---|---|---|---|---|---|---|---|
✅ | ✅ | ❌ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ❌ |
Setup
To access Hugging Face models you'll need to create a Hugging Face account, get an API key, and install the langchain-huggingface
integration package.
Credentials
Generate a Hugging Face Access Token and store it as an environment variable: HUGGINGFACEHUB_API_TOKEN
.
import getpass
import os
if not os.getenv("HUGGINGFACEHUB_API_TOKEN"):
os.environ["HUGGINGFACEHUB_API_TOKEN"] = getpass.getpass("Enter your token: ")