# Getting Started

Prerequisites and How to Get Help

All plans, including free plans, have access to the API (Application Programming Interface), which allows you to programmatically use our technology and all its features through code. The API is a fundamental component that applications rely on to use DUIX or any other service. In this section, we'll provide a concise overview of how to make requests to endpoints using the API and create our first DUIX session. It's worth noting that the website is just a frontend for the API. Therefore, there should be no difference in quality or output under the same settings whether you experience the session demo or call the API directly with code. However, it is still non-deterministic, so the delivery of generated output may vary.

DUIX ONE-Omni version API call connection sessions consume tokens. Therefore, if you have 200,000 tokens in your account and create a session, calling the session via API will consume the corresponding tokens. DUIX ONE-Lite version API call connection sessions require you to have obtained a GPT4o-realtime Key from the OpenAPI platform, which can be used for session verification through API calls after setup. For your convenience, you can first go to Choose a Plan (opens new window), or you can use the time-limited free trial quota to verify the process. Given the wide scope and almost unlimited possibilities of the API, we'll do a very quick overview and show some examples to get you up and running.

# Creating Your First Session

Start using the DUIX API to generate your first conversation

# Create an Account

To use our DUIX ONE SDK, you first need to create a GUIJI.CN account, click here to Create One (opens new window). image.png

# Create a Session

After successful login, click the [Create Session] menu on the left to create your first session. You can choose your preferred digital human, voice, and background. You can select the large model you want to use and the session language. If you choose the DUIX ONE-Omni model, you can also set an opening message, which the digital human will say proactively when starting the conversation. If you choose the DUIX ONE-Lite model, you need to set up a key to create a session. image.png

# Get appid/key and Conversation id

Click next to get the app id, app key, and Conversation id. Click the "copy" icon to copy and paste for use. Don't share your app key with others. If someone gets access to your app key, they can use your account just like they have your password. image.png

# Start Integration

Finally, after the session is created successfully, you can start integrating with the API and SDK to see the effects. You can refer to the API Documentation (opens new window) image.png

# Getting Your API Keys

How to authenticate your requests to our API.

# Create Application

If you're not using DUIX ONE for the first time or want to create more applications, click the [Account] menu on the left, then click [API Management --> My Keys] to view more or create new applications. Click Create New Application, set the application name, and you can create a new application. Click copy to paste your app id and app key into the documentation. image.png Note: Don't show your app-key to others. If someone gets access to your app-key, they can use your account just like they have your password. If you're using the lite version, you need to set up GPT4o keys by clicking [Set GPT4o] and entering the settings in the popup.

# Getting Tokens

Access tokens are the service authentication credentials for calling DUIX ONE interactive services. All HTTP interface calls need to include the Token in the Header.

# How to Get Tokens

Below we introduce the method for obtaining access tokens.

# Prerequisites

You must have obtained appKey and appId, which can be found in the created API Keys.

# Steps

  1. Generate a signature using appKey and appId.
  2. Use the signature as a parameter for the init method of the h5 sdk.

# Signature Generation

Signatures use the JWT mechanism. Users can refer to the following to complete the signature

# Parameter Description

The following parameters are needed for signature generation

Name Type Description Example
appId string Session identifier, obtained after session creation xxxxxxx
appKey string Session key, obtained after session creation xxxxxxx
sigExp Integer Signature validity period in seconds 1800

# Demo Code

Here's an example code for signature generation, Java version

Add pom dependency

<dependency>
    <groupId>com.auth0</groupId>
    <artifactId>java-jwt</artifactId>
    <version>3.8.3</version>
</dependency>

import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import java.util.Calendar;
import java.util.Date;

public class SigUtils {
    /**
     * Create signature
     *
     * @param appId  Session identifier
     * @param appKey Session key
     * @param sigExp Signature validity period in seconds
     * @return
     */
    public static String createSig(String appId, String appKey, int sigExp) {
        Calendar nowTime = Calendar.getInstance();
        nowTime.add(Calendar.SECOND, sigExp);
        Date expiresDate = nowTime.getTime();
        return JWT.create()
                //Issue time
                .withIssuedAt(new Date())
                //Expiration time
                .withExpiresAt(expiresDate)
                //Payload
                .withClaim("appId", appId)
                //Encryption
                .sign(Algorithm.HMAC256(appKey));
    }
}

** Note: This signature (Token) is the sign for the H5 SDK

# Development Integration

With the AppID, secret key, and Token obtained from the above steps, you can learn in detail through the SDK and API overview how to integrate DUIX ONE into your services on various platforms.