A2E
  1. Streaming Avatar
A2E
  • AI Avatar API
  • Get Tokens
    • Getting API Tokens (2025 version)
    • Obtain Login Token
      POST
    • Get API token
      POST
    • Delete API token
      POST
    • List api tokens
      GET
    • Getting API Tokens (2025 version)
      GET
  • TTS and Voice Clone
    • List Public TTS Options
      POST
    • List Public TTS Options
      GET
    • List Voice Clone Options
      GET
    • Train TTS Model of The User's Voice (Voice Clone)
      POST
    • List Ongoing Voice Clone Tasks
      GET
    • Generate TTS Audio (Text-to-Speech)
      POST
    • Get Details of a Voice
      GET
    • Delete a User Voice
      DELETE
  • Generate Avatar Videos
    • Generate AI Avatar Videos
      POST
    • List of Result Videos
      POST
    • List of Result Videos
      GET
    • List One or All Avatars
      POST
    • List One or All Avatars
      GET
    • Obtain the Status of One Avatar Video Task
      POST
    • Obtain the List of Personalized Lip-Sync Models
      GET
    • Delete or Cancel a Video
      DELETE
    • Auto Language Detect
      POST
    • Auto Swith to Public Computing Pool
      POST
  • Create Avatars and Train Lip-sync Models
    • Create A Custom Avatar by a Video or an Image
    • Train a Personalized Lip-sync Model (Optional) a.k.a. Continue Training đź’ 
    • Remove A Customized Avatar
    • Get Status of All Tasks
    • Get All Ongoing "Training" Tasks
    • Status of One Task
    • Clone Voice from a Video
  • Background Matting and Replacement
    • Obtain the List of Background Images
    • Add Custom Background Image
    • Delete Custom Image
  • Face Swap
    • Manage Face Swap Resource
      • Add Face Swap Image
      • Get Records of Face Swap Images
      • Delete User Face Swap Image
    • Quickly Preview Face Swap
      • Add User Face Swap Preview
      • Get Status of Face Swap Preview Process
    • Face Swap Tasks
      • Add User Face Swap Task
      • Get Status of Face Swap Task
      • Get Face Swap Task Records
      • Get Details of Face Swap
      • Delete Record
  • AI Dubbing
    • Start dubbing
    • List Dubbing Tasks
    • List All Processing Dubbing Tasks
    • Get Details
    • Delete Record
  • Image to Video
    • Start Image-to-Video
    • Check Status of One Task
    • List Status of All Tasks
    • Delete Record
  • Caption Removal
    • Start Caption Removal
    • Get Records of All Tasks
    • Get Status of All Tasks in Processing
    • Get Details of One Task
    • Delete a Task
  • Streaming Avatar
    • Get All avatars
      GET
    • Get a Streaming Avatar Token
      POST
    • Set QA Context
      POST
    • Get QA Context
      GET
    • Ask a Question to the Avatar
      POST
    • Let the Avatar Speak Directly
      POST
    • Leave the Room
      POST
  • Miscellaneous
    • Add a User
    • Get User Remaining Credits
    • Exchange Diamonds
    • List Available Languages
    • Save URL to A2E's storage
  1. Streaming Avatar

Get a Streaming Avatar Token

Developing
Global Server
https://video.a2e.ai
Global Server
https://video.a2e.ai
POST
/api/v1/streaming-avatar/agora-token
Our AI powering the lip motion and body movements of the avatar operates on our computing clusters. The generated video stream is delivered to the end user using Agora Real-Time Communication (RTC) technology.
Learn how streaming avatar works here.
Experience the demo of our streaming avatar by clicking “Streaming Avatar” at the top of https://www.a2e.ai.
Steps to Create a Streaming Avatar:
1.
Get Agora Room Details: Use this API (/api/v1/streaming-avatar/agora-token) to retrieve the necessary information to join a room of Agora network.
2.
Integrate Video and Audio: Pull the video and audio streams from Agora’s network into your application (e.g., a website).
3.
Interact with the Avatar: Send text or questions to our avatar system. The user will see the avatar responding with synchronized lip motion and dynamic body movements in real-time.
How Streaming Avatar is Charged: At the start of the interaction, the user (API developer) explicitly sets an expiration time for the avatar interaction in UTC. The account of the API developer is immediately charged the corresponding amount of coins based on the set expiration time. If the user leaves the avatar system (Agora room) earlier than the expiration time, the unused coins will be refunded to the account.
This API provides the necessary credentials for frontend integration with Agora Web SDK.
Here's a basic interactive live streaming example of viewer functionality.
import AgoraRTC from "agora-rtc-sdk-ng";

let rtc = {
    // For the local audio and video tracks.
    localAudioTrack: null,
    localVideoTrack: null,
    client: null,
};
// Note: These parameters (appId, channel, token, uid) should be obtained 
// from the API endpoint: /api/v1/streaming-avatar/agora-token
let options = {
    // Pass your app ID here.
    appId: "your_app_id",
    // Set the channel name.
    channel: "test",
    // Use a temp token
    token: "your_temp_token",
    // Uid
    uid: 123456,
};

async function startBasicLiveStreaming() {
    rtc.client = AgoraRTC.createClient({mode: "live", codec: "vp8"});

    window.onload = function () {
        document.getElementById("audience-join").onclick = async function () {
            rtc.client.setClientRole("audience");
            await rtc.client.join(options.appId, options.channel, options.token, options.uid);
            rtc.client.on("user-published", async (user, mediaType) => {
                // Subscribe to a remote user.
                await rtc.client.subscribe(user, mediaType);
                console.log("subscribe success");

                // If the subscribed track is video.
                if (mediaType === "video") {
                    // Get `RemoteVideoTrack` in the `user` object.
                    const remoteVideoTrack = user.videoTrack;
                    // Dynamically create a container in the form of a DIV element for playing the remote video track.
                    const remotePlayerContainer = document.createElement("div");
                    // Specify the ID of the DIV container. You can use the `uid` of the remote user.
                    remotePlayerContainer.id = user.uid.toString();
                    remotePlayerContainer.textContent = "Remote user " + user.uid.toString();
                    remotePlayerContainer.style.width = "640px";
                    remotePlayerContainer.style.height = "480px";
                    document.body.append(remotePlayerContainer);

                    // Play the remote video track.
                    // Pass the DIV container and the SDK dynamically creates a player in the container for playing the remote video track.
                    remoteVideoTrack.play(remotePlayerContainer);
                }

                // If the subscribed track is audio.
                if (mediaType === "audio") {
                    // Get `RemoteAudioTrack` in the `user` object.
                    const remoteAudioTrack = user.audioTrack;
                    // Play the audio track. No need to pass any DOM element.
                    remoteAudioTrack.play();
                }
            });

            rtc.client.on("user-unpublished", user => {
                // Get the dynamically created DIV container.
                const remotePlayerContainer = document.getElementById(user.uid);
                // Destroy the container.
                remotePlayerContainer.remove();
            });
        };

        document.getElementById("leave").onclick = async function () {
            // Close all the local tracks.
            rtc.localAudioTrack.close();
            rtc.localVideoTrack.close();
            // Traverse all remote users.
            rtc.client.remoteUsers.forEach(user => {
                // Destroy the dynamically created DIV containers.
                const playerContainer = document.getElementById(user.uid);
                playerContainer && playerContainer.remove();
            });

            // Leave the channel.
            await rtc.client.leave();
        };
    };
}

startBasicLiveStreaming();
Price: running streaming avatars consumes 1 gold coin every 5 seconds

Request

Authorization
Provide your bearer token in the
Authorization
header when making requests to protected resources.
Example:
Authorization: Bearer ********************
Body Params application/json
avatar_id
string 
required
The id is obtained by /api/v1/streaming-avatar/all_avatars
expire_seconds
integer 
optional
The expire seconds of the obtained token
Default:
60
Example
{
    "avatar_id": "676e1f054c86ff839eae2cc3",
    "expire_seconds": 60
}

Request samples

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
Request Request Example
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://video.a2e.ai/api/v1/streaming-avatar/agora-token' \
--header 'Content-Type: application/json' \
--data-raw '{
    "avatar_id": "676e1f054c86ff839eae2cc3",
    "expire_seconds": 60
}'

Responses

🟢200OK
application/json
Body
code
integer 
required
0 is OK
data
object 
required
response data
token
string 
required
sreaming avatar token
appId
string 
required
sreaming avatar appid
channel
string 
required
channel
expire_epoch_timestamp
number 
required
the expiration epoch timestamp. Your resource will be released after this time. Note that you need to call "Leave the Room" API if your user leaves the room earlier. Otherwise our system will keep deducting your coins unless the expiration time.
expire_date_UTC
string 
required
the expiration date in UTC format. Your resource will be released after this time. Note that you need to call "Leave the Room" API if your user leaves the room earlier. Otherwise our system will keep deducting your coins unless the expiration time.
uid
number 
required
the uid
trace_id
string 
required
Example
{
    "code": 0,
    "data": {
        "token": "007eJxTYNAXcQ3j/95/6dKbhdr7/3VcW1Ol9Oz647Ypp9cp/ZyoKHlLgcHA0DjRxMAyMSk5JckkOdXAwjjFwDAtzTg5yTDZ3CI1+Z95VroNAwODx6t/TIwMjAwsQAziM4FJZjDJAiZZGdIsTNJSOBmMLS2NTY2MjUwB4uEkxg==",
        "appId": "013a409abcdb4ce083d01ff3cb1c78ec",
        "channel": "f84fd",
        "expire_epoch_timestamp": 1735014458.862645,
        "expire_date_UTC": "2024-12-24 04:27:38",
        "uid": 360923290
    },
    "trace_id": "20ca058a-62b6-40d5-b33d-546220b8bfcd"
}
đź”´500Server Error
Modified at 2025-06-12 03:35:40
Previous
Get All avatars
Next
Set QA Context
Built with