> ## Documentation Index
> Fetch the complete documentation index at: https://sambanova-systems.mintlify.site/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Hugging Face integration guide

[Hugging Face](https://huggingface.co/) is a platform for building, training, and deploying open-source models. You can use SambaNova as an inference provider to access SambaNova models through Hugging Face.

## Prerequisites

Before starting, ensure you have:

* A [SambaCloud](https://cloud.sambanova.ai?utm_source=huggingface\&utm_medium=external\&utm_campaign=cloud_signup) account and API key
* A [Hugging Face](https://huggingface.co/) account

## Setup

<Steps>
  <Step title="Enable SambaNova as an inference provider">
    Go to your Hugging Face account settings, navigate to **Inference Providers**, and enable SambaNova.

    <Frame>
      <img src="https://mintcdn.com/sambanova-systems/LoXMzNQBg50bDH9k/images/docs/integrations/hugging-face/hugging-face-1.png?fit=max&auto=format&n=LoXMzNQBg50bDH9k&q=85&s=84f44f4983a4eedda16f72e95c87b689" alt="Hugging Face inference providers settings with SambaNova enabled" style={{ maxWidth:"100%" }} width="3584" height="1560" data-path="images/docs/integrations/hugging-face/hugging-face-1.png" />
    </Frame>
  </Step>

  <Step title="Add your SambaCloud API key">
    Enter your SambaCloud API key in the provider configuration.

    Get your API key from the [SambaCloud portal](https://cloud.sambanova.ai/apis).

    <Frame>
      <img src="https://mintcdn.com/sambanova-systems/LoXMzNQBg50bDH9k/images/docs/integrations/hugging-face/hugging-face-2.png?fit=max&auto=format&n=LoXMzNQBg50bDH9k&q=85&s=01fb27d80443d6c3392b80308fe00bc5" alt="Hugging Face API key configuration for SambaNova" style={{ maxWidth:"100%" }} width="3540" height="1694" data-path="images/docs/integrations/hugging-face/hugging-face-2.png" />
    </Frame>
  </Step>
</Steps>

## Usage

There are two ways to use Inference APIs:

* **Custom key**: Your requests are sent directly to SambaNova using your own API key. Usage is billed to your SambaNova account.
* **Routed by HF**: Your requests are routed through Hugging Face, so you don't need a separate provider API key. Usage fees are billed to your Hugging Face account.

## Using the Python SDK

The example below demonstrates how to run a model through SambaNova as the inference provider. You can authenticate with your SambaCloud API key.

Make sure you have `huggingface_hub` version `0.28.0` or newer installed.

```python theme={null}
from huggingface_hub import InferenceClient

client = InferenceClient(
    provider="sambanova",
    api_key="your-sambanova-api-key"
)

messages = [
    {
        "role": "user",
        "content": "What is the capital of France?"
    }
]

completion = client.chat.completions.create(
    model="Meta-Llama-3.3-70B-Instruct",
    messages=messages,
    max_tokens=500
)

print(completion.choices[0].message)
```

## Additional resources

* [Hugging Face Inference Providers documentation](https://huggingface.co/docs/inference-providers/index)
