StartAIConversation
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.
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: { |
| TTSConfig | No | String | Required parameter, TTS configuration. it is a JSON string: TRTC TTS configuration as follows:. { |
| 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.
- Tencent Cloud SDK 3.0 for Python
- Tencent Cloud SDK 3.0 for Java
- Tencent Cloud SDK 3.0 for PHP
- Tencent Cloud SDK 3.0 for Go
- Tencent Cloud SDK 3.0 for Node.js
- Tencent Cloud SDK 3.0 for .NET
- Tencent Cloud SDK 3.0 for C++
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. |