# get token usage - GetUMInferTokenUsage

## Overview

Get the token usage of a specific model under a specific key






## Definition

### Public Parameters

| Parameter Name | Type | Description Information | Required |
|:---|:---|:---|:---|
| **Action**     | string  | Corresponding API command name, the current API is `GetUMInferTokenUsage`.                      | **Yes** |
| **PublicKey**  | string  | The user's public key can be obtained from [Console](https://console.ucloud.cn/uaccount/api_manage)                                             | **Yes** |
| **Signature**  | string  | User signature generated based on public key and API command, see [Signature Algorithm](https://docs.ucloud.cn/api/summary/signature.md)  | **Yes** |

### Request Parameters

| Parameter Name | Type | Description Information | Required |
|:---|:---|:---|:---|
| **ProjectId** | string | Project ID. Leave it blank for the default project. Sub-accounts must fill in. Please refer to the [GetProjectList API](https://docs.ucloud.cn/api/summary/get_project_list) |**Yes**|
| **KeyId** | string | apikey's id |**Yes**|
| **Model** | string | Model Name |**Yes**|
| **StartTime** | int | Start Timestamp |**Yes**|
| **EndTime** | int | End Timestamp |**Yes**|

### Response Field

| Field Name | Type | Description Information | Required |
|:---|:---|:---|:---|
| **RetCode** | int | Return status code. If it is 0, it means successful return. If it is not 0, it means failure. |**Yes**|
| **Action** | string | Operation command name. |**Yes**|
| **Message** | string | Returns an error message, providing detailed description when `RetCode` is non-zero. |No|
| **Data** | [*TokenUsage*](#tokenusage) | token usage detail |**Yes**|

#### Data Model


#### TokenUsage

| Field Name | Type | Description Information | Required |
|:---|:---|:---|:---|
| **Total** | int | Total Token Count |No|
| **InTotal** | int | Output Total Token |No|
| **OutTotal** | int | Total Output Tokens |No|
| **ImageGenerationNum** | int | total image generation nums |No|
| **RequestTotal** | int | total request count |No|
| **Usages** | array[[*TokenUsageTimestamp*](#tokenusagetimestamp)] | Token usage per timestamp |No|

#### TokenUsageTimestamp

| Field Name | Type | Description Information | Required |
|:---|:---|:---|:---|
| **Type** | string | Type, in Input out Output total Total |No|
| **Count** | int | Quantity |No|
| **Timestamp** | int | Unix timestamp |No|
| **Model** | string | Model Name |No|

## Example

### Request Example
    
```
https://api.ucloud.cn/?Action=GetUMInferTokenUsage
&KeyId=MBMtLxzV
&Model=RVLhTXwV
&StartTime=9
&EndTime=2
&ProjectId=pPuXjEjZ
&ProjectId=YyoGQFzG
```

### Response Example
    
```json
{
  "Action": "GetUMInferTokenUsageResponse",
  "Data": {},
  "RetCode": 0
}
```





