Completions
    • PDF

    Completions

    • PDF

    Article Summary

    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:

    MethodURI
    POST/v1/completions/{model}

    Header

    The following describes the header.

    HeaderRequiredDescription
    X-NCP-CLOVASTUDIO-API-KEYYAPI key issued when creating a test app or service app
    X-NCP-APIGW-API-KEYYAPI Gateway key issued when creating a test app or service app
    X-NCP-CLOVASTUDIO-REQUEST-IDNRequest ID for each request
    Content-TypeYapplication/json

    Path parameters

    The following describes the parameters.

    FieldTypeRequiredDescription
    modelstringYModel name: LK-D2

    Body

    The following describes the body.

    FieldTypeRequiredDescription
    includeAiFiltersbooleanNIndicates the degree to which the generated text corresponds to each category (for example, profanity, abasement, discrimination, hate speech, sexual harassment, or obscenity)
  • true (default value)
  • false
  • includeTokensbooleanNWhether to include input_tokens and output_tokens in the response
  • true: use
  • false: do not use
  • maxTokensintNMaximum number of tokens to be used when generating result value
  • 0 < maxTokens ≤ 2048 (default value: 100)
  • repeatPenaltyfloatNPenalty value to be applied to tokens that repeat the same expression
  • 0.0 < repeatPenalty ≤ 10.0 (default value: 5.0)
  • restartstringNText to be appended after output value
    startstringNText to be appended after user input value
    stopBeforearrayNCharacter that halts token generation
  • [] (default value)
  • temperaturefloatNRandomness of result values. A higher value is more likely to produce random results
  • 0.00 < temperature ≤ 1.00 (default value: 0.50)
  • textstringYIt is a user input value (prompt), and a new sentence is generated based on this text
    topKintNTop K value. Tokens are listed in order of highest probability, and only tokens within the top K range are used
  • 0 ≤ topk ≤ 128 (default value: 0)
  • topPfloatNTop P value. Select a token with top P included in its cumulative probability value as a candidate
  • 0.00 < topP ≤ 1.00 (default value: 0.80)
  • 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.

    HeaderRequiredDescription
    Content-Type-application/json

    Body

    The following describes the body.

    FieldTypeRequiredDescription
    aiFiltersobject array-AI Filter score
    aiFilters[].groupNamestring-See AI Filter table
    aiFilters[].namestring-See AI Filter table
    aiFilters[].scorestring-The extent to which the text corresponds to the aiFilters[].name category
    • 0: high
    • 1: medium
    • 2: low
    inputLengthinteger-Input token number
    inputTokensstring array-Input token information
    outputLengthinteger-Output token number
    outputTokensstring array-Output token information
    stopReasonstring-Reason for stopping result value
    • length: reached the set maximum length
    • end_token: reached the maximum number of tokens that can be used
    • stop_before: reached the set stop sequence
    textstring-Generated token. Includes both prompt and result values
    probsfloat-Probability of each generated token being selected

    AI Filter table

    See the following table for contents included in aiFilters[].groupName and aiFilters[].name.

    groupNamenameDescription
    cursediscriminationAbasement, discrimination, or hate speech
    curseinsultProfanity
    unsafeContentssexualHarassmentSexual 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?

    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.