Skip to content
API

API

5. API Interface

The client interacts with the backend via HTTP POST requests.

5.1 Get Video

  • Interface Description: Negotiate and obtain WebRTC video stream

  • Endpoint: /offer

5.1.1 Request Parameters

ParameterTypeRequiredDescription
typestringYMust be offer
sdpstringYWebRTC offer parameter
avatarstringNAvatar ID; default value is avatar_id from startup command parameters
refaudiostringNCloned voice ID; default value is REF_FILE from startup command parameters
reftextstringNText for cloned voice; default value is REF_TEXT from startup command parameters
custom_configstringNJSON string for action choreography configuration; default value is customvideo_config from startup command parameters
Request example:

{
    "sdp": "xxxx",
    "type": "offer"
}

5.1.2 Response Data

ParameterTypeRequiredDescription
typestringYMust be answer
sdpstringYWebRTC answer parameter
sessionidstringYDigital human session ID, used to distinguish multiple digital human streams. Required for all subsequent interfaces.
Response example:

{
    "sdp": "xxxx",
    "type": "answer",
    "sessionid": "d39256ea-c017-4cdc-8d4b-b73fd246d95f"
}

5.2 Send Text

  • Interface Description: Send chat content to the digital human

  • Endpoint: /human

5.2.1 Request Parameters

ParameterTypeRequiredDescription
sessionidstringYDigital human session ID
interruptboolNWhether to interrupt the digital human’s current speech; default is false
typestringYecho: Digital human speaks the input text; chat: Chat with the digital human
textstringYText content
Request example:

{
    "text": "hello",
    "type": "echo",
    "interrupt": true,
    "sessionid": "d39256ea-c017-4cdc-8d4b-b73fd246d95f"
}

5.3 Switch Playback Video

  • Interface Description: Control the digital human to play custom video

  • Endpoint: /set_audiotype

5.3.1 Request Parameters

ParameterTypeRequiredDescription
sessionidstringYDigital human session ID
audiotypeintYVideo content to play, corresponding to custom videos configured on the backend
Request example:

{
    "audiotype": 2,
    "sessionid": "d39256ea-c017-4cdc-8d4b-b73fd246d95f"
}

5.4 Recording

  • Interface Description: Save digital human video recording on the server; file path: data/record.mp4

  • Endpoint: /record

5.4.1 Request Parameters

ParameterTypeRequiredDescription
sessionidstringYDigital human session ID
typestringYstart_record: Start recording; end_record: Stop recording
Request example:

{
    "type": "start_record",
    "sessionid": "d39256ea-c017-4cdc-8d4b-b73fd246d95f"
}

5.5 Interrupt Digital Human Speech

  • Interface Description: Interrupt the digital human’s current speech

  • Endpoint: /interrupt_talk

5.5.1 Request Parameters

ParameterTypeRequiredDescription
sessionidstringYDigital human session ID
Request example:

{
    "sessionid": "d39256ea-c017-4cdc-8d4b-b73fd246d95f"
}

Third-Party Software Integration Process


pc = new RTCPeerConnection();
var offer = pc.localDescription;
Call the API `/offer` with parameters `offer.sdp` and `offer.type`.
Obtain the response data `answer`.
pc.setRemoteDescription(answer); // Set the response to the PC object; video stream will be received afterward.
// For detailed code, refer to web/client.js

Call the API `/human` with `sessionid` from `answer.sessionid` to trigger the digital human to speak.