Access Control (ACL)
The XAI XAPI provides a powerful Access Control List (ACL) mechanism, allowing you to finely manage the API call behavior of an account to enhance security.
IP Allowlist (AllowIPs)
By setting AllowIPs, you can restrict an account to make API calls only from specified IP addresses or IP ranges. This is crucial for protecting your API Key from being leaked and misused.
- Format:
AllowIPsis a string that supports single IPs or CIDR notation. Multiple entries can be separated by spaces or commas. - Example:
"192.168.1.100 10.0.0.0/8"means that only requests from192.168.1.100and the10.0.0.0/8network segment are allowed. - Inheritance Rule: A child user's
AllowIPsmust be a subset of its parent'sAllowIPs. If the parent user has set an IP allowlist, the child user can only further narrow down the scope within that list. - Special Operations:
- Add:
"118.23.21.0/24" - Remove:
"-118.23.21.0/24" - Restore default (no restrictions):
"*" - Allow local calls only:
"-*"
- Add:
Model Allowlist (AllowModels)
By setting AllowModels, you can control which AI models an account is allowed to use. This is very useful for cost control and feature restriction.
- Format:
AllowModelsis a string containing model names, separated by spaces or commas. It supports the use of*as a wildcard. - Example:
"gpt-4o gpt-4o-mini claude-*"means the account can only usegpt-4o,gpt-4o-mini, and all models starting withclaude-. - Inheritance Rule: A child user's
AllowModelsmust be a subset of its parent'sAllowModels. - Special Operations:
- Add:
"gpt-4o gpt-4o-mini" - Remove:
"-gpt-4o" - Restore default (no restrictions):
"*" - Prohibit all models:
"-*"
- Add:
Resource Path Allowlist (Resources)
This is a lower-level access control where you can restrict an account to access only specific API paths (Endpoints).
- Format:
Resourcesis a string containing API paths, separated by spaces or commas. - Example:
"/v1/chat/completions /v1/embeddings"means the account can only perform chat and embedding operations. - Inheritance Rule: A child user's
Resourcesmust be a subset of its parent'sResources. - Special Operations:
- Add:
"/v1/chat/completions" - Remove:
"-/v1/embeddings" - Restore default (no restrictions):
"*"
- Add:
**Security Best Practice**: We strongly recommend setting a strict `AllowIPs` allowlist for all API Keys used in production environments. This is the most effective way to prevent misuse if a key is leaked.