Completion (JP)
- Print
- PDF
Completion (JP)
- Print
- PDF
Article Summary
Share feedback
Thanks for sharing your feedback!
Completion API
By using the Completion API, you can pass information to CLOVA Studio to generate a result (completion). CLOVA Studio creates a result value based on the specified contents of the prompt, the model to be used, and other parameter values.
Requests
POST: /v1/completions/{model}
Name | Description |
---|---|
model | Model to be used |
Request headers
Name | Required | Description |
---|---|---|
X-NCP-CLOVASTUDIO-API-KEY | Required | API key issued when creating a test app or service app |
X-NCP-APIGW-API-KEY | Required | API Gateway key issued when creating a test app or service app |
X-NCP-CLOVASTUDIO-REQUEST-ID | Optional | Request ID for each request |
Request bodies
Name | Type | Required | Default | Description |
---|---|---|---|---|
includeAiFilters | boolean | Optional | true | Indicates the degree to which the generated text corresponds to each category (e.g., profanity; abasement, discrimination, or hate speech; and sexual harassment or obscenity) |
includeTokens | bool | Optional | false | Whether to include input_tokens and output_tokens in the response
|
maxTokens | integer | Optional | 32 | Maximum number of tokens to be used when generating result value (0~2048) |
repeatPenalty | float | Optional | 5.0 | Penalty value to be applied to tokens that repeat the same expression (0~10) |
restart | string | Optional | '' | Text to be appended after output value |
start | string | Optional | '' | Text to be appended after user input value |
stopBefore | string array | Optional | empty list | A stop sequence that signals when to stop generating result values The specified string is not included in the generated text |
temperature | float | Optional | 0.5 | Randomness of result values A higher value is more likely to produce random results (0~1.0) |
text | string | Required | N/A | User input value (prompt) A new sentence is generated based on this text |
topK | integer | Optional | 0 | Top K value Tokens are listed in order of highest probability, and only tokens within the top K range are used (0~128) |
topP | float | Optional | 0.8 | Top P value Select a token with top P included in its cumulative probability value as a candidate (0~1.0) |
{
"start": "\nEnglish: ",
"stopBefore": ["\nKorean: "],
"text": "Korean: 사과\nEnglish: Apple\nKorean: 바나나",
"includeAiFilters": true
}
Response
Key | Type | Required | Description |
---|---|---|---|
aiFilters | object array | Optional | AI filter score |
aiFilters[].groupName | string | Required | See AI Filter table |
aiFilters[].name | string | Required | See AI Filter table |
aiFilters[].score | string | Required | The extent to which the text corresponds to the aiFilters[].name category:
|
inputLength | integer | Required | Input token number |
inputTokens | string array | Optional | Input token information |
outputLength | integer | Required | Output token number |
outputTokens | string array | Optional | Output token information |
stopReason | string | Required | Reason for stopping result value
|
text | string | Required | Generated token Includes both prompt and result values |
probs | float | Optional | Probability of each generated token being selected |
AI Filter table
For information included in aiFilters[].groupName
and aiFilters[].name
, see the following table.
groupName | name | Description |
---|---|---|
curse | discrimination | Abasement, discrimination, or hate speech |
curse | insult | Profanity |
unsafeContents | sexualHarassment | Sexual harassment or obscenity |
{
"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?