# HuggingFaceEndpoint

> **Class** in `langchain_huggingface`

📖 [View in docs](https://reference.langchain.com/python/langchain-huggingface/llms/huggingface_endpoint/HuggingFaceEndpoint)

Hugging Face Endpoint. This works with any model that supports text generation (i.e. text completion) task.

To use this class, you should have installed the `huggingface_hub` package, and
the environment variable `HUGGINGFACEHUB_API_TOKEN` set with your API token,
or given as a named parameter to the constructor.

## Signature

```python
HuggingFaceEndpoint()
```

## Description

**Example:**

```python
# Basic Example (no streaming)
model = HuggingFaceEndpoint(
    endpoint_url="http://localhost:8010/",
    max_new_tokens=512,
    top_k=10,
    top_p=0.95,
    typical_p=0.95,
    temperature=0.01,
    repetition_penalty=1.03,
    huggingfacehub_api_token="my-api-key",
)
print(model.invoke("What is Deep Learning?"))

# Streaming response example
from langchain_core.callbacks.streaming_stdout import StreamingStdOutCallbackHandler

callbacks = [StreamingStdOutCallbackHandler()]
model = HuggingFaceEndpoint(
    endpoint_url="http://localhost:8010/",
    max_new_tokens=512,
    top_k=10,
    top_p=0.95,
    typical_p=0.95,
    temperature=0.01,
    repetition_penalty=1.03,
    callbacks=callbacks,
    streaming=True,
    huggingfacehub_api_token="my-api-key",
)
print(model.invoke("What is Deep Learning?"))

# Basic Example (no streaming) with Mistral-Nemo-Base-2407 model using a third-party provider (Novita).
model = HuggingFaceEndpoint(
    repo_id="mistralai/Mistral-Nemo-Base-2407",
    provider="novita",
    max_new_tokens=100,
    do_sample=False,
    huggingfacehub_api_token="my-api-key",
)
print(model.invoke("What is Deep Learning?"))
```

## Extends

- `LLM`

## Properties

- `endpoint_url`
- `repo_id`
- `provider`
- `huggingfacehub_api_token`
- `max_new_tokens`
- `top_k`
- `top_p`
- `typical_p`
- `temperature`
- `repetition_penalty`
- `return_full_text`
- `truncate`
- `stop_sequences`
- `seed`
- `inference_server_url`
- `timeout`
- `streaming`
- `do_sample`
- `watermark`
- `server_kwargs`
- `model_kwargs`
- `model`
- `client`
- `async_client`
- `task`
- `model_config`

## Methods

- [`build_extra()`](https://reference.langchain.com/python/langchain-huggingface/llms/huggingface_endpoint/HuggingFaceEndpoint/build_extra)
- [`validate_environment()`](https://reference.langchain.com/python/langchain-huggingface/llms/huggingface_endpoint/HuggingFaceEndpoint/validate_environment)

---

[View source on GitHub](https://github.com/langchain-ai/langchain/blob/ee95ad6907f5eab94644183393a20aa2a032bb19/libs/partners/huggingface/langchain_huggingface/llms/huggingface_endpoint.py#L43)