xuan
Published on 2024-12-30 / 13 Visits
0

集成商API接口

注意:服务器地址:https://txapi-usa.lbai.ai

1. 在小美服务端创建用户

接口描述

为用户开启小美AI能力.为用户创建唯一的用户id,并给其开启记忆空间,文件空间和AI伙伴.返回用户token长期有效.

接口地址

GET /ai-api/v1/apiService/addUser?identifier=

请求头

Authorization:Bearer cpn-xxxxxxxxxxxxxxxxxxxxxx (企业token)

请求参数

参数名称

必选

类型

描述

identifier

String

用户的唯一标识,可以是手机号,邮箱号或该用户在集成商服务中的userId.我方会校验其唯一性,防止重复创建. (数字,英文字符) 长度10-50

groupId

String

可传0,1,2,3.... 标记不同用户群体.

nickName

String

昵称

headPic

String

头像url (三方自定义链接)

validity

int

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)

请求参数

参数名称

必选

类型

描述

userId

String

用户id

validity

int

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)

请求参数

参数名称

必选

类型

描述

user_id

String

请求示例

/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)

请求参数

参数名称

必选

类型

描述

userId

String

groupId

请求示例

/ai-api/v1/costByUser?userId=11&groupId=  
  -H "Content-Type: application/json"  
  -H "Authorization: xxxxx"  

回复参数

参数名称

类型

描述

usage

Integer

晶片消耗量

回复示例

{
    "data": {
      "usage": 3332
    },
    "errorCode": 0,
    "message": "成功",
    "success": true
}

✅5.2 用户费用明细查询

接口描述

查询单一用户的晶片消耗明细.按时间倒排(userId和groupId至少有一个不为空)

接口地址

GET /ai-api/v1/costListByUser|

请求头

Authorization:Bearer cpn-xxxxxxxxxxxxxxxxxxxxxx (企业token)

请求参数

参数名称

必选

类型

描述

userId

String

groupId

String

startTime

string

2024-01-10 00:00:00

endTime

string

2024-01-11 00:00:00

pageSize

Integer

pageNum

Integer

请求示例

/ai-api/v1/costListByUser?userId=  
-H "Content-Type: application/json"  
-H "Authorization: xxxxx" 

回复参数

参数名称

类型

描述

id

Long

消费记录id

costUsage

Integer

用户晶片消耗量.

consumeTime

Date

消费时间

consumeName

String

消费项目名

回复示例

{
  "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  
}