- Print
- PDF
Completions
- Print
- PDF
Available in Classic and VPC
Generate conversational sentences utilizing the normal mode (LK model) of Playground.
Request
The following describes the request format for the endpoint. The request format is as follows:
Method | URI |
---|---|
POST |
|
Request headers
The following describes the request headers.
Headers | 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 for the request |
Content-Type | Required | Request data format
|
Request path parameters
The following describes the request path parameters.
Field | Type | Required | Description |
---|---|---|---|
model | String | Conditional | Model name
|
taskId | String | Conditional | Training ID
|
Request body
The following describes the request body.
Field | Type | Required | Description |
---|---|---|---|
text | String | Required | User input (prompt)
|
topK | Integer | Optional | Sample K high-probability candidates from the pool of generated token candidatestopK ≤ 128 (default: 0) |
topP | Float | Optional | Sample generated token candidates based on cumulative probability
|
repeatPenalty | Float | Optional | Degree of penalty for generating the same token (the higher the setting, the less likely it is to generate the same result repeatedly)repeatPenalty ≤ 10.0 (default: 5.0) |
stopBefore | Array | Optional | Character to abort token generation |
restart | String | Optional | Text to be attached behind the generated result value |
start | String | Optional | Text to be attached behind the user input value |
maxTokens | Integer | Optional | Maximum number of generated tokensmaxTokens ≤ 2048 (default: 100) |
includeTokens | Boolean | Optional | Whether input_tokens and output_tokens will be included in the response
|
temperature | Float | Optional | Degree of diversity for the generated tokens (higher values generate more diverse sentences)
|
includeAiFilters | Boolean | Optional | Whether to display the AI Filter results (degree of the generated results in categories such as profanity, degradation/discrimination/hate, sexual harassment/obscenity, etc.)
|
When entering some fields, check the following.
text
: The sum of the number of tokens entered and the number of tokens entered inmaxTokens
can't exceed 2048 tokens.
Request example
The following is a sample request.
curl --location --request POST 'https://clovastudio.apigw.ntruss.com/testapp/v1/completions/LK-D2' \
--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 '{
"start": "\nEnglish: ",
"stopBefore": ["\nKorean: "],
"text": "Korean: 사과\nEnglish: Apple\nKorean: 바나나",
"includeAiFilters": true
}'
Response
The following describes the response format.
Response headers
The following describes the response headers.
Headers | Required | Description |
---|---|---|
Content-Type | - | Response data format
|
Response body
The following describes the response body.
Field | Type | Required | Description |
---|---|---|---|
status | Object | - | Response status |
result | Object | - | Response result |
result.text | String | - | Generated token (prompt and generated result value) |
result.stopReason | String | - | Reason for stopping results generation
|
result.startLength | Integer | - | Input token count |
inputText | String | - | User input value (prompt) |
result.inputLength | Integer | - | Number of input tokens (including special tokens such as END OF TURN based on billing) |
result.inputTokens | Array | - | Entered token information |
result.outputText | Integer | - | Generated result value |
result.outputLength | Integer | - | Generated token count |
result.outputTokens | Array | - | Generated token information |
result.probs | Array | - | Candidate tokens for response tokens and probability values for candidate tokens |
result.ok | Boolean | - | Whether response was successful
|
aiFilter | Array | - | AI Filter result |
aiFilter
The following describes aiFilter
.
Field | Type | Required | Description |
---|---|---|---|
groupName | String | - | AI Filter category
|
name | String | - | AI Filter subcategory
|
score | String | - | AI Filter score
|
result | String | - | Whether AI Filter is operating properly
|
AI Filter can analyze up to 500 characters. However, if the text being analyzed contains many unusual formats, emojis, or special characters, it may not be analyzed correctly.
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": {
"text": "Write emotional marketing copy\n\nProduct: lotion\nText: Moisturizes as soon as it touches your skin\n###\nProduct: planner\nText: a gift I give to myself",
"stopReason": "end_token",
"startLength": 33,
"inputText": "Write emotional marketing copy\n\nProduct: lotion\nText: Moisturizes as soon as it touches your skin\n###\nProduct: planner",
"inputLength": 33,
"inputTokens": ["Wr", "ite", " emo", "tion", "al", " market","ing", " copy", "\n",
"\n", "Product", ":", " lotion", "\n", "Text", ":"," Moisturizes", " as", " soon", " as", " it", " touches", " your skin"
"\n", "##", "#", "\n", "Product", ":", " planner", "\n", "Text", ":"
],
"outputText": "\nText: a gift I give to myself",
"outputLength": 7,
"outputTokens": ["a", "gift", "I", "give", "to", "myself",""
],
"probs": [],
"ok": true,
"aiFilter": [
{
"groupName": "curse",
"name": "insult",
"score": "2"
},
{
"groupName": "curse",
"name": "discrimination",
"score": "1"
},
{
"groupName": "unsafeContents",
"name": "sexualHarassment",
"score": "2"
}
]
}
}
Failure
The following is a sample response upon a failed call.