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

# Hugging Face Hub

The Nebuly SDK enables you to monitor all the requests made to:

* [Single call to HF Hub Conversational models](#conversational-models)
* [Single call to HF Hub Text Generation models](#text-generation-models)
* [Chain of calls to HF models](#track-traces)

<Note>
  Both of them are supported also when using `async` mode.
  Text Generation models are supported also when using `stream` mode.
</Note>

The process is straightforward, you just need to:

* initialize the SDK with your API key
* include the `user_id` in your original HF Hub method calls.

You can then use the platform to analyze the results and get insights about your LLM users.

### Conversational Models

<Tabs>
  <Tab title="Python">
    ```python theme={null}
    import nebuly

    nebuly.init(api_key="<YOUR_NEBULY_API_KEY>")

    from huggingface_hub import InferenceClient
    client = InferenceClient()
    output = client.conversational(
        "What's the meaning of life?",
        # ... other optional hf hub kwargs
        # Nebuly additional kwargs
        user_id="<YOUR_USER_ID>",
    )
    ```
  </Tab>
</Tabs>

You can find a detailed explanation of the allowed nebuly additional keyword arguments below:

<ParamField path="user_id" type="string" required>
  An id or username uniquely identifying the end-user. We recommend hashing their username or email address, in order to avoid sending us any identifying information.
</ParamField>

<ParamField path="nebuly_tags" type="dict">
  Tag user interactions by adding key-value pairs using this parameter. Each key represents the tag name, and the corresponding value is the tag value.

  For example, if you want to tag an interaction with the model version used to reply to user input, provide it as an argument for nebuly\_tags, e.g. `{"version": "v1.0.0"}`. You have the flexibility to define custom tags, making them available as potential filters on the Nebuly platform.
</ParamField>

<ParamField path="nebuly_api_key" type="string">
  You can use this field to temporarily override the Nebuly API key for the selected model call. The interaction will be stored in the project associated with the provided API key.
</ParamField>

### Text Generation Models

<Tabs>
  <Tab title="Python">
    ```python theme={null}
    import nebuly

    nebuly.init(api_key="<YOUR_NEBULY_API_KEY>")

    from huggingface_hub import InferenceClient
    client = InferenceClient()

    output = client.text_generation(
        "When was Einstein born?",
        # ... other optional hf hub kwargs
        # Nebuly additional kwargs
        user_id="<YOUR_USER_ID>",
    )
    ```
  </Tab>
</Tabs>

You can find a detailed explanation of the allowed nebuly additional keyword arguments below:

<ParamField path="user_id" type="string" required>
  An id or username uniquely identifying the end-user. We recommend hashing their username or email address, in order to avoid sending us any identifying information.
</ParamField>

<ParamField path="nebuly_tags" type="dict">
  Tag user interactions by adding key-value pairs using this parameter. Each key represents the tag name, and the corresponding value is the tag value.

  For example, if you want to tag an interaction with the model version used to reply to user input, provide it as an argument for nebuly\_tags, e.g. `{"version": "v1.0.0"}`. You have the flexibility to define custom tags, making them available as potential filters on the Nebuly platform.
</ParamField>

<ParamField path="nebuly_api_key" type="string">
  You can use this field to temporarily override the Nebuly API key for the selected model call. The interaction will be stored in the project associated with the provided API key.
</ParamField>

### Track Traces

To track your huggingface traces we currently expose two different methodologies:

* The chain of models: you can use the context manager integration built in in the nebuly SDK to catch all the model calls. More information can be found in the [chain of models](/tracking/sdk/python/integrations/chain-of-models) section.
* Raw endpoints: you can directly use the exposed APIs to send the raw interactions and traces to the nebuly platform.
  You can find an example of usage of the endpoint [here](/tracking/sdk/python/integrations/raw-endpoints), while the formal endpoint definition is available [here](/tracking/api-reference/events/post-events-interaction-with-trace-v1).
