Available in Classic and VPC
Delete sentences that exceed the maximum number of tokens when using Chat completions API. The oldest conversation turns are deleted to free up tokens so that conversations can be created without interruption.
For a detailed description of how the sliding window works and how to work with it, see Utilize API of the CLOVA Studio user guide.
Request
This section describes the request format. The method and URI are as follows:
| Method | URI |
|---|---|
| POST | /v1/api-tools/sliding/chat-messages/{modelName} |
Request headers
For information about the headers common to all CLOVA Studio APIs, see CLOVA Studio request headers.
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 |
|---|---|---|---|
maxTokens |
Integer | Required | Maximum number of generated tokens
|
messages |
Array | Required | Conversation message list: messages
|
messages
The following describes messages.
| Field | Type | Required | Description |
|---|---|---|---|
role |
Enum | Required | Role of conversation messages
|
content |
String | Required | Content of conversation messages |
When entering some fields, check the following.
messages: The sum of the number of tokens entered and the number of tokens entered inmaxTokenscan't exceed 4096 tokens. The number of tokens entered inmessagescan be checked by calling the Token calculation API.
Request example
The request example is as follows:
curl --location --request POST 'https://clovastudio.stream.ntruss.com/v1/api-tools/sliding/chat-messages/{modelName}' \
--header 'Authorization: Bearer {API Key}' \
--header 'X-NCP-CLOVASTUDIO-REQUEST-ID: {Request ID}' \
--header 'Content-Type: application/json' \
--data '{
"maxTokens" : 200,
"messages" : [ {
"role" : "user",
"content" : "hello"
} ]
}'
Response
This section describes the response format.
Response body
The following describes the body.
| Field | Type | Required | Description |
|---|---|---|---|
status |
Object | - | See Response status. |
result |
Object | - | Response result
|
result.messages |
Array | - | Conversation message list: messages |
messages
The following describes messages.
| Field | Type | Required | Description |
|---|---|---|---|
role |
Enum | - | Role of conversation messages
|
content |
String | - | Content of conversation messages |
Response example
The response example is as follows:
Succeeded
The following is a sample response upon a successful call.
{
"status": {
"code": "20000",
"message": "OK"
},
"result": {
"messages": [
{
"role": "user",
"content": "hello"
}
]
}
}
Failure
The following is a sample response upon a failed call.