tencent cloud

实时音视频

StartAIConversation

下载
聚焦模式
字号
最后更新时间: 2026-05-21 11:29:15

1. API Description

Domain name for API request: trtc.intl.tencentcloudapi.com.

Start an AI conversation task. The AI Channel Robot joins the TRTC room and performs AI dialogue with specified members inside the room. Suitable for smart customer service, AI spoken language teacher, and other scenarios.

The TRTC AI dialogue function has built-in speech-to-text capability and provides both Channel Service, allowing customers to flexibly designate third-party AI model (LLM) services and Text-to-Audio (TTS) services.

A maximum of 50 requests can be initiated per second for this API.

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter Name Required Type Description
Action Yes String Common Params. The value used for this API: StartAIConversation.
Version Yes String Common Params. The value used for this API: 2019-07-22.
Region Yes String Common Params. For more information, please see the list of regions supported by the product. This API only supports: ap-guangzhou, ap-singapore, ap-tokyo, na-ashburn, na-siliconvalley.
SdkAppId Yes Integer SdkAppId of TRTC, which is the same as the SdkAppId used by the room with transcription task enabled.
RoomId Yes String RoomId of TRTC refers to the room number that enables the conversation task.
AgentConfig Yes AgentConfig Bot parameters.
SessionId No String The unique Id passed by the caller can be used to prevent duplication of task initiation on the client side as well as query task status through this field.
RoomIdType No Integer Type of the TRTC room number. 0 indicates digit room number, 1 indicates string room number. by default if left blank, it is digit room number.
STTConfig No STTConfig Speech recognition configuration.
LLMConfig No String Required parameter, LLM configuration. it must comply with the openai standard and be a JSON String. example:
 { 
  "LLMType": "Model type", // String required, for example: "openai"
  "Model": "your Model name", // String required, specifies the Model to be used
"APIKey": "your LLM API key", // String required
  "APIUrl": "https://API.xxx.com/chat/completions", // String required, the URL for LLM API access
  "History": 10, // Integer optional, sets the context rounds for LLM, default value is 0, maximum value is 50
  "HistoryMode": 1, // Integer optional, 1 means the content in the LLM context will synchronize with playback audio, and text corresponding to unplayed audio will not appear in the context. 0 means no synchronization, default value is 0
  "Streaming": true // Boolean optional, whether to use Streaming
 }
.
TTSConfig No String Required parameter, TTS configuration. it is a JSON string: TRTC TTS configuration as follows:.
 { 
  "TTSType": "flow", // [required] fixed to this value.
  "VoiceId": "v-female-R2s4N9qJ", // [required] premium timbre ID/clone voice ID. selectable different timbres. refer to the following timbre list for ID library.
  "Model": "flow_01_turbo", // (required) current default TTS Model version (corresponds to Flash version).
  "Speed": 1.0, // [option] adjust the speaking rate. value range [0.5-2.0]. default 1.0. the larger the value, the faster the speech speed.
  "Volume": 1.0, // [optional] adjust volume [0,10]. default: 1.0. a larger value indicates higher volume.
  "Pitch": 0, // [optional] adjusts the tone [-12,12]. default value is 0. among them, 0 outputs the original voice type.
  "Language": "zh" // [optional] recommend filling in. currently supports filling in chinese: zh, english: en, cantonese dialect: yue. parameter reference: (ISO 639-1).
 }
ExperimentalParams No String Experimental parameter, contact for background usage.

3. Output Parameters

Parameter Name Type Description
TaskId String For uniquely identifying a conversation task.
RequestId String The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem.

4. Example

Example1 Start an AI Robot Dialogue

Input Example

POST / HTTP/1.1
Host: trtc.intl.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: StartAIConversation
<Common request parameters>

{
    "SdkAppId": 12345678,
    "RoomId": "room_987654321",
    "RoomIdType": 1,
    "AgentConfig": {
        "UserId": "user_12345",
        "UserSig": "user_signature_example",
        "MaxIdleTime": 120,
        "TargetUserId": "target_user_54321"
    },
    "SessionId": "session_1234567890abcdef",
    "STTConfig": {
        "Language": "zh"
    },
    "LLMConfig": "{\"LLMType\": \"openai\", \"Model\": \"gpt-3.5-turbo\", \"APIKey\": \"xxx\", \"APIUrl\": \"http://xxxx-api.xxxx.com/v1/chat/completions\", \"Streaming\": true}",
    "TTSConfig": "{\"TTSType\": \"tencent\", \"AppId\": 130000000, \"SecretId\": \"AKIDxxxxx\", \"SecretKey\": \"HlDxxxxxx\", \"VoiceType\": 1008, \"Speed\": 1}"
}

Output Example

{
    "Response": {
        "TaskId": "v2_20250224_udqgoOzzpAFOoiXR_sHbeVCwys3hy0PLs1uRLvS7wY9mjZMEIQuDPhT",
        "RequestId": "df81f274-c1b8-4342-b0a1-e552072cc48e"
    }
}

5. Developer Resources

SDK

TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

Command Line Interface

6. Error Code

The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

Error Code Description
FailedOperation.NotAbility Unlock the required capability bit.
FailedOperation.NotAllowed This operation is not allowed. submit a ticket to contact us.
FailedOperation.TaskExist Task already exists
InvalidParameter.UserSig UserSig is expired or wrong
ResourceInsufficient.RequestRejection Insufficient resources.

帮助和支持

本页内容是否解决了您的问题?

填写满意度调查问卷,共创更好文档体验。

文档反馈