Real-time Face Swap API Documentation
Live Face Swap API provides real-time face swap functionality, supporting real-time face swap operations during live streaming.
Before calling other APIs, you need to obtain an access token first.
Request Headers
Parameter | Value | Description |
---|---|---|
Content-Type | application/json | Request content type |
Request Body
Parameter | Type | Description |
---|---|---|
clientId | String | Client ID |
clientSecret | String | Client secret |
Example Request
Detect faces in an image and get facial landmarks coordinates.
Request Headers
Parameter | Value | Description |
---|---|---|
Authorization | Bearer token | API key for request authorization |
Content-Type | application/json | Request content type |
Request Body
Parameter | Type | Description |
---|---|---|
single_face | Boolean | Whether to detect single face only |
image_url | String | Image URL for face detection |
img | String | Base64 encoded image (optional) |
Example Request
Response
Parameter | Type | Description |
---|---|---|
error_code | int | Error code (0: success) |
error_msg | String | Error message |
landmarks | Array | Facial landmarks coordinates array |
landmarks_str | Array | Facial landmarks coordinates string array |
region | Array | Face region coordinates |
seconds | float | Processing time in seconds |
trx_id | String | Transaction ID |
Response Example
Create a new real-time face swap session.
Request Headers
Parameter | Value | Description |
---|---|---|
Authorization | Bearer token | API key for request authorization |
Content-Type | application/json | Request content type |
Request Body
Parameter | Type | Description |
---|---|---|
sourceImage | Array | Source image information array, each element contains path and opts properties |
Example Request
Response
Parameter | Type | Description |
---|---|---|
code | int | API response business status code (1000: success) |
msg | String | API response status information |
data | Object | Response data object |
Response Example
Status Code Description
faceswap_status
:
Update existing real-time face swap session configuration.
Request Headers
Parameter | Value | Description |
---|---|---|
Authorization | Bearer token | API key for request authorization |
Content-Type | application/json | Request content type |
Request Body
Parameter | Type | Description |
---|---|---|
_id | String | Session ID |
sourceImage | Array | Source image information array, each element contains path and opts properties |
Example Request
Response Example
Close the specified real-time face swap session.
Request Headers
Parameter | Value | Description |
---|---|---|
Authorization | Bearer token | API key for request authorization |
Content-Type | application/json | Request content type |
Request Body
Parameter | Type | Description |
---|---|---|
_id | String | Session ID |
Example Request
Response Example
faceswap_status
statusFor implementing real-time video communication with Agora SDK, you can refer to the following resources:
As shown in the figure above, channel_id
, front_user_id
, and front_rtc_token
correspond to the Channel, User ID, and Token input fields on the page respectively.
These parameters can be obtained after creating a session through the Live Face Swap API. After filling them in, you can experience push/pull streaming and real-time face swap effects.
For optimal performance in live face swap scenarios, it’s recommended to use the following track configurations:
These configurations are optimized for:
music_standard
encoder for better audio qualityThese resources provide complete examples of how to integrate Agora’s real-time video communication SDK, which can be used as a reference for implementing the video streaming part of the live face swap functionality.
Real-time Face Swap API Documentation
Live Face Swap API provides real-time face swap functionality, supporting real-time face swap operations during live streaming.
Before calling other APIs, you need to obtain an access token first.
Request Headers
Parameter | Value | Description |
---|---|---|
Content-Type | application/json | Request content type |
Request Body
Parameter | Type | Description |
---|---|---|
clientId | String | Client ID |
clientSecret | String | Client secret |
Example Request
Detect faces in an image and get facial landmarks coordinates.
Request Headers
Parameter | Value | Description |
---|---|---|
Authorization | Bearer token | API key for request authorization |
Content-Type | application/json | Request content type |
Request Body
Parameter | Type | Description |
---|---|---|
single_face | Boolean | Whether to detect single face only |
image_url | String | Image URL for face detection |
img | String | Base64 encoded image (optional) |
Example Request
Response
Parameter | Type | Description |
---|---|---|
error_code | int | Error code (0: success) |
error_msg | String | Error message |
landmarks | Array | Facial landmarks coordinates array |
landmarks_str | Array | Facial landmarks coordinates string array |
region | Array | Face region coordinates |
seconds | float | Processing time in seconds |
trx_id | String | Transaction ID |
Response Example
Create a new real-time face swap session.
Request Headers
Parameter | Value | Description |
---|---|---|
Authorization | Bearer token | API key for request authorization |
Content-Type | application/json | Request content type |
Request Body
Parameter | Type | Description |
---|---|---|
sourceImage | Array | Source image information array, each element contains path and opts properties |
Example Request
Response
Parameter | Type | Description |
---|---|---|
code | int | API response business status code (1000: success) |
msg | String | API response status information |
data | Object | Response data object |
Response Example
Status Code Description
faceswap_status
:
Update existing real-time face swap session configuration.
Request Headers
Parameter | Value | Description |
---|---|---|
Authorization | Bearer token | API key for request authorization |
Content-Type | application/json | Request content type |
Request Body
Parameter | Type | Description |
---|---|---|
_id | String | Session ID |
sourceImage | Array | Source image information array, each element contains path and opts properties |
Example Request
Response Example
Close the specified real-time face swap session.
Request Headers
Parameter | Value | Description |
---|---|---|
Authorization | Bearer token | API key for request authorization |
Content-Type | application/json | Request content type |
Request Body
Parameter | Type | Description |
---|---|---|
_id | String | Session ID |
Example Request
Response Example
faceswap_status
statusFor implementing real-time video communication with Agora SDK, you can refer to the following resources:
As shown in the figure above, channel_id
, front_user_id
, and front_rtc_token
correspond to the Channel, User ID, and Token input fields on the page respectively.
These parameters can be obtained after creating a session through the Live Face Swap API. After filling them in, you can experience push/pull streaming and real-time face swap effects.
For optimal performance in live face swap scenarios, it’s recommended to use the following track configurations:
These configurations are optimized for:
music_standard
encoder for better audio qualityThese resources provide complete examples of how to integrate Agora’s real-time video communication SDK, which can be used as a reference for implementing the video streaming part of the live face swap functionality.