Skip to content

Chat Completion

1. Introduction

Chat Completion API is a service that generates natural and fluent conversational responses to text inputs provided by users. It can be used in a variety of use cases, enabling the development of various applications such as chatbots, customer support systems, and personal assistants.

Key features

  • Create conversation response: Create consistent and fluent conversation response based on the message history provided.
  • Token control: You can control response length by setting the maximum number of tokens in the response you want to generate.
  • Temperature settings: Supports temperature parameters that control the diversity and creativity of responses.
  • Role-based message: You can specify a variety of roles, including systems, users, assistants, to maintain a more natural flow of conversation.
  • Choose multiple responses: Multiple responses to a single request can be generated to provide a variety of options.

Use Cases

Chat Completion API enables the creation of an instant, natural response to a user's text input. This allows you to develop a variety of conversation-based applications, including the following, or enhance the user experience.

  • Develop chatbots: Create a natural and fluent response to text entered by the user to implement an interactive chatbot.
  • Customer support system: Automate customer support services by automatically generating responses to customer inquiries.
  • Personal secretaries: It can act as a personal assistant by generating real-time responses to your commands or questions.

2. Example

Below is a simple usage example, which shows how to generate a conversation response through the API for text entered by the user.

Request Example

shell
curl -X POST 'https://apis.daglo.ai/nlp/v1/sync/chat/completions' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <API_TOKEN>' \
--data '{
    "model": "elli",
    "messages": [
        {
            "role": "system",
            "content": "You are an elementary school teacher."
        },
        {
            "role": "user",
            "content": "Please explain interest rates at a level that elementary school students can understand."
        }
    ],
    "topP": 0.9
}'

Response Example

json
{
    "rid": "<RID>",
    "model": "elli",
    "chatResults": [
        {
            "index": 0,
            "message": {
                "role": "assistant",
                "content": "\"An interest rate is the amount of money you pay to borrow. As the value of money increases, the amount of money you give back after one month increases. For example, if 10,000 won becomes 10,500 won for two months, the interest on 10,000 won you received before is 500 won."
            },
            "finishReason": "stop"
        }
    ],
    "usage": {
        "promptTokens": 23,
        "completionTokens": 78,
        "totalTokens": 101
    }
}

3. Instructions

1) Getting an API Key

  • Create an account in the API console.
  • Go to the token menu and issue a new token.
  • Copy the issued token information and use it as an authentication token when requested.

2) Sending a request

  • The example below is a request to generate a conversation response for text entered by the user.
  • Request to the specified endpoint with the required parameters.
  • For more detailed API information, refer to API Reference.

a. POST Send chat message for completion

  • Endpoint
shell
POST https://apis.daglo.ai/nlp/v1/sync/chat/completions

3) Getting a response

Success

View response code
  • 200

Error

View response code
  • 401 : Unauthorized. Authentication failed.
  • 403: Forbidden. No access.
  • 429: Too Many Requests.
  • 500 : Internal Server Error. Server error.

Update history

  • 20240902 ver1.0 API document has been created.