> ## 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.

# Interaction API

The Interaction API lets you send user interactions directly to the Nebuly platform.

<ParamField body="interaction" type="object" required>
  <Expandable title="properties" defaultOpen>
    <ParamField path="conversation_id" type="string" initialValue="conversation_id" required>
      The conversation id of the interaction. This parameter can be used to enforce interactions to be grouped by a specific conversation.
    </ParamField>

    <ParamField path="input" type="string" initialValue="input" required>
      The user input in the interaction.
    </ParamField>

    <ParamField path="output" type="string" initialValue="output" required>
      The LLM output in the interaction (the text shown to the user as assistant response).
    </ParamField>

    <ParamField path="time_start" type="string" initialValue="2024-01-01" required>
      The start time of the call to the LLM. You can approximate this to the time when the user sends the interaction. The accepted format is the `ISO 8601`.

      Example: `2023-12-07T15:00:00.000Z`
    </ParamField>

    <ParamField path="time_end" type="string" initialValue="2024-01-01" required>
      The end time of the call to the LLM. This is when the user receives the full answer from the model. The accepted format is the `ISO 8601`.

      Example: `2023-12-07T15:00:00.000Z`
    </ParamField>

    <ParamField path="end_user" 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="hide_content" type="boolean" default="false">
      Boolean flag to hide the content of the interaction (input and output) in the Nebuly platform. If set to true, only metadata and traces will be visible.
    </ParamField>

    <ParamField body="tags" type="object">
      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.

      <Expandable title="Tags examples">
        <ParamField path="country" type="string" default="US">
          The end user's country.
        </ParamField>

        <ParamField path="department" type="string" default="Finance">
          The end user's department.
        </ParamField>

        <ParamField path="age" type="string" default="20-30">
          The end user's age group.
        </ParamField>
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="user_feedback" type="object[]">
  A list of feedback actions provided by the end-user during or after the interaction.

  <Expandable title="properties" defaultOpen>
    <ParamField path="slug" type="string" initialValue="thumbs_down" required>
      The type of action. Accepted values include:

      * `thumbs_up`
      * `thumbs_down`
      * `copy_input`
      * `copy_output`
      * `paste`
      * `comment`
      * `regenerate`
      * `edit`
      * `rating`
    </ParamField>

    As optional extra parameters is possible to include:

    * text (string, optional): textual feedback associated with the action (if applicable).
    * value (integer, optional): only used for the `rating` action to capture a numerical score.

    **Example:**

    ```json theme={null}
    "user_feedback": [
    {
        "slug": "thumbs_up",
        "text": "Very helpful response!"
    },
    {
        "slug": "comment",
        "text": "Can you explain more about this?"
    },
    {
        "slug": "rating",
        "value": 4,
        "text": "Pretty good!"
    },
    {
        "slug": "regenerate"
    }
    ]
    ```
  </Expandable>
</ParamField>

<ParamField body="traces" type="object[]" required>
  The full trace of your LLM agent or chain.

  <Tabs>
    <Tab title="LLMTrace">
      <Expandable title="properties">
        <ParamField path="model" type="string" required>
          The LLM used.
        </ParamField>

        <ParamField path="messages" type="array" required>
          A list of messages from the conversation so far, following the same format used by OpenAI Chat Completion endpoints.

          Each message has two required fields:

          * `role`: the role of who is sending the message. Possible values are: **system**, **user**, **assistant**, **tool**.
          * `content`: the content of the message.

          The messages in the list should be ordered according to the conversation's sequence, from the oldest message to the most recent.

          Example:

          ```
          "messages": [
              {
                  "role": "system",
                  "content": "This is a system prompt"
              },
              {
                  "role": "user",
                  "content": "What's the weather like in Turin?"
              },
              {
                  "role": "assistant",
                  "content": "The weather is currently rainy in Turin."
              },
              {
                  "role": "user",
                  "content": "What's the weather like in Rome?"
              }
          ]
          ```
        </ParamField>

        <ParamField path="output" type="string" initialValue="output" required>
          The LLM output message.
        </ParamField>

        <ParamField path="input_tokens" type="integer">
          The number of input tokens.
        </ParamField>

        <ParamField path="output_tokens" type="integer">
          The number of output tokens.
        </ParamField>
      </Expandable>
    </Tab>

    <Tab title="RetrievalTrace">
      <Expandable title="properties">
        <ParamField path="source" type="string" initialValue="rag source name" required>
          The type of data source used, e.g. db\_reader\_tool or vector\_db.
        </ParamField>

        <ParamField path="input" type="string" initialValue="input" required>
          The query to the RAG source.
        </ParamField>

        <ParamField path="outputs" type="string[]" required>
          The RAG source output. It is presented in list format to accommodate multiple outputs for a single query.
        </ParamField>
      </Expandable>
    </Tab>

    <Tab title="EmbeddingTrace">
      Embedding trace details for an LLM.

      <Expandable title="properties">
        <ParamField path="model" type="string" required>
          The model used for embedding.
        </ParamField>

        <ParamField path="input" type="string" required>
          The input text to be embedded.
          Example:

          ```
          "input": "Text to be embedded"
          ```
        </ParamField>

        <ParamField path="input_tokens" type="integer">
          The number of input tokens.
          Example:

          ```
          "input_tokens": 10
          ```
        </ParamField>
      </Expandable>
    </Tab>
  </Tabs>
</ParamField>

<ParamField body="anonymize" type="boolean" default="true">
  Boolean flag to anonymize your data
</ParamField>
