最后更新于
这有帮助吗?
这有帮助吗?
{
"text": "string"
}[
{
"name": "string",
"description": "string"
}
]{
"output": {
"audio_routing": "audio_only", // 默认:"audio_only" | "data_only" | "both"
"max_chunk_duration_ms": 100, // 默认:100,范围:10-1000 毫秒
"add_wav_header": false // 默认:false
}
}{
"session_id": "<你在实时会话中的临时会话 id>",
"character_session_id": "<你的会话 id。若是新会话,则返回新生成的值,或返回旧值>",
"room_url": "<客户端需要加入的房间 URL>",
"room_name": "<要加入的房间名称>",
"token": "<客户端加入房间的令牌>",
"end_user_id": "<会话中用户的 end_user_id,若请求中未发送则为 null>"
}{
"detail": "未找到角色,或该角色不属于该用户"
}{
"detail": [
{
"type": "<请求体问题的类型>",
"loc": [],
"msg": "<消息>",
"input": "<输入值>",
"ctx": {
"error": "有关错误的更多详情"
}
}
]
}import requests
url = "https://live.convai.com/connect"
headers = {
"Content-Type": "application/json",
"X-API-Key": "<你的 api 密钥>" # 替换为你实际的 Convai API 密钥
}
data = {
"character_id": "<你的角色 id>",
"connection_type": "audio", # 或 "video"
"character_session_id": "string" # 可选
## 如需指定场景描述
## "scene_description": [
## {
## "name": "string",
## "description": "string"
## }
## ],
## 如需指定动态信息
## "dynamic_info": {
## "text": "string"
## },
}
response = requests.post(url, headers=headers, json=data)
print("状态码:", response.status_code)
print("响应:", response.text)curl --location 'https://live.convai.com/connect' \\
--header 'Content-Type: application/json' \\
--header 'X-API-Key: <你的 api 密钥>' \\
--data '{
"character_id": "<你的角色 id>",
"connection_type": "audio", // 或用于视频功能的 "video"
"character_session_id": "string" // 可选
"dynamic_info": { // 可选
"text": "string"
},
"scene_description": [
{
"name": "string",
"description": "string"
}
], // 可选
}'