A2E
  1. Streaming Avatar
A2E
  • AI Avatar API
  • Get Tokens
    • Getting API Tokens (2025 version)
  • TTS and Voice Clone
    • 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
      GET
    • List One or All Avatars
      GET
    • Obtain the Status of One Avatar Video Task
      POST
    • 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
      POST
    • Train a Personalized Lip-sync Model (Optional) a.k.a. Continue Training đź’ 
      POST
    • Remove A Customized Avatar
      POST
    • Get Status of All Tasks
      GET
    • Get All Ongoing "Training" Tasks
      GET
    • Status of One Task
      GET
    • Clone Voice from a Video
      POST
  • 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
    • Start and Manage Face Swap Tasks
      • Start a 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
    • List Available Languages
    • Save URL to A2E's storage
    • Add Watermark to Video or Image
    • Get R2 Upload Presigned URL
  • Text to Image
    • Start Text-to-Image
    • List Tasks of Text-to-Image Tasks
    • Get Details of One Task
    • Delete Record
    • Quick Add Avarar
  • Talking Photo
    • Start a Task
    • List Tasks
    • Get Task Detail
    • Delete Task
  • Virtual Try-On
    • Start Virtual Try-On
    • List Tasks of Virtual Try-On
    • Get Details of One Task
    • Delete Record
  • Video to Video
    • Start Video to Video
    • List Tasks of Video to Video
    • Get Details of One Task
    • Delete Record
  • Product Avatar
    • Start Product Avatar
  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

Example
{
    "avatar_id": "676e1f054c86ff839eae2cc3",
    "expire_seconds": 60
}

Request Code 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

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