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.
Digital 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_url
String
The 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
Parameter
Type
Value
Description
code
int
1000
Interface returns business status code(1000:success)
_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
ExampleBody
Copy
{ "_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 }}
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.
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
Parameter
Type
Value
Description
type
String
chat
default chat.
payload
String
To pass in content, you need to serialize the json content.
payload.message_id
String
Message id. The same id indicates that the incoming data belongs to the same message.
payload.voice_id
String
Voice model id, you can get the field voice_id from the interface 【Get Voice List Result】.
payload.language
String
Language code, you can get the field lang_code from the interface 【Get Language List Result】.
payload.mode_type
String
1
default 1.
payload.question
String
The text content passed in, such as ‘Hello’.
payload.prompt
Object
Regarding the custom description of the digital person.
payload.prompt.from
String
text
the value range of from is 【text, url】. The default type=“text”
payload.prompt.content
String
When 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=""
to
String
Server ID, you can get from server_chat_room_url link address, The address suffix such as server_8898 is the server id.
ExampleSend 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.
Copy
{ "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.
Copy
{ "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 }}