Router

Prev Next

Available in Classic and VPC

Call the API of a specific router to classify the input request into the appropriate domain and determine whether it meets the set filter conditions.

Request

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

Method URI
POST /v1/routers/{router-id}/versions/{version}/route

Request headers

The following describes the request headers.

Field Required Description
Authorization Required API key for authentication Example: Bearer nv-************
X-NCP-CLOVASTUDIO-REQUEST-ID Optional Request ID
Content-Type Required Request data format
  • application/json

Request path parameters

You can use the following path parameters with your request:

Field Type Required Description
router-id String Required Router ID
version Integer Required Router version
  • 1 ≤ version

Request body

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

Field Type Required Description
query String Required Entry
chatHistory Array Optional Conversation message history: chatHistory

chatHistory

The following describes chatHistory.

Field Type Required Description
chatHistory.role Enum Required Conversation message role
  • user: user utterances/questions
chatHistory.content String Required Content of conversation messages

Request example

The request example is as follows:

curl --location --request POST 'https://clovastudio.stream.ntruss.com/v1/routers/{router-id}/versions/{version}/route' \
--header 'Authorization: Bearer {API Key}' \
--header 'X-NCP-CLOVASTUDIO-REQUEST-ID: {Request ID}' \
--header 'Content-Type: application/json' \
--data '{
  "query" : "Tell me the fine dust information.",
  "chatHistory" : [ {
    "role" : "user",
    "content" : "Tell me the precipitation forecast for Seoul tomorrow."
  } ]
}'

Response

This section describes the response format.

Response headers

The following describes the response headers.

Headers Required Description
Content-Type - Response data format
  • application/json

Response body

The response body includes the following data:

Field Type Required Description
status Object - Response status
result Object - Response result
result.domain Object - Domain result
result.domain.result String - Domain determination result
  • Display an empty string if no matching domain is found.
result.domain.called Boolean - Whether domain determination is performed
  • false
  • true
result.blockedContent Object - Content filter results
result.blockedContent.result Array - Content filter determination result
  • Display an empty list if no matching filter is found.
result.blockedContent.called Boolean - Whether content filter determination is performed
  • false
  • true
result.safety Object - Safety filter result
result.safety.result Array - Safety filter determination result
  • Display an empty list if no matching filter is found.
result.safety.called Boolean - Whether safety filter determination is performed
  • false
  • true
result.usage Object - Token count information
result.usage.promptTokens Integer - Input token count
result.usage.completionTokens Integer - Generated token count
result.usage.totalTokens Integer - Total token count
  • promptTokens + completionTokens

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": {
    "domain": {
      "result": "Search Region",
      "called": true
    },
    "blockedContent": {
      "result": ["UnsupportedRegion"],
      "called": true
    },
    "safety": {
      "result": [],
      "called": true
    },
    "usage": {
      "promptTokens": 425,
      "completionTokens": 62,
      "totalTokens": 487
    }
  }
}

Failure

The following is a sample response upon a failed call.