Completions
- Print
- PDF
Completions
- Print
- PDF
Article Summary
Share feedback
Thanks for sharing your feedback!
Available in Classic and VPC
You can pass information for generating a result value (completion) in CLOVA Studio to CLOVA Studio. CLOVA Studio creates a result value based on the specified contents of the prompt, the model to be used, and other parameter values.
Requests
Describes the request format. The request format is as follows:
Method | URI |
---|---|
POST | /v1/completions/{model} |
Header
The following describes the header.
Header | Required | Description |
---|---|---|
X-NCP-CLOVASTUDIO-API-KEY | Y | API key issued when creating a test app or service app |
X-NCP-APIGW-API-KEY | Y | API Gateway key issued when creating a test app or service app |
X-NCP-CLOVASTUDIO-REQUEST-ID | N | Request ID for each request |
Content-Type | Y | application/json |
Path parameters
The following describes the parameters.
Field | Type | Required | Description |
---|---|---|---|
model | string | Y | Model name: LK-D2 |
Body
The following describes the body.
Field | Type | Required | Description |
---|---|---|---|
includeAiFilters | boolean | N | Indicates the degree to which the generated text corresponds to each category (for example, profanity, abasement, discrimination, hate speech, sexual harassment, or obscenity) |
includeTokens | boolean | N | Whether to include input_tokens and output_tokens in the response |
maxTokens | int | N | Maximum number of tokens to be used when generating result value |
repeatPenalty | float | N | Penalty value to be applied to tokens that repeat the same expression |
restart | string | N | Text to be appended after output value |
start | string | N | Text to be appended after user input value |
stopBefore | array | N | Character that halts token generation |
temperature | float | N | Randomness of result values. A higher value is more likely to produce random results |
text | string | Y | It is a user input value (prompt), and a new sentence is generated based on this text |
topK | int | N | Top K value. Tokens are listed in order of highest probability, and only tokens within the top K range are used |
topP | float | N | Top P value. Select a token with top P included in its cumulative probability value as a candidate |
Syntax
The following is an example of syntax.
curl --location --request POST 'https://clovastudio.apigw.ntruss.com/testapp/v1/completions/LK-D2' \
--header 'X-NCP-CLOVASTUDIO-API-KEY: <X-NCP-CLOVASTUDIO-API-KEY>' \
--header 'X-NCP-APIGW-API-KEY: <X-NCP-APIGW-API-KEY>' \
--header 'X-NCP-CLOVASTUDIO-REQUEST-ID: <X-NCP-CLOVASTUDIO-REQUEST-ID>' \
--header 'Content-Type: application/json' \
--data '{
"start": "\nEnglish: ",
"stopBefore": ["\nKorean: "],
"text": "Korean: apple\nEnglish: apple\nKorean: banana",
"includeAiFilters": true
}'
Responses
Describes the responses format.
Header
The following describes the header.
Header | Required | Description |
---|---|---|
Content-Type | - | application/json |
Body
The following describes the body.
Field | Type | Required | Description |
---|---|---|---|
aiFilters | object array | - | AI Filter score |
aiFilters[].groupName | string | - | See AI Filter table |
aiFilters[].name | string | - | See AI Filter table |
aiFilters[].score | string | - | The extent to which the text corresponds to the aiFilters[].name category
|
inputLength | integer | - | Input token number |
inputTokens | string array | - | Input token information |
outputLength | integer | - | Output token number |
outputTokens | string array | - | Output token information |
stopReason | string | - | Reason for stopping result value
|
text | string | - | Generated token. Includes both prompt and result values |
probs | float | - | Probability of each generated token being selected |
AI Filter table
See the following table for contents included in aiFilters[].groupName
and aiFilters[].name
.
groupName | name | Description |
---|---|---|
curse | discrimination | Abasement, discrimination, or hate speech |
curse | insult | Profanity |
unsafeContents | sexualHarassment | Sexual harassment or obscenity |
Syntax
The following is an example of syntax.
{
"status": {
"code": "20000",
"message": "OK"
},
"result": {
"text": "...",
"stopReason": "stop_before",
"inputLength": 10,
"outputLength": 20,
"inputTokens" : ["who", " ", "are", " ", "you"],
"outputTokens" : ["hello", " ", "world"],
"aiFilters": [
{
"groupName": "curse",
"name": "insult",
"score": "0"
},
{
"groupName": "curse",
"name": "discrimination",
"score": "1"
},
{
"groupName": "unsafeContents",
"name": "sexualHarassment",
"score": "2"
}
]
}
}
Was this article helpful?