注意:服务器地址:https://txapi-usa.lbai.ai
1. 在小美服务端创建用户
接口描述
为用户开启小美AI能力.为用户创建唯一的用户id,并给其开启记忆空间,文件空间和AI伙伴.返回用户token长期有效.
接口地址
GET /ai-api/v1/apiService/addUser?identifier=
请求头
Authorization:Bearer cpn-xxxxxxxxxxxxxxxxxxxxxx (企业token)
请求参数
请求示例
curl /ai-api/v1/apiService/addUser?identifier=xxx
-H "Content-Type: application/json"
-H "Authorization: xxxxx"
回复示例
{
"data": {
"token": "xxxxxx", // 返回给用户的token,用户请求api的时候需要添加到header里 15天有效
"userId": "13000998888932" //小美平台用户唯一标识
},
"errorCode": 0,
"message": null,
"success": true
}
✅2. 获取/更新用户token
接口描述
调用此接口,将生成新token.用户旧token将失效;
接口地址
GET /ai-api/v1/apiService/refreshToken?userId=
请求头
Authorization:Bearer cpn-xxxxxxxxxxxxxxxxxxxxxx (企业token)
请求参数
请求示例
/ai-api/v1/apiService/refreshToken?userId=
-H "Content-Type: application/json"
-H "Authorization: xxxxx"
回复示例
{
"data": {
"token": "xxxxxx" // 返回给用户的token,用户请求api的时候需要添加到header里
},
"errorCode": 0,
"message": "成功",
"success": true
}
✅3. 用户退出登录
接口描述
调用此接口将销毁用户token.
接口地址
GET /ai-api/v1/apiService/logout
请求头
Authorization:Bearer cpn-xxxxxxxxxxxxxxxxxxxxxx (企业token)
请求参数
请求示例
/ai-api/v1/apiService/refreshToken?userId=
-H "Authorization: xxxxx"
回复示例
{
"data": null,
"errorCode": 0,
"message": "成功",
"success": true
}
✅4. 企业查询余额接口
接口描述
查询账号余额
接口地址
GET https://txapi.jxjia.net/ai-api/v1/account/banlance
请求头
Authorization:Bearer cpn-xxxxxxxxxxxxxxxxxxxxxx (企业token)
返回结果
{
"data": {
"balance": 9830602 //余额
},
"errorCode": 0,
"line": null,
"message": "成功",
"success": true
}
✅5. 费用查询
✅5.1 用户费用查询
查询用户总共消耗的晶片. 注意,有些任务异步处理,且很耗时,消耗量会有延迟.
查询用户消耗总费用或者用户所在组的消耗总费用(userId和groupId至少有一个不为空)
接口描述
查询单一用户的晶片消耗量.
接口地址
GET /ai-api/v1/costByUser
请求头
Authorization:Bearer cpn-xxxxxxxxxxxxxxxxxxxxxx (企业token)
请求参数
请求示例
/ai-api/v1/costByUser?userId=11&groupId=
-H "Content-Type: application/json"
-H "Authorization: xxxxx"
回复参数
回复示例
{
"data": {
"usage": 3332
},
"errorCode": 0,
"message": "成功",
"success": true
}
✅5.2 用户费用明细查询
接口描述
查询单一用户的晶片消耗明细.按时间倒排(userId和groupId至少有一个不为空)
接口地址
GET /ai-api/v1/costListByUser|
请求头
Authorization:Bearer cpn-xxxxxxxxxxxxxxxxxxxxxx (企业token)
请求参数
请求示例
/ai-api/v1/costListByUser?userId=
-H "Content-Type: application/json"
-H "Authorization: xxxxx"
回复参数
回复示例
{
"data": {
"isMore": 0,
"items": [
{
"id":"9999",
"costUsage":8888,
"consumeTime":3239923,
"consumeName":"AI伙伴对话"
},{
"id":"9999",
"costUsage":8888,
"consumeTime":3239923,
"consumeName":"AI伙伴对话"
}
],
"pageNum": 1,
"pageSize": 10,
"startIndex": 0,
"totalCount": 2,
"totalPage": 1
},
"errorCode": 0,
"message": "成功",
"success": true
}