Detailed Parameters
Version History
| Date | Update Summary |
|---|---|
| 2026-10-16 | Added optional customer_rtc and managed_rtc parameters to Create a Live Stream (choose a platform-managed RTC provider: Alibaba Cloud / Tencent Cloud / Agora / Volcano Engine; defaults to artc if omitted). |
Create a live stream
Creates an editing live stream. Once created, the live stream enters a waiting state; you then need to establish the WebSocket connection and join RTC before going live.
Request example
Response example
Request headers
| Header | Description |
|---|---|
Authorization | vda_<your_api_key>, without the Token prefix |
Content-Type | application/json |
X-Request-ID | A unique request identifier of up to 36 characters (UUID recommended), used solely for request tracing and troubleshooting. |
Request parameters
Two RTC access modes are supported:
When rtc_info is omitted, the platform creates and manages the RTC channel (Alibaba Cloud RTC by default, provider=artc), and the response returns the join credentials rtc and the edited-result stream UID render_uid.
When rtc_info is provided, the platform no longer creates a channel and connects directly to your own RTC channel instead; in that case rtc and render_uid in the response are empty. See "Publishing and subscribing" for details.
image_urlstringRequiredssupload:?id=...), base64 data URI (data:image/*;base64,...), and http(s) URL.editing_typestringstyle_transfer (overall style transfer, the default), virtual_tryon (virtual try-on), subject_replacement (subject replacement), background_replacement (background replacement).rtmp_urlsstring[]rtmp:// and be no longer than 2048 characters. When supplied, the composited result is relayed as a single stream to these addresses when the live stream starts. Omitting it or passing an empty array disables relaying. Duplicate addresses are de-duplicated by the server in their original order. This parameter is not supported when using your own RTC channel; passing a non-empty array returns 400.customer_rtcobjectprovider=artc).managed_rtcobjectprovider=unspecified, it is still artc. Do not pass this together with customer_rtc.customer_rtc object fields
providerstringRequiredapp_idstringOptionalchannel_idstringOptionaltoken.user_idstringOptionaltoken.sub_user_idstringOptionaltokenstringOptionaluser_id. The platform does not validate its content — make sure the format and validity period are correct.agora_int_uidintegerOptionalprovider=agora.provider enum values
| Value | Description |
|---|---|
| artc | Alibaba Cloud RTC (the default provider for the platform-managed channel) |
| trtc | Tencent Cloud RTC |
| agora | Agora RTC |
| volcengine | Volcano Engine RTC |
managed_rtc object fields
providerstringOptionalunspecified, it is treated as artc.enable_recordingbooleanOptionalResponse example
Response example
Response parameters
liveobjectrtcobjectapp_id / channel_id / user_id / token / token_expire_at / provider). The provider is specified by managed_rtc.provider, defaulting to artc. Empty when using your own RTC channel.render_uidstringclient_secretstringrtc.token_expire_at. Pass it in the query string of /ws/live/connect. Server-side integrations can use the Authorization header instead and do not need this field.live object fields
idstringlive_id). Subsequent connections and all signals use this value.statusstringlive_durationintegercreated_at / start_time / end_timestring (Unix timestamp, in seconds)0 when the live stream has not started or has not ended.close_reasonstringtrace_idstringstatus enum values
| Value | Description |
|---|---|
waiting | Created, waiting for the client to connect and go live. |
prepared | Connecting (transitional state). |
on_live | Live, billed normally. |
ending | Ending (transitional state). |
ended | Ended. |
Establish the WebSocket connection
Once created, establish the WebSocket control connection:
| Parameter | Location | Description |
|---|---|---|
Authorization | Request header | Optional; recommended for server-side integration. vda_<your_api_key>, without the Token prefix. When it is supplied together with client_secret, both must resolve to the same identity. |
live_id | Query | Required. The live.id returned by the create endpoint. |
conn_id | Query | A client-generated connection ID (a random string is recommended). It stays constant within a single connection and is used to correlate signal acknowledgements. If omitted, the server generates one; on reconnect you must reuse the value from the first connection. |
client_secret | Query | Required for browser scenarios (mandatory if the Authorization header is not included in the request). Use the client_secret returned by the create endpoint; its validity period matches rtc.token_expire_at. |
After the connection is established, send and receive messages as described in "WebSocket signals". If the connection drops unexpectedly, you can reconnect within the grace period reusing the same live_id and conn_id; if you do not reconnect in time, the live stream ends and billing stops.
Connection initialization signaling (type=1 / type=2)
A conn_init message must be sent immediately after the connection is established to initialize the connection, and the server will return a conn_init_ack. Upon receipt of this successful acknowledgment, the live stream enters the on_live state, and billing begins.
Request Example
In case of failure, success is false, and error_code will be one of the "WebSocket Business Errors"—specifically NOT_READY, SIP_READY_TIMEOUT, LIVE_ENDED, or LIVE_CONN_INIT_FAILED—which should be handled according to the corresponding instructions. The seq_id in the response is the request's seq_id plus 1.
Image / scenario switch signal (type=13)
Request example
| Parameter | Description |
|---|---|
prompts | The reference image array: at most one entry, and it must have type=image. content accepts a platform upload URI, a base64 data URI, or an http(s) URL, in the same format as image_url at creation time. If omitted, the most recently supplied reference image is reused. Note: A single WebSocket message is limited to 16MB, so mind the frame size when sending base64. |
editing_type | The editing scenario type: style_transfer (overall style transfer), virtual_tryon (virtual try-on), subject_replacement (subject replacement), background_replacement (background replacement). If omitted, the most recently supplied scenario is reused; supplying only prompts means "change the image but not the scenario." |
To change the reference image or editing scenario during a live stream, you must supply at least one of prompts or editing_type; both may be supplied together. If neither is supplied, the signal has no effect. On success, no acknowledgement is returned, and the composited picture switches to the new reference image / scenario within a few seconds. On failure, the server returns a type=14 acknowledgement (success=false, carrying error_code / error_msg); you can correct the request and resend it with a new seq_id. The server does not deduplicate signals, so sending the same one repeatedly triggers repeated switches.
Hangup (type=5)
Send the hangup signal when you are finished. The server stops the live stream, stops billing, and closes the connection.
Request example
Publishing and subscribing
Platform-managed channel (default, when rtc_info is not provided)
Use the Alibaba Cloud RTC (AliRTC) SDK with the rtc credentials returned by the create call (app_id / channel_id / user_id / token) to join the channel. You must integrate the AliRTC SDK separately; for the web, refer to the Alibaba Cloud RTC Web SDK documentation and load the corresponding SDK in your page.
- Publish the editing input stream: after joining, publish the camera feed (or a local video file stream) as the editing input.
- Subscribe to the composited result: subscribe to the
render_uiduser's video stream in the channel — that is the real-time edited picture. - Credential validity: join the channel before
token_expire_at. A live stream that exceeds the maximum duration for a single session ends automatically. Using your own RTC channel (passingrtc_info) The platform no longer creates a channel; it connects directly to the real-time audio/video input using the channel and authentication information you provide inrtc_info, and produces the edited result stream inside your channel. In this case,rtcandrender_uidin the create response are empty. - Join the channel: use your own integrated RTC SDK (matching
provider) to join thechannel_idchannel. - Publish the editing input stream: publish the camera feed (or a local video file stream) under the identity
sub_user_id; the platform subscribes to your input based on this ID.sub_user_idmust match the user ID your App actually uses to publish. - Subscribe to the edited result: the edited result stream is published in your channel under the identity
user_id; subscribing to that user's video stream gets you the composited edited picture. Keepuser_iddistinct from the ID you use to publish. - Authentication credential:
tokenmust matchuser_id. The platform does not validate its content — make sure the format and validity period are correct yourself.
RTMP relay
Passing rtmp_urls at creation time enables relaying. When the live stream starts, the server relays the composited result (that is, the render_uid rendered stream) as-is, as a single stream, to each address you supplied. You can watch it on the corresponding live platform using the playback address (for example, FLV or HLS).
- The relay address must be a push address on your own live platform (
rtmp://). The push and playback addresses are provided by your live platform. - The same push address cannot be used by multiple live streams at the same time; after a live stream ends, the same address cannot be reused immediately (roughly 10 seconds).
- Relaying forwards the original stream, so quality and resolution match the
render_uidrendered stream in the channel. - If the relay fails to start, the live stream ends immediately (see
live.close_reasonfor the reason). Verify the address and create a new live stream. - RTMP relay is not supported when using your own RTC channel (passing
rtc_info); passing a non-emptyrtmp_urlsin that case returns 400.
Error responses
HTTP errors
When the create endpoint fails, it returns an HTTP status code with the following response body structure:
On failure, metadata may carry a trace_id. Provide it when contacting platform support.
| HTTP status | Scenario | Description |
|---|---|---|
| 400 | image_url missing or unsupported format | Only three forms are supported: platform upload URI, base64 data URI, and http(s) URL. |
| 400 | rtmp_urls invalid | Contains an entry without the rtmp:// prefix, an entry longer than 2048 characters, or more than 5 addresses. |
| 400 | editing_type invalid | The value is not within the enum range. |
| 400 | Using your own RTC channel (passing rtc_info) with a non-empty rtmp_urls, or passing rtmp_urls while the managed provider is not artc (managed_rtc.provider is trtc/agora/volcengine) | RTMP relay is not supported when using your own RTC channel; remove rtmp_urls or pass an empty array. Result-stream relaying is only supported on the platform-managed artc channel. |
| 400 | rtc_info.provider missing or invalid (or customer_rtc.provider, managed_rtc.provider missing or invalid) | The value must be one of artc / trtc / agora / volcengine. |
| 400 | customer_rtc and rtc_info passed together | The two fields have the same meaning; only one may be passed. |
| 400 | Your own RTC (customer_rtc / rtc_info) passed together with managed_rtc | Your own channel and the platform-managed channel are mutually exclusive. |
| 503 | The selected managed provider is currently unavailable (not enabled on the server) | That provider is temporarily unavailable; use a different provider or retry later. |
| 400 | Insufficient account credits | Below the minimum credits required for creation (error code CreditInsufficient). Top up and retry. |
| 429 | Concurrent live stream limit exceeded | The account has reached the maximum number of simultaneous live streams. End an in-progress live stream first. |
WebSocket business errors
Connection initialization failures are returned with the type=2 acknowledgement, and image-switch failures with the type=14 acknowledgement (success=false). The reason is carried in the error_code field:
| error_code | Description |
|---|---|
NOT_READY | The server is not yet ready during initialization; returned with the type=2 acknowledgement. The client should resend conn_init after a short wait. Retries are subject to a server-side budget; once that budget is exceeded the live stream ends and a terminal error is returned, at which point you should stop retrying. |
SIP_READY_TIMEOUT | Server-readiness retries exceeded the limit and the live stream has ended. Create a new live stream. |
LIVE_ENDED | The live stream has ended (or was closed by the platform). Create a new live stream. |
LIVE_CONN_INIT_FAILED | Initialization failed with an unclassified error. You can retry conn_init later; if it keeps failing, contact platform support and provide the trace_id. |
SWITCH_PROMPT_INVALID | Invalid parameters, such as missing both image and scenario, or an image count or format that does not meet the requirements. |
LIVE_NOT_ACTIVE | The live stream is not in progress (not yet started or already ended). |
RENDER_NOT_READY | The rendering service is not ready. Retry later. |
SWITCH_PROMPT_EXPIRED | The signal has expired. Resend with a new seq_id. |
RENDER_WRITE_FAILED | Failed to deliver to the rendering service. Retry. |
SWITCH_PROMPT_TIMEOUT | Processing timed out. Retry. |
SWITCH_PROMPT_INTERNAL_ERROR | Internal service error. If it persists, contact platform support and provide the trace_id. |
Billing
Live streams are billed by actual live duration in seconds, with the remainder settled when the stream ends. 1 credit per second (CNY 0.03125).
Billing window: from the moment the server returns conn_init_ack.success=true (the stream enters on_live) until the hangup signal ends the live stream. Establishing the WebSocket connection alone or joining the RTC channel alone is not billed.
After the live stream ends, you can call GET /live/v1/lives/{live_id} (using live.id) to read billed_seconds (billed seconds) and credits_cost (credits consumed).
FAQ
This is expected behaviour, not a fault. After a successful handshake the server sends nothing on its own; it waits for the client to send conn_init. Check that:
1. You sent the type=1conn_init signal immediately after connecting.
2. live_id and conn_id exactly match the connection query parameters (note that live_id must be a string in JSON, not a number).
Troubleshoot in this order:
1. Whether client_secret has expired. Once expired, the connection is rejected outright. Recreate the live stream rather than troubleshooting network issues on an expired credential.
2. Whether client_secret belongs to this live stream. The credential is bound to a specific live_id; using live stream A's credential to connect to live stream B is rejected.
3. Whether the API key matches the environment. A China (mainland) key connecting to an overseas domain (or vice versa) is rejected.
No. switch_prompt returns no acknowledgement on success, by design. You only receive a type=14 on failure. The server also does not de-duplicate this signal, so sending it repeatedly triggers repeated switches. Do not use a "resend when there is no acknowledgement" strategy.
It can test the handshake, but not send or receive signals. Some system-bundled builds of curl are not compiled with the WebSocket protocol and will report Protocol "wss" not supported; that is unrelated to the server. To actually send and receive signals, use a client that supports WebSocket (browser DevTools, Node.js WebSocket, Python websockets, and so on).
When using Alibaba RTC, it is easy to enter the wrong console entrance. Please use this address: https://live.console.aliyun.com/#/liveRtc/list. The specific steps: in the Live Video console → left navigation bar, go to Live+ > Real-Time Audio & Video > Application Management > Create Application.<live-doc-mark color="yellow">
</live-doc-mark>After creation, click "Manage" and get the AppID and AppKey on the Basic Information page.
The Linux server-side cannot use the trial package; you need to purchase the flagship edition and contact customer service to enable the permission. The following environments can use the trial package without contacting customer service: iOS, Android, HarmonyOS, Mac, Windows, Web, Electron, Flutter, uni-app, and WeChat Mini Program.
To get the Linux SDK trial package, fill out this application form: https://cloud.tencent.com/apply/p/435hepcpuft — the system will grant a free 30-day Linux trial within 1–2 days.