Appearance
平台开放接口
子账户相关接口
通过CloseAI提供的主账户sk,可以已类似请求openai的方式,请求CloseAI的开放接口。子账户sk无这类访问权限,不需要担心子账户越权操作。
注意:以下历史参数已经废弃,改为由pricing_factor控制的倍率定价,设置了auto_following的模型会自动转为倍率1倍,其余的模型不会自动转换,需要手动调整。
json
{
"prompt_price": 0,
"completion_price": 0,
"auto_following": true
}
查询子账户信息
请求参数(querystring)
shell
alias: 按别名过滤(可不传)
sk: 按token过滤(可不传)
page: 页码,默认为1(可不传)
page_size: 每页返回的数量,为-1时返回全部(可不传)
请求
shell
curl '{API Base}/api/v1/account/sub-account/list?page=1&page_size=10' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer sk-xxxx'
返回
json
{
"items": [
{
"id": 123,
"user_id": 123,
"token": "sk-xxx",
"token_type": "slave",
"alias": "test",
"enabled": true,
"model_pricing": [
{
"model": "gpt-3.5-turbo",
"pricing_factor": 1
}
],
"balance": "100",
"monthly_cost": "0.44000013",
"created_at": "2023-05-24T23:13:16.878831+08:00",
"updated_at": "2023-07-05T12:55:30.048657+08:00"
}
],
"total": 1,
"page": 1,
"pageSize": 10
}
批量创建子账户
参数释义:
shell
alias: 子账户别名
balance:子账户虚拟余额
model_pricing:子账户可用模型及定价,必须显式指定,不指定则无权限使用
count:批量创建的子账户数量
请求
shell
curl --request POST '{API Base}/api/v1/account/sub-account/token' \
--data-raw '{"alias":"test","model_pricing":[{"model":"gpt-3.5-turbo","prompt_price":0,"completion_price":0,"auto_following":true},{"model":"gpt-3.5-turbo-16k","prompt_price":0,"completion_price":0,"auto_following":true},{"model":"gpt-4","prompt_price":0,"completion_price":0,"auto_following":true}],"balance":1,"count":1}' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer sk-xxxx'
响应
json
{
"items": [
{
"id": 123,
"user_id": 123,
"token": "sk-xxxx",
"token_type": "slave",
"alias": "test",
"enabled": true,
"model_pricing": [
{
"model": "gpt-3.5-turbo",
"pricing_factor": 1
},
{
"model": "gpt-3.5-turbo-16k",
"pricing_factor": 1
},
{
"model": "gpt-4",
"pricing_factor": 1
}
],
"balance": "1",
"monthly_cost": "0",
"created_at": "2023-07-09T21:23:16.944115+08:00",
"updated_at": "2023-07-09T21:23:16.944115+08:00"
}
],
"success": true
}
批量编辑子账户模型定价
参数释义:
shell
sks: 需要删除的sk的列表
alias: 子账户别名
model_pricing:子账户可用模型及定价,必须显式指定,不指定则无权限使用
请求
shell
curl --request POST '{API Base}/api/v1/account/sub-account/token/info' \
--data-raw '{"sks":["sk-123"],"alias":"ee4","model_pricing":[{"model":"gpt-3.5-turbo","pricing_factor": 1}]}' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer sk-xxxx'
响应
json
{"success":true}
批量删除子账户
参数释义:
shell
sks: 需要删除的sk的列表
请求
shell
curl --request DELETE '{API Base}/api/v1/account/sub-account/token' \
--data-raw '{"sks":["sk-xxxx"]}' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer sk-xxxx'
响应
json
{"success":true}