- Print
- PDF
Sliding window
- Print
- PDF
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
The following describes the request format for the endpoint. The request format is as follows:
Method | URI |
---|---|
POST | /v1/api-tools/sliding/chat-messages/{modelName} |
Request headers
The following describes the request headers.
Field | Required | Description |
---|---|---|
X-NCP-CLOVASTUDIO-API-KEY | Required | API key issued when creating the test app or service app |
X-NCP-APIGW-API-KEY | Required | API Gateway key issued when creating the test app or service app |
X-NCP-CLOVASTUDIO-REQUEST-ID | Optional | Request ID |
Content-Type | Required | Request data format
|
Request path parameters
The following describes the request path parameters.
Field | Type | Required | Description |
---|---|---|---|
modelName | String | Required | Model name
|
Request body
The following describes the request body.
Field | Type | Required | Description |
---|---|---|---|
maxTokens | Integer | Required | Maximum number of generated tokensmaxTokens ≤ 4096 (default: 100) |
messages | Array | Required | Conversation message list
|
messages.role | Enum | Required | Role of conversation messages
|
messages.content | String | Required | Content of conversation messages |
When entering some fields, check the following.
Request example
The following is a sample request.
curl --location --request POST 'https://clovastudio.apigw.ntruss.com/v1/api-tools/sliding/chat-messages/{modelName}' \
--header 'X-NCP-CLOVASTUDIO-API-KEY: {CLOVA Studio API Key}' \
--header 'X-NCP-APIGW-API-KEY: {API Gateway API Key}' \
--header 'X-NCP-CLOVASTUDIO-REQUEST-ID: {Request ID}' \
--header 'Content-Type: application/json' \
--data '{
"maxTokens" : 200,
"messages" : [ {
"role" : "user",
"content" : "hello"
} ]
}'
Response
The following describes the response format.
Response body
The following describes the body.
Field | Type | Required | Description |
---|---|---|---|
result | Object | - | Response result
|
result.messages | Array | - | Conversation message list |
result.messages.role | Enum | - | Role of conversation messages
|
result.messages.content | String | - | Content of conversation messages |
Response example
The following is a sample example.
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.