Completion (JP)
    • PDF

    Completion (JP)

    • PDF

    Article Summary

    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}

    NameDescription
    modelModel to be used

    Request headers

    NameRequiredDescription
    X-NCP-CLOVASTUDIO-API-KEYRequiredAPI key issued when creating a test app or service app
    X-NCP-APIGW-API-KEYRequiredAPI Gateway key issued when creating a test app or service app
    X-NCP-CLOVASTUDIO-REQUEST-IDOptionalRequest ID for each request

    Request bodies

    NameTypeRequiredDefaultDescription
    includeAiFiltersbooleanOptionaltrueIndicates the degree to which the generated text corresponds to each category (e.g., profanity; abasement, discrimination, or hate speech; and sexual harassment or obscenity)
    includeTokensboolOptionalfalseWhether to include input_tokens and output_tokens in the response
    • true: use
    • false: do not use
    maxTokensintegerOptional32Maximum number of tokens to be used when generating result value (0~2048)
    repeatPenaltyfloatOptional5.0Penalty value to be applied to tokens that repeat the same expression (0~10)
    restartstringOptional''Text to be appended after output value
    startstringOptional''Text to be appended after user input value
    stopBeforestring arrayOptionalempty listA stop sequence that signals when to stop generating result values The specified string is not included in the generated text
    temperaturefloatOptional0.5Randomness of result values A higher value is more likely to produce random results (0~1.0)
    textstringRequiredN/AUser input value (prompt) A new sentence is generated based on this text
    topKintegerOptional0Top K value Tokens are listed in order of highest probability, and only tokens within the top K range are used (0~128)
    topPfloatOptional0.8Top 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

    KeyTypeRequiredDescription
    aiFiltersobject arrayOptionalAI filter score
    aiFilters[].groupNamestringRequiredSee AI Filter table
    aiFilters[].namestringRequiredSee AI Filter table
    aiFilters[].scorestringRequiredThe extent to which the text corresponds to the aiFilters[].name category:
    • 0: high
    • 1: medium
    • 2: low
    inputLengthintegerRequiredInput token number
    inputTokensstring arrayOptionalInput token information
    outputLengthintegerRequiredOutput token number
    outputTokensstring arrayOptionalOutput token information
    stopReasonstringRequiredReason 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
    textstringRequiredGenerated token Includes both prompt and result values
    probsfloatOptionalProbability of each generated token being selected

    AI Filter table

    For information included in aiFilters[].groupName and aiFilters[].name, see the following table.

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

    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.