The resources (image, video, voice) generated by our API are valid for 7 days. Please save the relevant resources as soon as possible to prevent expiration.

Create session

POST https://openapi.akool.com/api/open/v3/liveAvatar/session/create

Request Headers

ParameterValueDescription
AuthorizationBearer tokenYour API Key used for request authorization. You can get from https://openapi.akool.com/api/open/v3/getToken api.

Body Attributes

ParameterTypeValueDescription
avatar_idStringDigital human model in real-time avatar, The current system provides four options: _“Kai_1080P_back”、“Katha_1080P_back”、“Olivia_1080P_back”、“who_1080P_back”. If you want to use a custom uploaded video, you need to call the https://openapi.akool.com/api/open/v3/avatar/create interface to create a template. This process takes some time to process. You can check the processing status through the interface https://openapi.akool.com/api/open/v3/avatar/detail. When status=3, you can use the avatar_id field to pass it in.
background_urlStringThe user can provide a background image to replace the avatar background in the video. If it is not passed or is empty, the avatar default background will be used.

Response Attributes

ParameterTypeValueDescription
codeint1000Interface returns business status code(1000:success)
msgStringInterface returns status information
dataObject{ "_id": "", "status": 1, "stream_urls": { "client_pull_stream_url":"", "client_chat_room_url":"", "server_chat_room_url":"" } }_id: Interface returns data, status: the status of session: [1:queueing, 2:processing, 3:completed, 4:failed], stream_urls: the url of live avatar, client_pull_stream_url: Client streaming address, client_chat_room_url: Client websocket link address, server_chat_room_url: server websocket link address, The address suffix such as server_8898 is the object processed by the server algorithm

Example

Body

{
  "_id": "6698c9d69cf7b0d61d1b6420",
  "status": 1,
  "task_id": "6698c9d69b4c131d2cf15f2d",
  "app_name": "openapi_live",
  "stream_name": "20240718075254093_8898",
  "stream_urls": {
    "client_pull_stream_url": "https://stream-open-test.akool.io:8443/final_openapi_live/20240718075254093_8898.flv", // Client streaming address
    "client_chat_room_url": "wss://stream-open-test.akool.io:8443/final_20240718075254093_8898/client_8898.chat",     // Client websocket link address
    "server_chat_room_url": "wss://stream-open-test.akool.io:8443/final_20240718075254093_8898/server_8898.chat"      // server websocket link address, The address suffix such as server_8898 is the object processed by the server algorithm
  }
}

Request

Response

{
    "code": 1000,
    "msg": "OK",
    "data": {
        "_id": "6698c9d69cf7b0d61d1b6420",
        "uid": 100010,
        "type": 1,
        "status": 1,
        "task_id": "6698c9d69b4c131d2cf15f2d",
        "app_name": "openapi_live",
        "stream_name": "20240718075254093_8898",
        "stream_urls": {
            "client_pull_stream_url": "https://stream-open-test.akool.io:8443/final_openapi_live/20240718075254093_8898.flv",   // Client streaming address
            "client_chat_room_url": "wss://stream-open-test.akool.io:8443/final_20240718075254093_8898/client_8898.chat",   // Client websocket link address
            "server_chat_room_url": "wss://stream-open-test.akool.io:8443/final_20240718075254093_8898/server_8898.chat" // server websocket link address, The address suffix such as server_8898 is the object processed by the server algorithm
        }
    }
}

Get Session Info Result

GET https://openapi.akool.com/api/open/v3/liveAvatar/session/detail?id=6698c9d69cf7b0d61d1b6420

Request Headers

ParameterValueDescription
AuthorizationBearer tokenYour API Key used for request authorization. You can get from https://openapi.akool.com/api/open/v3/getToken api.

Query Attributes

ParameterTypeValueDescription
idStringNULLvideo db id: You can get it based on the _id field returned by https://openapi.akool.com/api/open/v3/liveAvatar/session/create .

Response Attributes

ParameterTypeValueDescription
codeint1000Interface returns business status code(1000:success)
msgStringOKInterface returns status information
dataObject{ status:1, _id:"", stream_urls:{} }status: the status of live avatar:【1:queueing, 2:processing, 3:completed, 4:failed】 stream_urls: the url of live avatar, _id: Interface returns data

Example

Request

Response

{
  "code": 1000,
  "msg": "OK",
  "data": {
    "_id": "6698c9d69cf7b0d61d1b6420",
    "uid": 100010,
    "type": 1,
    "status": 3,
    "task_id": "6698c9d69b4c131d2cf15f2d",
    "stream_urls": {
        "client_pull_stream_url": "https://stream-open-test.akool.io:8443/final_openapi_live/20240718075254093_8898.flv"
    }
  }
}

Close Session

POST https://openapi.akool.com/api/open/v3/liveAvatar/session/close

Request Headers

ParameterValueDescription
AuthorizationBearer tokenYour API Key used for request authorization. You can get from https://openapi.akool.com/api/open/v3/getToken api.

Body Attributes

ParameterTypeValueDescription
idStringNULLsession id: You can get it based on the _id field returned by https://openapi.akool.com/api/open/v3/liveAvatar/session/create .

Response Attributes

ParameterTypeValueDescription
codeint1000Interface returns business status code(1000:success)
msgStringOKInterface returns status information

Example

Request

Response

{
  "code": 1000,
  "msg": "OK"
}

Pause Session

POST https://openapi.akool.com/api/open/v3/liveAvatar/session/pause

Calling this interface will pause the streaming, and the processing of data may be delayed by 0.5s to several seconds. Resending the websocket message will continue streaming. Please note that if you do not send messages for a long time after pausing, the connection will time out and you will need to restart the session.

Request Headers

ParameterValueDescription
AuthorizationBearer tokenYour API Key used for request authorization. You can get from https://openapi.akool.com/api/open/v3/getToken api.

Body Attributes

ParameterTypeValueDescription
idStringNULLsession id: You can get it based on the _id field returned by https://openapi.akool.com/api/open/v3/liveAvatar/session/create .

Response Attributes

ParameterTypeValueDescription
codeint1000Interface returns business status code(1000:success)
msgStringOKInterface returns status information

Example

Request

Response

{
  "code": 1000,
  "msg": "OK"
}

Get Session List

GET https://openapi.akool.com/api/open/v3/liveAvatar/session/list?page=1&size=10&status=1

Request Headers

ParameterValueDescription
AuthorizationBearer tokenYour API Key used for request authorization. You can get from https://openapi.akool.com/api/open/v3/getToken api.

Query Attributes

ParameterTypeValueDescription
pageNumber1Current number of pages,Default is 1.
sizeNumber10Current number of returns per page,Default is 100.
statusNumberNULLsession status: 【1:queueing, 2:processing, 3:completed, 4:failed】.

Response Attributes

ParameterTypeValueDescription
codeint1000Interface returns business status code(1000:success)
msgStringOKInterface returns status information
dataArray{count: 1, data: [{ task_id: "xx", stream_urls: {} }] }task_id: task id of session. url: the url of live avatar.

Example

Request

Response

{
  "code": 1000,
  "msg": "OK",
  "data": {
    "count": 18,
    "result": [
      {
        "stream_urls": {
          "client_pull_stream_url": "https://stream-open.akool.io:8443/final_openapi_live/20240615060910789_3712.flv",
          "client_push_stream_url": "https://stream-open.akool.io:8443/openapi_live/20240615060910789_3712.whip"
        },
        "_id": "666d3006247f07725af0f884",
        "uid": 100010,
        "type": 1,
        "status": 1,
        "task_id": "666d300635d473f81c8be7b1"
      }
    ]
    }
}

Live Avatar WebSocket

WSS client_chat_room_url

you can get the url client_chat_room_url from the interface 【Create session】. like wss://stream-open.akool.io:8443/final_open_live/client_3835.chat

Receive Data

ParameterTypeValueDescription
typeStringchatdefault chat.
payloadStringTo pass in content, you need to serialize the json content.
payload.message_idStringMessage id. The same id indicates that the incoming data belongs to the same message.
payload.voice_idStringVoice model id, you can get the field voice_id from the interface 【Get Voice List Result】.
payload.languageStringLanguage code, you can get the field lang_code from the interface 【Get Language List Result】.
payload.mode_typeString1default 1.
payload.questionStringThe text content passed in, such as ‘Hello’.
payload.promptObjectRegarding the custom description of the digital person.
payload.prompt.fromStringtextthe value range of from is 【text, url】. The default type=“text”
payload.prompt.contentStringWhen type is text, content is the text description of the avatar role. When type is url, content is the pdf link of the description of the avatar role. The link size limit is 50M. The default type=“text” and content=""
toStringServer ID, you can get from server_chat_room_url link address, The address suffix such as server_8898 is the server id.

Example

Send Data

The payload here is not serialized. When using it, you need to use JSON.stringify() to convert the object into a json string. If it is other types, you can convert it to base64 first.

{
    "type": "chat",                         //  default 'chat'.
    "payload": {
      "message_id":"msg-1723629433573",     //  Message id. The same id indicates that the incoming data belongs to the same message.
      "voice_id":"21m00Tcm4TlvDq8ikWAM",    //  Voice model id, you can get the field *voice_id* from the interface 【Get Voice List Result】.
      "language":"en",                      //  Language code, you can get the field 'lang_code' from the interface 【Get Language List Result】
      "mode_type":1,                        //  1 Retelling 2 Dialogue, default *1*.
      "prompt":{
        "from": "text", 
        "content": ""
      },
      "question":"Hello"                    //  The text content passed in, such as 'Hello'.
    },
    "to": "server_8898"   //  Server ID, you can get from *server_chat_room_url* link address, The address suffix such as server_8898 is the server id.
}

Receive Data

The payload has been parsed here. In actual use, you need to perform JSON.parse() to restore it first.

{
    "type": "chat",                       //  default 'chat'.
    "from": "server_8898",                //  Current server id.
    "to": "client_8898",                  //  Current client id.
    "payload": {
      "message_id": "msg-1723629433573",  //  Message id. The same id indicates that the incoming data belongs to the same message.
      "voice_id": "21m00Tcm4TlvDq8ikWAM", //  Voice model id, you can get the field *voice_id* from the interface 【Get Voice List Result】.
      "language": "English",              //  Language
      "mode_type": 1,                     //  default *1*.
      "prompt": {
        "from": "text", 
        "content": ""
      },
      "question": "",                     //  Current input question
      "answer": "Hello!  How can I assist you today? "  // avatar's answer
    }
}

Response Code Description

Please note that if the value of the response code is not equal to 1000, the request is failed or wrong

ParameterValueDescription
code1000Success
code1003Parameter error or Parameter can not beempty
code1008The content you get does not exist
code1009Youdo not have permission to operate
code1101Invalid authorization or Therequest token has expired
code1102Authorization cannot be empty
code1200The account has been banned
code1201create audio error, pleasetry again later
code1202The same video cannot be translated lipSync inthe same language more than 1 times
code1203video should be with audio
code1204Your video duration is exceed 60s!
code1205Create videoerror, please try again later
code1207The video you are using exceeds thesize limit allowed by the system by 300M
code1209Please upload a videoin another encoding format
code1210The video you are using exceeds thevalue allowed by the system by 60fp
code1211Create lipsync error, pleasetry again later