API说明

本文为您介绍AUI Kits智能体实时互动场景的API说明。

获取RTCtoken

生成rtc通话的token,供通话场景下使用。

使用说明

  • 请求协议:http/https

  • 请求Path:/api/v2/aiagent/getRtcAuthToken

  • 是否需要授权:是

  • 请求Method:POST

  • 请求ContentType:JSON

  • 依赖配置:biz.live_mic.app_id、biz.live_mic.app_key

请求参数

名称

类型

是否必填

示例值

描述

user_id

String

userid****

用户id

channel_id

String

channelid****

频道id。

说明

如果端侧不传,则由服务器端生成。服务器端生成规则:32uuid字符串(去掉-)

返回数据

名称

类型

示例值

描述

code

Integer

200

业务响应码。参考HTTP响应码

rtc_auth_token

String

eyJnc2xiIjp****

RTCtoken

channel_id

String

channelid****

使用的频道id

timestamp

Long

1700000000

有效期。单位:秒。默认24小时有效

示例

请求示例

{
    "user_id": "usertid****",
    "channel_id":"channelid****"
}

正常返回示例

{
    "code": 200,
    "rtc_auth_token": "eyJnc2xiIjp****",
    "channel_id": "channelid****",
    "timestamp": 1700000000
}

生成直播互动消息所需的token

生成直播互动消息所需的token,供消息对话场景下使用。

使用说明

  • 请求协议:http/https

  • 请求Path:/api/v2/aiagent/generateMessageChatToken

  • 是否需要授权:是

  • 请求Method:POST

  • 请求ContentType:JSON

  • 依赖配置: biz.openapi.access.key、biz.openapi.access.secret

请求参数

名称

类型

是否必填

示例值

描述

ai_agent_id

String

19de81b3b3d94abda22****

智能体Id

user_id

String

userid****

要登录的用户的ID。

仅限A-Z,a-z,0-9及"_",最长64字节

role

String

admin

角色,为admin时,表示该用户可以调用“管控类”接口。默认空。

expire

Integer

3600

超时时间,单位秒,默认3600秒。

region

String

cn-shanghai

智能体所在的区域。详细RegionId,请参见服务接入点

返回数据

名称

类型

示例值

描述

code

Integer

200

业务响应码。参考HTTP响应码

message

String

success

描述信息

request_id

String

7B117AF5-2A16-412C-B127-****

请求阿里云openAPI的请求标识

app_id

String

****

用户的AppID

token

String

acet****

生成的Token

user_id

String

userid****

用户入会的UserId

nonce

String

AK-****

生成Token所用的Nonce

role

String

admin

生成Token所用的角色

timestamp

Long

1700000000

过期时间,过期时间 = 当前时间+过期时长,单位秒

app_sign

String

H4sIAAAAAAAE****

应用AppSign

示例

请求示例

{
    "user_id": "userid****",
    "ai_agent_id":"19de81b3b3d94abda22******",
    "role":"admin",
    "expire":1800,
    "region":"cn-shanghai"
}

正常返回示例

{
    "code": 200,
    "message": "success",
    "role": "admin",
    "user_id": "userid****",
    "app_id": "****",
    "nonce": "AK-****",
    "request_id": "7B117AF5-2A16-412C-B127-****",
    "token": "acet****",
    "timestamp": 1700000000,
    "app_sign": "H4sIAAAAAAAE****",
}

查询智能体实例详情

查询智能体实例,供通话场景使用

使用说明

  • 请求协议:http/https

  • 请求Path:/api/v2/aiagent/describeAIAgentInstance

  • 是否需要授权:是

  • 请求Method:POST

  • 请求ContentType:JSON

  • 依赖配置: biz.openapi.access.key、biz.openapi.access.secret

请求参数

名称

类型

是否必填

示例值

描述

user_id

String

userid****

用户id

ai_agent_instance_id

String

39f8e0bc005e4f309379701645f4****

智能体实例ID

region

String

cn-shanghai

智能体所在的区域。详细RegionId,请参见服务接入点

返回数据

名称

类型

示例值

描述

code

Integer

200

业务响应码。参考HTTP响应码

message

String

success

描述信息

request_id

String

7B117AF5-2A16-412C-B127-****

请求ID

call_log_url

String

https://example.com/call_logs/12345

通话日志的 URL。

runtime_config

String

{"VoiceChat":{"AgentUserId":"voice_agent_001","ChannelId":"voice_channel_001","AuthToken":"your_voice_chat_auth_token"}}

智能体运行时的配置信息。详细内容,请参见

AIAgentRuntimeConfig

status

String

Finished

智能体实例的状态,如 Finished,Executing。

枚举值:

  • Finished:结束。

  • Executing:运行中。

template_config

String

{"VoiceChat": {"AppId": "your_voice_chat_app_id"}}

智能体模板配置。详细内容,请参见AIAgentTemplateConfig

user_data

String

{"Email":"johndoe@example.com","Preferences":{"Language":"en"}}

用户自定义信息。

agent_config

String

{"xxx":"xx"}

智能体模板配置,填写的配置会和控制台上的智能体模板配置进行合并更新。不填写则使用控制台上智能体的默认配置。详细内容,请参见AIAgentConfig

示例

请求示例

{
    "user_id":"userid****",
    "ai_agent_instance_id": "39f8e0bc005e4f309379701645f4****",
    "region":"cn-shanghai"
}

正常返回示例

{
    "code": 200,
    "message": "success",
    "request_id": "7B117AF5-2A16-412C-B127-****",
    "agent_config": "{\"VoiceChat\": {\"AppId\": \"your_voice_chat_app_id\"}}",
    "template_config": "{\"VoiceChat\": {\"AppId\": \"your_voice_chat_app_id\"}}",
    "call_log_url": "https://example.com/call_logs/12345",
    "user_data": "{\"user_id\": \"test\"}",
    "runtime_config": "{\"VoiceChat\":{\"AgentUserId\":\"voice_agent_001\",\"ChannelId\":\"voice_channel_001\",\"AuthToken\":\"your_voice_chat_auth_token\"}}",
    "status": "Finished"
}