MENU
      Generate skillset answer

        Generate skillset answer


        Article summary

        Available in Classic and VPC

        Call the API for a specific skillset to generate the appropriate response.

        Request

        This section describes the request format. The method and URI are as follows:

        MethodURI
        POST/v1/skillsets/{skillset-id}/versions/{version}/final-answer

        Request headers

        The following describes the request headers.

        FieldRequiredDescription
        AuthorizationRequiredAPI key for authentication <e.g.,> Bearer nv-************
        X-NCP-CLOVASTUDIO-REQUEST-IDOptionalRequest ID
        Content-TypeRequiredRequest data format
        • application/json
        AcceptConditionalResponse data format
        • text/event-stream
        Note

        Response results are returned in JSON by default, but if you specify Accept as text/event-stream, then the response results are returned as a stream.

        Request path parameters

        You can use the following path parameters with your request:

        FieldTypeRequiredDescription
        skillset-idStringRequiredSkillset ID to generate answers for
        versionInteger/StringRequiredSkillset version to generate answers for
        • Specify a version to enter when using the skillset
        • {Version number} | latest
          • {Version number}: specific version
            • 1 ≤ version
          • latest: currently applied version
        Note

        You can request version as either an integer or a string, depending on which version of the skillset you want to enter.

        Request body

        You can include the following data in the body of your request:

        FieldTypeRequiredDescription
        queryStringRequiredQuery details
        tokenStreamBooleanOptionalWhether to use token streaming when generating answers
        • false | true
          • false: Not use
          • true: Use
        chatHistoryArrayOptionalAnswer generation history
        chatHistory.roleEnumRequiredConversation message role
        • user | assistant
          • user: user's utterance or question
          • assistant: model's answer
        chatHistory.contentStringRequiredContent of conversation messages
        requestOverrideObjectOptionalCall options to apply to all APIs
        requestOverride.baseOperationObjectOptionalCall option information to apply to all APIs
        requestOverride.baseOperation.headerObjectOptionalRequest header to apply to all APIs
        requestOverride.baseOperation.queryObjectOptionalRequest query parameter to apply to all APIs
        requestOverride.baseOperation.requestBodyObjectOptionalRequest body to apply to all APIs
        • Not applied to GET method APIs
        requestOverride.operationsArrayOptionalCall options to apply to specific APIs

        operations

        The following describes operations.

        FieldTypeRequiredDescription
        operationIdStringConditionalOperation ID of a specific API
        • Required when entering operations
        headerObjectOptionalRequest header to apply to a specific API
        queryObjectOptionalRequest query parameter to apply to a specific API
        requestBodyObjectOptionalRequest body to apply to specific APIs
        • Not applied to GET method APIs

        Request example

        The request example is as follows:

        curl --location --request POST 'https://clovastudio.stream.ntruss.com/testapp/v1/skillsets/{skillset-id}/versions/{version}/final-answer' \
        --header 'Authorization: Bearer {API Key}' \
        --header 'X-NCP-CLOVASTUDIO-REQUEST-ID: {Request ID}' \
        --header 'Content-Type: application/json' \
        --data '{
            "query": "What will the weather be like tomorrow?",
            "tokenStream": true,
            "chatHistory": [
                {
                    "role": "user",
                    "content": "How is the weather in Seoul today?"
                 },
                {
                    "role": "assistant",
                    "content": "It's the calm before the storm."
                 }
             ],
             "requestOverride": {
                "baseOperation": {
                    "query": {
                        "appid": "appid-11223344"
                        }
                    }
                }
            }'
        Plain text

        Response

        This section describes the response format.

        Response headers

        The following describes the response headers.

        HeadersRequiredDescription
        Content-Type-Response data format
        • application/json

        Response body

        The response body includes the following data:

        FieldTypeRequiredDescription
        statusObject-Response status
        resultObject-Response result
        result.finalAnswerString-Final execution result of the model
        • If not run to the end, return an empty string
        result.tokenCountInteger-Number of tokens measured when generating answers
        result.useTaskBoolean-Whether the called model is trained
        • false | true
          • false: not trained
          • true: training completed
        result.apiResultArray-Called API result

        apiResult

        The following describes apiResult.

        FieldTypeRequiredDescription
        urlString-API URL called during the answer process
        requestBodyString-API request body called during the answer process
        responseBodyString-API response body called during the answer process
        apiOrderInteger-Sort by to fix the order of responses regardless of the result of the API call
        operationIdString-Operation ID of the API Spec called during the answer process
        nameForHumanString-Name of the skill in which the API called during the answer process is registered

        Response example

        The response example is as follows:

        Succeeded

        The following is a sample response upon a successful call.

        {
          "status": {
            "code": "20000",
            "message": "OK"
          },
          "result": {
            "finalAnswer": "The weather in Seoul tomorrow is expected to be sunny, with temperatures around 27 degrees.",
            "tokenCount": 1032,
            "apiResult": [
              {
                "url": "http://example.com?numOfRows=1&location=서울&date=20240530",
                "requestBody": "string",
                "responseBody": "string",
                "apiOrder": 1,
                "operationId": "weatherAPI",
                "nameForHuman": "WeatherSkill"
              }
            ]
          }
        }
        JSON

        Failure

        The following is a sample response upon a failed call.

        Response stream

        You can use token streaming to output the tokens as they are generated, one by one. The following describes the token streaming format.

        Response headers

        The following describes the response headers.

        FieldRequiredDescription
        Accept-Response data format
        • text/event-stream

        Response body

        The response body includes the following data:

        FieldTypeRequiredDescription
        selectedSkillObject-Name of the selected skill
        • Only displayed in planning events
        finalAnswerString-Final execution result of the model
        • If not run to the end, return an empty string
        • Only displayed in FinalAnswer events
        tokenCountInteger-Number of tokens used in the event
        apiResultObject-Results of APIs called during the answer process
        • Only displayed in FinalAnswer events
        apiResult.urlString-API URL called during the answer process
        apiResult.requestBodyString-API request body called during the answer process
        apiResult.responseBodyString-API response body called during the answer process
        apiResult.apiOrderInteger-Sort by to fix the order of responses regardless of the result of the API call
        apiResult.operationIdString-Operation ID of the API Spec called during the answer process
        apiResult.nameForHumanString-Name of the skill in which the API called during the answer process is registered

        Token Event

        The following describes TokenEvent.

        FieldTypeRequiredDescription
        probsArray-List of response candidate tokens and probability values for each token
        stopReasonString-Reason for stopping results generation (generally passed to the last event)
        • length | end_token | stop_before
          • length: length limit
          • end_token: token count limit
          • stop_before: Settings value specified in stopBefore occurred during answer generation
        textString-Complete text pair

        Response example

        The response example is as follows:

        Succeeded

        The following is a sample response upon a successful call.

        id: aabdfe-dfgwr-edf-hpqwd-f2asd-g
        event: planning
        data: {"selectedSkill": {["nameForHuman":"Search hotel"]}, "tokenCount": 432}
        id: aabdfe-dfgwr-edf-hpqwd-f1asd-g
        event: cot
        data: {"apiResult": [{"url": "https://example.com/search_reviews_get?keyword=accessible to subway station", "requestBody": "keyword=accessible to subway station", "responseBody": "[{\"review_id\": 5,
        \"review_date\": \"20230809\", \"reviewer\": \"ClaudeCalder\", \"rating\": 4.0, \"content\": \"I was disappointed
        that they didn't have a sauna, pool, or other facilities, but the price was reasonable. There's a subway station and a convenience store
        nearby. It's perfect for a short stay.\", \"hotel_name\": \"Movenpick Hotel\", \"address\": \"120 Walkerhill-ro,
        Gwangjin-gu, Seoul\", \"room_name\": \"City View\", \"good_cnt\": 9, \"bad_cnt\": 0, \"rating_service\":
        3. 0, \"rating_clean\": 4.0, \"rating_room\": 4.0}]", "apiOrder": 1}], "tokenCount": 2401 }
        id: aabdfe-dfgwr-edf-hpqwd-f2asd-g
        event: finalAnswer
        data: {"finalAnswer": "A hotel with good subway access in Seoul is Movenpick Hotel, located at 120 Walkerhill-ro,
        Gwangjin-gu, Seoul.", "apiResult": [{"url": "https://example.com/search_reviews_get?keyword=accessible to subway station", "requestBody": "keyword=accessible to subway station", "responseBody":
        "[{\"review_id\": 5, \"review_date\": \"20230809\", \"reviewer\": \"ClaudeCalder\", \"rating\": 4.0,
        \"content\": \"I was disappointed that they didn't have a sauna, pool, or other facilities, but the price was reasonable. There's a subway station
        and a convenience store nearby. It's perfect for a short stay.\", \"hotel_name\": \"Movenpick Hotel\",
        \"address\": \"120 Walkerhill-ro, Gwangjin-gu, Seoul\", \"room_name\": \"City View\", \"good_cnt\": 9, \"bad_cnt\":
        0, \"rating_service\": 3.0, \"rating_clean\": 4.0, \"rating_room\": 4.0}]", "apiOrder": 1}],
        "tokenCount": 214 }
        ...
        Plain text

        Failure

        The following is a sample response upon a failed call.


        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.