Token calculator (chat)
- Print
- PDF
Token calculator (chat)
- Print
- PDF
Article summary
Did you find this summary helpful?
Thank you for your feedback
Available in Classic and VPC
Calculate the number of tokens in a sentence entered in the HCX model.
Request
This section describes the request format. The method and URI are as follows:
Method | URI |
---|---|
POST | /v1/api-tools/chat-tokenize/{modelName} |
Request headers
The following describes the request headers.
Headers | Required | Description |
---|---|---|
Authorization | Required | API key for authentication <e.g.,> Bearer nv-************ |
X-NCP-CLOVASTUDIO-REQUEST-ID | Optional | Request ID |
Content-Type | Required | Request data format
|
Request path parameters
You can use the following path parameters with your request:
Field | Type | Required | Description |
---|---|---|---|
modelName | String | Required | Model name
|
Request body
You can include the following data in the body of your request:
Field | Type | Required | Description |
---|---|---|---|
messages | Array | Required | List of conversation messages to count tokens for |
messages.role | Enum | Required | Role of conversation messages
|
messages.content | String | Required | Content of conversation messages |
Request example
The request example is as follows:
Response
This section describes the response format.
Response body
The response body includes the following data:
Field | Type | Required | Description |
---|---|---|---|
messages | Array | - | List of request conversation messages with counted tokens |
messages.role | Enum | - | Role of conversation messages
|
messages.content | String | - | Content of conversation messages |
messages.count | Integer | - | Result of calculating the number of tokens in the conversation message |
Response example
The response example is as follows:
Succeeded
The following is a sample response upon a successful call.
Failure
The following is a sample response upon a failed call.
Was this article helpful?