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

# LLM and Generative AI Usage Logs API

[Back to API List](https://koreai.mintlify.site/ai-for-service/apis/automation/api-list)

This API retrieves LLM and Generative AI usage logs for GenAI features.

| Field | Value |
| - | - |
| **Method** | POST |
| **Endpoint** | `https://{{host}}/api/1.1/public/bot/{{botId}}/getLLMUsageLogs?version=2.0` |
| **Content Type** | `application/json` |
| **Authorization** | `auth: {{JWT}}` — See [How to generate the JWT Token](https://koreai.mintlify.site/ai-for-service/apis/automation/api-introduction.md#generating-the-jwt-token). |
| **API Scope** | App Builder: Fetch Gen AI and LLM Usage Logs; Admin Console: API Scopes > Gen AI and LLM Usage Logs |

> [!NOTE]
>
> A single API call supports querying up to 90 days of data and retrieving up to 50 records. Make multiple requests using `skip` and `limit` to retrieve the complete dataset.

## Path Parameters

| Parameter | Required/Optional | Description |
| - | - | - |
| `host` | Required | The environment URL. For example, `https://platform.kore.ai` |
| `botId` | Required | Bot identifier or Stream identifier. Accessible from the [General Settings](https://koreai.mintlify.site/ai-for-service/app-settings.md) page of the bot. |

## Query Parameters

| Parameter | Required/Optional | Description |
| - | - | - |
| `version` | Optional | API version number. For support backward compatibility, the request must include the `version=2.0` in the query parameter. |

## Sample Request version 1.0

```json expandable=true theme={null}
curl --location 'https://{{host}}/api/1.1/public/bot/{{botId}}/getLLMUsageLogs?' \
--header 'auth: {{JWT_TOKEN}}'\
--header 'Content-Type: application/json' \
--data '{
    "dateFrom": "2024-03-07",
    "dateTo": "2024-04-26",
    "limit": "50",
    "skip": "5",
    "isDeveloper": true,
    "channel": ["msteams", "rtm"],
    "featureName": ["Agent Node"],
    "taskId": "dg-d4924db4-xxxx-5b4d-ae51-aa5c7be4xxxx",
    "channelUserIds": ["29:1gmwl6k7ohtdhxxxx7kvu1yiek_qri4grpmd0k_am9dpzwttw"],
    "userIds": ["u-40b3eafc-xxxx-55f2-83e8-cf4d0fbxxxx"],
    "sort": {
        "field": "Time Taken",
        "order": "asc"
    }
}'
```

## Sample Request version 2.0

```json expandable=true theme={null}
curl --location 'https://{{host}}/api/1.1/public/bot/{{botId}}/getLLMUsageLogs?version=2.0' \
--header 'auth: {{JWT_TOKEN}}'\
--header 'Content-Type: application/json' \
--data '{
    "dateFrom": "2024-03-07",
    "dateTo": "2024-04-26",
    "limit": "50",
    "skip": "5",
    "isDeveloper": true,
    "channel": ["msteams", "rtm"],
    "featureName": ["Agent Node"],
    "taskId": "dg-d4924db4-xxxx-5b4d-ae51-aa5c7be4xxxx",
    "channelUserIds": ["29:1gmwl6k7ohtdhxxxx7kvu1yiek_qri4grpmd0k_am9dpzwttw"],
    "userIds": ["u-40b3eafc-xxxx-55f2-83e8-cf4d0fbxxxx"],
    "sort": {
        "field": "Time Taken",
        "order": "asc"
    }
}'
```

## Body Parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `dateFrom` | String | Yes | Start date for retrieving LLM usage logs. Format: `YYYY-MM-DD` |
| `dateTo` | String | Yes | End date for retrieving LLM usage logs. Format: `YYYY-MM-DD` |
| `limit` | Integer | Yes | Maximum number of records to return. |
| `skip` | Integer | No | Number of records to skip before returning results. Used for pagination. |
| `isDeveloper` | Boolean | No | Filters logs generated by developer interactions when set to `true`. |
| `channel` | Array | No | List of channels to filter the logs. Example: `["msteams", "rtm"]`. |
| `featureName` | Array | No | List of feature names to filter the logs. Example: `["Agent Node"]`. |
| `taskId` | String | No | Unique identifier of the task associated with the usage logs. |
| `channelUserIds` | Array | No | List of channel-specific user IDs used to filter logs. |
| `userIds` | Array | No | List of platform user IDs used to filter logs. |
| `sort` | Object | No | Defines the sorting criteria for the results. |
| `sort.field` | String | No | Field used for sorting the results. Example: `Time Taken`. |
| `sort.order` | String | No | Sort order. Supported values: `asc`, `desc`. |

## Sample Response version 1.0

```json expandable=true theme={null}
[
    {
      "promptName": "Default",
      "integration": "OpenAI",
      "startDate": "2024-03-08T06:38:54.008Z",
      "endDate": "2024-03-08T06:38:58.386Z",
      "timeTaken": 4378,
      "statusCode": 200,
      "botId": "st-73bfdb2f-xxxx-55e6-b4c8-3f568a6exxxx",
      "userId": "u-40b3eafc-xxxx-55f2-83e8-cf4d0fb1xxxx",
      "featureName": "GenAI Node",
      "modelName": "GPT-4",
      "channelName": "msteams",
      "description": "Order pizza-GenAINode0002",
      "taskId": "dg-200ad1ff-xxxx-5219-810e-4ee3800dxxxx",
      "status": "Success",
      "payloadDetails": {
        "requestPayload": {
          "model": "gpt-4",
          "temperature": 0.5,
          "maxTokens": 1500,
          "topP": 1,
          "frequencyPenalty": 0,
          "presencePenalty": 0,
          "messages": [
            {
              "role": "system",
              "content": "You are a virtual assistant..."
            },
            {
              "role": "user",
              "content": "Order pizza"
            }
          ]
        },
        "responsePayload": {
          "id": "chatcmpl-90OAYDFFkbjgMxhMxKukwqklT6SWO",
          "object": "chat.completion",
          "created": 1709879934,
          "model": "gpt-4-0613",
          "choices": [
            {
              "index": 0,
              "message": {
                "role": "assistant",
                "content": "{\"bot\":\"I'm sorry, but your message seems incomplete...\"}"
              },
              "finishReason": "stop"
            }
          ],
          "usage": {
            "promptTokens": 614,
            "completionTokens": 74,
            "totalTokens": 688
          }
        },
        "requestTokens": 614,
        "responseTokens": 74
      }
    }
  ]

```

## Sample Response version 2.0

```json expandable=true theme={null}
{
  "moreAvailable": false,
  "result": [
    {
      "promptName": "Default",
      "integration": "OpenAI",
      "startDate": "2024-03-08T06:38:54.008Z",
      "endDate": "2024-03-08T06:38:58.386Z",
      "timeTaken": 4378,
      "statusCode": 200,
      "botId": "st-73bfdb2f-xxxx-55e6-b4c8-3f568a6exxxx",
      "userId": "u-40b3eafc-xxxx-55f2-83e8-cf4d0fb1xxxx",
      "featureName": "GenAI Node",
      "modelName": "GPT-4",
      "channelName": "msteams",
      "description": "Order pizza-GenAINode0002",
      "taskId": "dg-200ad1ff-xxxx-5219-810e-4ee3800dxxxx",
      "status": "Success",
      "payloadDetails": {
        "requestPayload": {
          "model": "gpt-4",
          "temperature": 0.5,
          "maxTokens": 1500,
          "topP": 1,
          "frequencyPenalty": 0,
          "presencePenalty": 0,
          "messages": [
            {
              "role": "system",
              "content": "You are a virtual assistant..."
            },
            {
              "role": "user",
              "content": "Order pizza"
            }
          ]
        },
        "responsePayload": {
          "id": "chatcmpl-90OAYDFFkbjgMxhMxKukwqklT6SWO",
          "object": "chat.completion",
          "created": 1709879934,
          "model": "gpt-4-0613",
          "choices": [
            {
              "index": 0,
              "message": {
                "role": "assistant",
                "content": "{\"bot\":\"I'm sorry, but your message seems incomplete...\"}"
              },
              "finishReason": "stop"
            }
          ],
          "usage": {
            "promptTokens": 614,
            "completionTokens": 74,
            "totalTokens": 688
          }
        },
        "requestTokens": 614,
        "responseTokens": 74
      }
    }
  ],
  "total": 6
}
```

## Response Parameters

| Field | Type | Description |
| - | - | - |
| `moreAvailable` | Boolean | Indicates whether more records are available. `true`: Indicates records are available beyond the current response. `false`: No additional records are available. |
| `result` | Array | Contains the LLM usage log records. |
| `promptName` | String | Name of the prompt used for the request. |
| `integration` | String | Name of the LLM integration used for the request. |
| `startDate` | String | Start time of the request in ISO 8601 format. |
| `endDate` | String | End time of the request in ISO 8601 format. |
| `timeTaken` | Integer | Time taken to process the request, in milliseconds. |
| `statusCode` | Integer | HTTP status code returned for the request. |
| `botId` | String | Unique identifier of the bot. |
| `userId` | String | Unique identifier of the user. |
| `featureName` | String | Name of the feature that triggered the request. |
| `modelName` | String | Name of the LLM model used for the request. |
| `channelName` | String | Name of the channel from which the request originated. |
| `description` | String | Description of the request. |
| `taskId` | String | Unique identifier of the task. |
| `status` | String | Execution status of the request. |
| `payloadDetails` | Object | Contains request and response payload details. |
| `requestPayload` | Object | Contains the payload sent to the LLM provider. |
| `model` | String | Name of the model used for the request. |
| `temperature` | Number | Sampling temperature used to generate the response. |
| `maxTokens` | Integer | Maximum number of tokens that can be generated in the response. |
| `topP` | Number | Nucleus sampling value used for response generation. |
| `frequencyPenalty` | Number | Penalty applied to reduce repeated tokens. |
| `presencePenalty` | Number | Penalty applied to encourage new topics in the response. |
| `messages` | Array | Contains the messages sent in the request. |
| `role` | String | Role associated with the message, such as `system` or `user`. |
| `content` | String | Content of the message. |
| `responsePayload` | Object | Contains the response returned by the LLM provider. |
| `id` | String | Unique identifier of the response. |
| `object` | String | Type of response object. |
| `created` | Integer | Unix timestamp indicating when the response was created. |
| `choices` | Array | Contains the generated response choices. |
| `index` | Integer | Index of the response choice. |
| `message` | Object | Contains the generated message. |
| `finishReason` | String | Reason the model stopped generating the response. |
| `usage` | Object | Contains token usage information. |
| `promptTokens` | Integer | Number of tokens used in the prompt. |
| `completionTokens` | Integer | Number of tokens generated in the response. |
| `totalTokens` | Integer | Total number of tokens used for the request and response. |
| `requestTokens` | Integer | Number of tokens in the request. |
| `responseTokens` | Integer | Number of tokens in the response. |
| `total` | Integer | Total number of records returned or matching the query. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.