API Reference
XAI Subaccount API Usage Guide
Welcome to the Subaccount API of XAI system. We provide developers with a comprehensive set of APIs to help you easily manage and operate subaccounts in your application. This document will provide you with detailed instructions on how to use these APIs, including interface functions, call methods, parameter descriptions, and sample code. Through our API system, you can easily create and manage subaccounts, allocate features and resources to your team members or share them with your friends. Whether it's for business collaboration, project management, or simple sharing, our subaccount management features offer maximum flexibility and convenience. Start using our APIs now, embark on an intelligent allocation journey, and enjoy the potential benefits and value-added services that come with it!
1. Create Subaccount
Request
curl -X POST -H "Authorization: Bearer $key" -d '{"Name": "child-1", "Email": "[email protected]", "CreditGranted": 100}' https://api.proxyxai.com/x-users
curl -X POST -H "Authorization: Bearer $key" -d '{"Name": "child-1", "Email": "[email protected]", "CreditGranted": 100, "Alias": "Nickname"}' https://api.proxyxai.com/x-users
Response
Response data contains the parent account information
{
"Action": "add",
"Parent": {
"Child": 1,
"ChildLimit": 88888888,
"CreditBalance": [
{
"amount": 10000,
"balance": 9900,
"granted_at": "2023-10-24T18:38:59.238721706+08:00",
"expires_at": "2024-10-24T18:38:59.238721091+08:00"
}
],
"HardLimit": 1200000,
"ID": 4,
"Level": 0,
"Name": "beta",
"RPM": 6666666,
"Rates": 1,
"SoftLimit": 1000000
},
"User": {
"ID": 7,
"Alias": "Nickname",
"Name": "child-1",
"SecretKey": "sk-Xvszkap0gCd0mA8QlqgARLzutOHq0Pi7OZZnbfhTmxJ3zJsa",
"Updates": {
"Child": 0,
"CreditBalance": [
{
"amount": 100,
"balance": 100,
"granted_at": "2023-10-24T18:46:12.304121985+08:00",
"expires_at": "2024-10-24T18:46:12.304122072+08:00"
}
],
"CreditGranted": 100,
"Email": "[email protected]",
"HardLimit": 100,
"Level": 0,
"Name": "child-1",
"RPM": 6666666,
"Rates": 1,
"SoftLimit": 80
}
}
}
Field description:
The prepaid card is a structure called CreditBalance that includes the following fields:
amount: Recharge card amount
balance: Remaining card balance
reference: Transaction remarks
granted_at: Recharge time
expires_at: Expiration time
CreditGranted Prepaid card recharge amount (As shown above, the default creation and recharge amount are given, so it is $100, this field is only a record of the latest recharge amount size)
Name Account name, unique identifier, cannot be repeated, can be modified (Required field)
Email Account email, unique identifier, cannot be repeated, can be modified (Required field)
CreditGranted Prepaid card recharge amount (Required field)
Alias Account nickname, default is the same as Name (Optional field)
Level Account level, inherited from parent account, cannot be modified
Rates Account rate, inherited from parent account, can be adjusted larger
SecretKey Subaccount API Key, system-generated unique account key, only displayed once at the time of account creation, please keep it safe, no secondary recovery is provided, it can only be discarded and rebuilt if lost
HardLimit Monthly usage hard limit, defaulting to the rounded up integer of the recharge amount, can be reduced (System hard limit, usage beyond this limit will be blocked, can be adjusted upwards according to business needs)
SoftLimit Monthly usage soft limit, defaulting to 80% of the rounded up integer of the recharge amount, can be reduced (System soft limit, usage beyond this limit will receive email reminders)
RPM Maximum requests per minute, default inherited from parent account, can be reduced
2. Get the specified subaccount
Request
curl -X GET -H "Authorization: Bearer $key" "https://api.proxyxai.com/x-users/7"
curl -X GET -H "Authorization: Bearer $key" "https://api.proxyxai.com/x-users/child-1"
curl -X GET -H "Authorization: Bearer $key" "https://api.proxyxai.com/x-users/[email protected]"
curl -X GET -H "Authorization: Bearer $key" "https://api.proxyxai.com/x-users?id=7"
curl -X GET -H "Authorization: Bearer $key" "https://api.proxyxai.com/x-users?name=xxx"
curl -X GET -H "Authorization: Bearer $key" "https://api.proxyxai.com/x-users?email=xxx"
Response
[
{
"ID": 7,
"Level": 0,
"Name": "child-1",
"Rates": 1,
"CreditUsed": 0,
"CreditBalance": [
{
"amount": 100,
"balance": 100,
"granted_at": "2023-10-24T18:46:12.304121985+08:00",
"expires_at": "2024-10-24T18:46:12.304122072+08:00"
}
],
"CreditGranted": 100,
"HardLimit": 100,
"SoftLimit": 80,
"RPM": 6666666,
"ChildLimit": 88888888,
"Child": 0,
"Requests": 0,
"Status": true,
"Email": "[email protected]",
"PartialKey": "0Pi7OZZnbfhTmxJ3zJsa",
"SecretKey": "***",
"CreatedAt": "2023-10-24T18:46:12.306937+08:00",
"UpdatedAt": "2023-10-24T18:46:12.306937+08:00"
}
]
Field description:
"SecretKey": "***",
This field is different from the plaintext information when created, as it is encrypted storage
3. Get all subaccounts
Request
curl -X GET -H "Authorization: Bearer $key" "https://api.proxyxai.com/x-users"
curl -X GET -H "Authorization: Bearer $key" "https://api.proxyxai.com/x-users?page=1&size=10"
Response
[
{
"ID": 8,
"Level": 0,
"Name": "child-2",
"Rates": 1,
"CreditUsed": 0,
"CreditBalance": [
{
"amount": 100,
"balance": 100,
"granted_at": "2023-10-24T18:49:53.716420048+08:00",
"expires_at": "2024-10-24T18:49:53.716420138+08:00"
}
],
"CreditGranted": 100,
"HardLimit": 100,
"SoftLimit": 80,
"RPM": 6666666,
"ChildLimit": 88888888,
"Child": 0,
"Requests": 0,
"Status": true,
"Email": "[email protected]",
"PartialKey": "eQGRm3H3tyDDdCzGEACC",
"SecretKey": "***",
"CreatedAt": "2023-10-24T18:49:53.71827+08:00",
"UpdatedAt": "2023-10-24T18:49:53.71827+08:00"
},
{
"ID": 7,
"Level": 0,
"Name": "child-1",
"Rates": 1,
"CreditUsed": 0,
"CreditBalance": [
{
"amount": 100,
"balance": 100,
"granted_at": "2023-10-24T18:46:12.304121985+08:00",
"expires_at": "2024-10-24T18:46:12.304122072+08:00"
}
],
"CreditGranted": 100,
"HardLimit": 100,
"SoftLimit": 80,
"RPM": 6666666,
"ChildLimit": 88888888,
"Child": 0,
"Requests": 0,
"Status": true,
"Email": "[email protected]",
"PartialKey": "0Pi7OZZnbfhTmxJ3zJsa",
"SecretKey": "***",
"CreatedAt": "2023-10-24T18:46:12.306937+08:00",
"UpdatedAt": "2023-10-24T18:46:12.306937+08:00"
}
]
4. Get specified descendant accounts
Request
curl -X GET -H "Authorization: Bearer $key" "https://api.proxyxai.com/x-dna/7"
curl -X GET -H "Authorization: Bearer $key" "https://api.proxyxai.com/x-dna/child-1"
curl -X GET -H "Authorization: Bearer $key" "https://api.proxyxai.com/x-dna/[email protected]"
curl -X GET -H "Authorization: Bearer $key" "https://api.proxyxai.com/x-dna?id=7"
curl -X GET -H "Authorization: Bearer $key" "https://api.proxyxai.com/x-dna?name=xxx"
curl -X GET -H "Authorization: Bearer $key" "https://api.proxyxai.com/x-dna?email=xxx"
5. Get all descendant accounts
Request
curl -X GET -H "Authorization: Bearer $key" "https://api.proxyxai.com/x-dna"
curl -X GET -H "Authorization: Bearer $key" "https://api.proxyxai.com/x-dna?page=1&size=10"
6. Recharge (deduct) subaccount balance
Request
curl -X PUT -H "Authorization: Bearer $key" -d '{"CreditGranted": 100}' "https://api.proxyxai.com/x-users/7"
curl -X PUT -H "Authorization: Bearer $key" -d '{"CreditGranted": 100}' "https://api.proxyxai.com/x-users/child-1"
curl -X PUT -H "Authorization: Bearer $key" -d '{"CreditGranted": -10}' "https://api.proxyxai.com/x-users/child-1"
Recharge Response
{
"Action": "update",
"Parent": {
"Balance": 9720,
"Child": 2,
"ChildLimit": 88888888,
"CreditBalance": [
{
"amount": 10000,
"balance": 9720,
"granted_at": "2023-10-24T18:38:59.238721706+08:00",
"expires_at": "2024-10-24T18:38:59.238721091+08:00"
}
],
"HardLimit": 1200000,
"ID": 4,
"Level": 0,
"Name": "beta",
"RPM": 6666666,
"Rates": 1,
"SoftLimit": 1000000
},
"User": {
"ID": 7,
"Name": "child-1",
"Updates": {
"ChildLimit": 88888888,
"CreditBalance": [
{
"amount": 100,
"balance": 100,
"granted_at": "2023-10-24T18:46:12.304121985+08:00",
"expires_at": "2024-10-24T18:46:12.304122072+08:00"
},
{
"amount": 80,
"balance": 80,
"granted_at": "2023-10-24T18:52:18.074094181+08:00",
"expires_at": "2024-10-24T18:52:18.074092875+08:00"
}
],
"Balance": 180,
"CreditGranted": 80,
"Email": "[email protected]",
"HardLimit": 100,
"Level": 0,
"Name": "child-1",
"RPM": 6666666,
"Rates": 1,
"SoftLimit": 80,
"Status": true
}
}
}
Deduct Response
{
"Action": "update",
"Parent": {
"Balance": 9769.8,
"Child": 2,
"ChildLimit": 88888888,
"CreditBalance": [
{
"amount": 50,
"balance": 50,
"granted_at": "2023-10-24T18:55:16.315242864+08:00",
"expires_at": "2024-08-19T18:55:16.315242707+08:00"
},
{
"amount": 10000,
"balance": 9719.8,
"granted_at": "2023-10-24T18:38:59.238721706+08:00",
"expires_at": "2024-10-24T18:38:59.238721091+08:00"
}
],
"HardLimit": 1200000,
"ID": 4,
"Level": 0,
"Name": "beta",
"RPM": 6666666,
"Rates": 1,
"SoftLimit": 1000000
},
"User": {
"ID": 7,
"Name": "child-1",
"Updates": {
"ChildLimit": 88888888,
"CreditBalance": [
{
"amount": 100,
"balance": 50,
"granted_at": "2023-10-24T18:46:12.304121985+08:00",
"expires_at": "2024-10-24T18:46:12.304122072+08:00"
},
{
"amount": 80,
"balance": 80,
"granted_at": "2023-10-24T18:52:18.074094181+08:00",
"expires_at": "2024-10-24T18:52:18.074092875+08:00"
}
],
"Balance": 180,
"CreditGranted": -50,
"Email": "[email protected]",
"HardLimit": 200,
"Level": 0,
"Name": "child-1",
"RPM": 6666666,
"Rates": 1,
"SoftLimit": 80,
"Status": true
}
}
}
Field explanation:
Balance Total account balance, which is the sum of the remaining balances of each recharge card in CreditBalance
7. Recharge for subaccount with custom expiration time
curl -X PUT -H "Authorization: Bearer $key" -d '{"CreditGranted": 10, "Days": 30}' https://api.proxyxai.com/x-users/7
curl -X PUT -H "Authorization: Bearer $key" -d '{"CreditGranted": 10, "Days": 30}' https://api.proxyxai.com/x-users/child-1
8. Adjust subaccount rate
Request
curl -X PUT -H "Authorization: Bearer $key" -d '{"Rates": 2}' https://api.proxyxai.com/x-users/7
curl -X PUT -H "Authorization: Bearer $key" -d '{"Rates": 2}' https://api.proxyxai.com/x-users/child-1
Response
{
"Action": "update",
"Parent": {
"Balance": 9769.8,
"Child": 2,
"ChildLimit": 88888888,
"CreditBalance": [
{
"amount": 50,
"balance": 50,
"granted_at": "2023-10-24T18:55:16.315242864+08:00",
"expires_at": "2024-08-19T18:55:16.315242707+08:00"
},
{
"amount": 10000,
"balance": 9719.8,
"granted_at": "2023-10-24T18:38:59.238721706+08:00",
"expires_at": "2024-10-24T18:38:59.238721091+08:00"
}
],
"HardLimit": 1200000,
"ID": 4,
"Level": 0,
"Name": "beta",
"RPM": 6666666,
"Rates": 1,
"SoftLimit": 1000000
},
"User": {
"ID": 7,
"Name": "child-1",
"Updates": {
"ChildLimit": 88888888,
"CreditBalance": [
{
"amount": 200,
"balance": 100,
"granted_at": "2023-10-24T18:46:12.304121985+08:00",
"expires_at": "2024-10-24T18:46:12.304122072+08:00"
},
{
"amount": 160,
"balance": 160,
"granted_at": "2023-10-24T18:52:18.074094181+08:00",
"expires_at": "2024-10-24T18:52:18.074092875+08:00"
}
],
"Balance": 260,
"CreditGranted": 0,
"Email": "[email protected]",
"HardLimit": 300,
"Level": 0,
"Name": "child-1",
"RPM": 6666666,
"Rates": 2,
"SoftLimit": 80,
"Status": true
}
}
}
9. Adjust subaccount rate limit
Request
curl -X PUT -H "Authorization: Bearer $key" -d '{"RPM": 5}' https://api.proxyxai.com/x-users/7
curl -X PUT -H "Authorization: Bearer $key" -d '{"RPM": 5}' https://api.proxyxai.com/x-users/child-1
10. Adjust subaccount email and name
Request
curl -X PUT -H "Authorization: Bearer $key" -d '{"Email": "[email protected]"}' https://api.proxyxai.com/x-users/7
curl -X PUT -H "Authorization: Bearer $key" -d '{"Name": "child-x"}' https://api.proxyxai.com/x-users/7
curl -X PUT -H "Authorization: Bearer $key" -d '{"Name": "child-x", "Email": "[email protected]"}' https://api.proxyxai.com/x-users/7
11. Delete subaccount
Request
curl -X DELETE -H "Authorization: Bearer $key" https://api.proxyxai.com/x-users/7
curl -X DELETE -H "Authorization: Bearer $key" https://api.proxyxai.com/x-users/child-1
Response
{
"Action": "delete",
"Parent": {
"CreditBalance": [
{
"amount": 129.8,
"balance": 129.8,
"granted_at": "2023-10-24T19:05:14.133984009+08:00",
"expires_at": "2024-04-21T19:05:14.133983832+08:00"
},
{
"amount": 50,
"balance": 50,
"granted_at": "2023-10-24T18:55:16.315242864+08:00",
"expires_at": "2024-08-19T18:55:16.315242707+08:00"
},
{
"amount": 10000,
"balance": 9719.8,
"granted_at": "2023-10-24T18:38:59.238721706+08:00",
"expires_at": "2024-10-24T18:38:59.238721091+08:00"
}
],
"ID": 4,
"Name": "beta",
"Rates": 1
},
"User": {
"CreditBalance": [
{
"amount": 200,
"balance": 100,
"granted_at": "2023-10-24T18:46:12.304121985+08:00",
"expires_at": "2024-10-24T18:46:12.304122072+08:00"
},
{
"amount": 160,
"balance": 160,
"granted_at": "2023-10-24T18:52:18.074094181+08:00",
"expires_at": "2024-10-24T18:52:18.074092875+08:00"
}
],
"ID": 7,
"Name": "child-1",
"Rates": 2
}
}
12. Query the basic attributes of the account to which the current key belongs
Request
curl -X GET -H "Authorization: Bearer $key" "https://api.proxyxai.com/dashboard/x_user/info"
13. Query the current key's usage data for a period of time (up to 12 months)
Request
curl GET -H "Authorization: Bearer $key" "https://api.proxyxai.com/dashboard/billing/usage?start_date=2023-08-10&end_date=2023-11-18"
14. Set a dedicated billing notification email address / custom account alias for subaccount (can be self-adjusted)
Request
curl -X PUT -H "Authorization: Bearer $key" -d '{"BillingEmail": "[email protected]"}' https://api.proxyxai.com/x-users/child-1
curl -X PUT -H "Authorization: Bearer $key" -d '{"Alias": "bob"}' https://api.proxyxai.com/x-users/child-1
15. Access Control: Add / Remove trusted IP whitelist for subaccount
Request
curl -X PUT -H "Authorization: Bearer $key" -d '{"AllowIPs": "49.234.158.212"}' https://api.proxyxai.com/x-users/child-1
curl -X PUT -H "Authorization: Bearer $key" -d '{"AllowIPs": "118.23.21.0/24 119.24.12.11"}' https://api.proxyxai.com/x-users/child-1
curl -X PUT -H "Authorization: Bearer $key" -d '{"AllowIPs": "-49.234.158.212"}' https://api.proxyxai.com/x-users/child-1
curl -X PUT -H "Authorization: Bearer $key" -d '{"AllowIPs": "-118.23.21.0/24,119.24.12.11"}' https://api.proxyxai.com/x-users/child-1
curl -X PUT -H "Authorization: Bearer $key" -d '{"AllowIPs": "*"}' https://api.proxyxai.com/x-users/child-1
curl -X PUT -H "Authorization: Bearer $key" -d '{"AllowIPs": "-*"}' https://api.proxyxai.com/x-users/child-1
16. Access Control: Add / Remove Model whitelist for subaccount
Request
curl -X PUT -H "Authorization: Bearer $key" -d '{"AllowModels": "gpt-3.5-turbo"}' https://api.proxyxai.com/x-users/child-1
curl -X PUT -H "Authorization: Bearer $key" -d '{"AllowModels": "gpt-3.5-turbo gpt-4"}' https://api.proxyxai.com/x-users/child-1
curl -X PUT -H "Authorization: Bearer $key" -d '{"AllowModels": "-gpt-3.5-turbo"}' https://api.proxyxai.com/x-users/child-1
curl -X PUT -H "Authorization: Bearer $key" -d '{"AllowModels": "-gpt-3.5-turbo gpt-4"}' https://api.proxyxai.com/x-users/child-1
curl -X PUT -H "Authorization: Bearer $key" -d '{"AllowModels": "*"}' https://api.proxyxai.com/x-users/child-1
curl -X PUT -H "Authorization: Bearer $key" -d '{"AllowModels": "-*"}' https://api.proxyxai.com/x-users/child-1