Admin API Reference
The Admin API provides complete system configuration capabilities for the owner account, including Provider key pool management, model mapping, Level routing, pricing override, and broadcast notifications. All endpoints require owner privileges.
Base Information
Base URL: https://api.xaixapi.com
Authentication: All requests require owner account API Key
Authorization: Bearer sk-Xvs...
Permission: Owner account only (isOwner=true)
Frontend Console: Admin Console / Production
Endpoint Overview
| Module | Endpoint | Description |
|---|---|---|
| Provider Key Management | GET/POST/PUT/DELETE /x-keys | Manage upstream AI Provider key pool |
GET /x-conf | View keys, mappings and sleeping status | |
| System Configuration | GET/PUT/DELETE /x-config | Manage model mapping, Level routing, rate limits etc. |
| Broadcast Notifications | POST/DELETE /x-news | Publish system or targeted notifications |
1. Provider Key Management API
Manage upstream AI Provider key pool, supporting standard Providers (OpenAI, Anthropic, etc.), Azure OpenAI, and Google Vertex AI.
1.1 Query Keys
Endpoint: GET /x-keys
Query Parameters:
id- Filter by key IDlevel- Filter by Level (load pool level)provider- Filter by Provider URLpage/size- Pagination (optional)
Path Filters:
GET /x-keys/{id}- Get by IDGET /x-keys/L{n}- Get by Level (e.g.L2)GET /x-keys/{provider}- Get by Provider (e.g.api.anthropic.com)
Examples:
# Get all keys
curl -H "Authorization: Bearer $API_KEY" \
https://api.xaixapi.com/x-keys
# Get Level 2 keys
curl -H "Authorization: Bearer $API_KEY" \
"https://api.xaixapi.com/x-keys?level=2"
# Get keys of a provider
curl -H "Authorization: Bearer $API_KEY" \
"https://api.xaixapi.com/x-keys?provider=https://api.openai.com"
Response Example:
{
"success": true,
"keys": [
{
"ID": 123,
"Name": "OpenAI Production",
"Level": 1,
"Provider": "https://api.openai.com",
"Status": true,
"CreatedAt": "2025-01-01T00:00:00Z",
"UpdatedAt": "2025-01-15T10:00:00Z"
}
]
}
1.2 Create Key
Endpoint: POST /x-keys
Request Body Fields:
{
"SecretKey": "sk-...", // Upstream API key (required, ≥20 chars)
"Name": "Production - OpenAI", // Display name (optional)
"Level": 1, // Load pool level (required, for routing)
"Provider": "https://api.openai.com", // Upstream API URL (required)
"Status": true, // Enable status (default true)
"Config": { // Special config (optional)
"provider_type": "standard" // standard/azure/vertex
}
}
Configuration Types
1) Standard Configuration
For OpenAI, Anthropic, Mistral, DeepSeek and other standard compatible Providers.
{
"SecretKey": "sk-...",
"Name": "OpenAI Production",
"Level": 1,
"Provider": "https://api.openai.com",
"Status": true,
"Config": {
"provider_type": "standard" // Can be omitted
}
}
2) Azure OpenAI Configuration
{
"SecretKey": "your-azure-api-key",
"Name": "Azure OpenAI",
"Level": 2,
"Provider": "https://your-resource.openai.azure.com",
"Status": true,
"Config": {
"provider_type": "azure",
"model_mapping": {
"gpt-4o": "gpt-4-deployment", // Model name → Deployment name
"gpt-3.5*": "gpt35-turbo", // Supports wildcards
"*": "default-deployment" // Default deployment
},
"api_versions": { // Optional, API version for each endpoint
"chat": "2025-01-01-preview",
"embeddings": "2024-02-01",
"responses": "2025-04-01-preview",
"audio": "2025-03-01-preview",
"images": "2025-04-01-preview"
}
}
}
3) Google Vertex AI Configuration
{
"SecretKey": "sk-placeholder-51chars-xxxxxxxxxxxxxxxxxxxxxxxx",
"Name": "Vertex AI",
"Level": 3,
"Provider": "https://us-central1-aiplatform.googleapis.com",
"Status": true,
"Config": {
"provider_type": "vertex",
"base_url": "https://us-central1-aiplatform.googleapis.com/v1/projects/{project}/locations/{location}",
"project_id": "my-gcp-project",
"client_email": "[email protected]",
"private_key": "-----BEGIN RSA PRIVATE KEY-----\nMIIE...\n-----END RSA PRIVATE KEY-----\n"
}
}
Examples:
# Add standard Provider
curl -X POST https://api.xaixapi.com/x-keys \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"SecretKey": "sk-live-...",
"Name": "OpenAI Main Pool",
"Level": 1,
"Provider": "https://api.openai.com",
"Status": true
}'
# Add Azure OpenAI
curl -X POST https://api.xaixapi.com/x-keys \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"SecretKey": "your-azure-key",
"Name": "Azure GPT-4",
"Level": 2,
"Provider": "https://your-resource.openai.azure.com",
"Status": true,
"Config": {
"provider_type": "azure",
"model_mapping": {"gpt-4o": "gpt-4-deployment"}
}
}'
Behavior Notes:
- After successful creation, system auto-completes
LEVEL_MAPPERbased on Provider - Sensitive fields in Config (e.g. Vertex
private_key) are auto-encrypted - Provider URL cannot self-reference (cannot point to current system)
- Auto-refreshes Redis cache and in-memory structures
1.3 Update Key
Endpoint: PUT /x-keys/{id} or POST /x-keys/{id}
Updatable Fields: Name, Level, Status, Provider, Config, etc.
Example:
curl -X PUT https://api.xaixapi.com/x-keys/123 \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"Level": 2, "Status": true}'
1.4 Delete Key
Endpoint: DELETE /x-keys/{id}
curl -X DELETE https://api.xaixapi.com/x-keys/123 \
-H "Authorization: Bearer $API_KEY"
1.5 Configuration & Observation
Endpoint: GET /x-conf
Returns current owner account's:
Resources- Allowed API pathsLevelMapper/ModelMapper/ModelLimits/SwitchOver- Sleeping keys list (with remaining sleep time)
- Disabled keys list
UserMinBalance/UserApiBalance- Key thresholds
curl -H "Authorization: Bearer $API_KEY" \
https://api.xaixapi.com/x-conf | jq .
2. System Configuration API
Manage owner-level system configuration including model mapping, Level routing, resource allowlist, model rate limits, pricing override, etc.
2.1 Get Configuration
Endpoint: GET /x-config
curl -H "Authorization: Bearer $API_KEY" \
https://api.xaixapi.com/x-config | jq .
Response Example:
{
"success": true,
"oid": 1,
"configs": {
"MODEL_MAPPER": {"gpt-3.5*": "gpt-4o-mini"},
"LEVEL_MAPPER": {"gpt-4*": 2, "claude*": 3},
"SWITCH_OVER": {"1": 2},
"RESOURCES": {"/v1/chat/completions": {}, "/v1/embeddings": {}},
"MODEL_LIMITS": {"gpt-4o": {"rpm": 30, "tpm": 90000}},
"EMAIL_SMTP": "smtp.gmail.com",
"EMAIL_TLS": true,
"PRICING": "{\"ChatPricing\":{\"gpt-4o\":{\"InputText\":3.5}}}"
}
}
2.2 Update Configuration
Endpoint: PUT /x-config or POST /x-config
Content-Type: application/json
Configuration Keys:
| Key | Description | Format | Example |
|---|---|---|---|
MODEL_MAPPER | Model Mapper | source=target | gpt-3.5*=gpt-4o-mini, o*=gpt-4o |
LEVEL_MAPPER | Level Mapper | model=level | gpt-4*=2, claude*=3 |
SWITCH_OVER | Level failover | primary=backup | 1=2, 2=3 |
RESOURCES | Resource Allowlist | comma/space separated | /v1/chat/completions, /v1/embeddings |
MODEL_LIMITS | Model Limits | JSON string/object | See below |
PRICING | Pricing override | JSON string | See 2.3 |
XAI_MAIL | System notification email | string | [email protected] |
EMAIL_SMTP | SMTP server | string | smtp.gmail.com |
EMAIL_PORT | SMTP port | string | 587 |
EMAIL_AUTH | Auth email | string | [email protected] |
EMAIL_PASS | Email password | string | password |
EMAIL_TLS | Enable TLS | string | true |
Example:
curl -X PUT https://api.xaixapi.com/x-config \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"MODEL_MAPPER": "gpt-3.5*=gpt-4o-mini, o*=gpt-4o",
"LEVEL_MAPPER": "gpt-4*=2, claude*=3",
"SWITCH_OVER": "1=2, 2=3",
"RESOURCES": "/v1/chat/completions, /v1/embeddings",
"MODEL_LIMITS": "{\"gpt-4o\": {\"rpm\": 30, \"tpm\": 90000}}",
"EMAIL_SMTP": "smtp.gmail.com",
"EMAIL_TLS": "true"
}'
MODEL_LIMITS Details:
{
"MODEL_LIMITS": {
"gpt-4o": {"rpm": 30, "tpm": 90000},
"claude-3-opus": {"rpm": 20, "tpm": 60000}
}
}
Or as JSON string:
{
"MODEL_LIMITS": "{\"gpt-4o\": {\"rpm\": 30, \"tpm\": 90000}}"
}
Format Notes:
MODEL_MAPPER/LEVEL_MAPPER/SWITCH_OVERusek=vcomma-separated format, auto-trimmedRESOURCESsupports comma/space separation, each item validated as valid pathMODEL_LIMITScan be JSON string or object, object mode supports incremental override
2.3 Pricing Override (PRICING)
Owner accounts can override system default pricing via PRICING config key, only need to specify "delta" different from defaults.
Data Structure:
{
"ChatPricing": {
"<model>": {
"InputText": 0, // USD/1M tokens
"OutputText": 0,
"CachedText": 0,
"CacheWrite": 0,
"ReasonText": 0,
"InputAudio": 0,
"OutputAudio": 0,
"InputImage": 0,
"OutputImage": 0,
"Rates": 1
}
},
"ImgPricing": {
"<model>": {
"Call": 0,
"Rates": 1,
"Sizes": {"1024x1024": 0}
}
},
"AudioPricing": {
"<model>": {
"Input": 0,
"Output": 0,
"Call": 0,
"Rates": 1
}
},
"RerankPricing": {
"<model>": {"Input": 0, "Call": 0, "Rates": 1}
},
"CallPricing": {
"<model>": {"Call": 0, "Rates": 1}
},
"FineTuningPricing": {
"<base-model>": {"InputText": 0, "OutputText": 0, "Rates": 1}
}
}
Field Descriptions:
InputText/OutputText- USD/million tokens (input/output text)CachedText/CacheWrite- USD/million tokens (cache read/write)ReasonText- USD/million tokens (reasoning process, e.g. o1 series)InputAudio/OutputAudio- USD/million equivalent tokens (audio)InputImage/OutputImage- USD/million equivalent tokens (image)Rates- Model-level multiplier (default 1)Call- USD/call (per-call billing)Sizes- Image size pricing (e.g."1024x1024": 0.05)
Example: Minimal Delta Override
my_pricing.json:
{
"ChatPricing": {
"gpt-4o": {
"InputText": 3.5,
"OutputText": 12,
"Rates": 1
}
}
}
Write command:
curl -H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-X PUT https://api.xaixapi.com/x-config \
-d "{\"PRICING\": $(jq -Rs . < my_pricing.json)}"
Read current pricing override:
curl -H "Authorization: Bearer $API_KEY" \
https://api.xaixapi.com/x-config | jq -r '.configs.PRICING'
Validation & Limits:
- JSON size ≤ 128 KB
- Total entries ≤ 1024
- Unknown fields rejected
- All numeric values must be finite and non-negative
Effective Logic:
- Owner override takes precedence
- Uncovered parts fallback to system default (
pricing.json) - Stacks with user-level
Rates/Factormultipliers
2.4 Delete Configuration Items
Endpoint: DELETE /x-config
Revert to system defaults after deletion.
Request Body:
{
"keys": ["MODEL_MAPPER", "PRICING"]
}
Example:
# Clear pricing override, revert to system default
curl -H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-X DELETE https://api.xaixapi.com/x-config \
-d '{"keys": ["PRICING"]}'
3. Broadcast Notifications API
Publish system-wide or targeted user notifications, displayed in Manage console banner.
3.1 Create System News
Endpoint: POST /x-news
Request Body:
{
"title": "System Maintenance Notice",
"content": "System maintenance scheduled for tomorrow 2:00-4:00 AM, service may be interrupted."
}
Field Descriptions:
title- Notification title (required, max 100 chars)content- Notification content (required, max 1000 chars)
Example:
curl -X POST https://api.xaixapi.com/x-news \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"title": "System Maintenance Notice",
"content": "System maintenance scheduled for tomorrow 2:00-4:00 AM."
}'
3.2 Create Targeted News
Endpoint: POST /x-news/{target}
Publish notification to specified user or users under DNA path.
Path Parameter:
{target}- User ID, username, email, or DNA path
Examples:
# Send to specified user
curl -X POST https://api.xaixapi.com/x-news/42 \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"title": "Balance Alert",
"content": "Your account balance is below $10, please recharge."
}'
# Send to all users under DNA path
curl -X POST https://api.xaixapi.com/x-news/.1.42. \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"title": "Team Notification",
"content": "Important notification for your team..."
}'
3.3 Delete News
Endpoint: DELETE /x-news
Request Body:
{
"id": 123
}
Example:
curl -X DELETE https://api.xaixapi.com/x-news \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"id": 123}'
3.4 Get News List
Endpoint: GET /dashboard/news
See Manage API Reference for details.
Use Cases
Case 1: Add Standard Provider
# 1. Add OpenAI Provider
curl -X POST https://api.xaixapi.com/x-keys \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"SecretKey": "sk-live-...",
"Name": "OpenAI Main Pool",
"Level": 1,
"Provider": "https://api.openai.com",
"Status": true
}'
# 2. System auto-completes LEVEL_MAPPER (gpt* → Level 1)
# 3. Verify configuration
curl -H "Authorization: Bearer $API_KEY" \
https://api.xaixapi.com/x-conf | jq '.LevelMapper'
Case 2: Configure Model Mapping and Rate Limits
# 1. Set model mapping (redirect gpt-3.5 to gpt-4o-mini)
# 2. Set Level mapping (gpt-4* uses Level 2)
# 3. Set model rate limits (gpt-4o limited to 30 RPM)
curl -X PUT https://api.xaixapi.com/x-config \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"MODEL_MAPPER": "gpt-3.5*=gpt-4o-mini, o*=gpt-4o",
"LEVEL_MAPPER": "gpt-4*=2, claude*=3",
"MODEL_LIMITS": "{\"gpt-4o\": {\"rpm\": 30, \"tpm\": 90000}}"
}'
Case 3: Configure Azure OpenAI
curl -X POST https://api.xaixapi.com/x-keys \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"SecretKey": "your-azure-key",
"Name": "Azure GPT-4",
"Level": 2,
"Provider": "https://your-resource.openai.azure.com",
"Status": true,
"Config": {
"provider_type": "azure",
"model_mapping": {
"gpt-4o": "gpt-4-deployment",
"gpt-3.5*": "gpt35-turbo"
},
"api_versions": {
"chat": "2025-01-01-preview"
}
}
}'
Case 4: Custom Pricing and Publish Notification
# 1. Create pricing delta file
cat > my_pricing.json <<EOF
{
"ChatPricing": {
"gpt-4o": {"InputText": 3.5, "OutputText": 12}
}
}
EOF
# 2. Upload pricing override
curl -H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-X PUT https://api.xaixapi.com/x-config \
-d "{\"PRICING\": $(jq -Rs . < my_pricing.json)}"
# 3. Publish system notification
curl -X POST https://api.xaixapi.com/x-news \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"title": "Pricing Update",
"content": "GPT-4o model pricing has been updated, check billing page for details."
}'
Best Practices
Provider Management
- Group by Service - Put keys from same service in same Level
- Set Failover - Use
SWITCH_OVERto configure backup Levels - Check Sleeping Keys - Use
GET /x-confto view sleeping status - Reasonable Levels - Divide Levels by cost, speed, reliability
Configuration Management
- Model Mapping Purpose - Use for smooth migration or cost optimization (e.g. map o1 to gpt-4o)
- Careful with RESOURCES - Wrong config may block API access
- MODEL_LIMITS Control - Set strict rate limits for expensive models
- Regular Backups - Use
GET /x-configto export configuration
Pricing Override
- Delta Principle - Only override parts different from system default
- Version Control - Save pricing JSON to file and track in version control
- Test & Verify - After update, verify billing via
/dashboard/bill - Document Changes - Record override reason and time for auditing
Notification Management
- Priority First - System-wide news for critical information
- Concise Content - Avoid overly long notifications
- Clean Expired - Delete expired or invalid notifications
Related Documentation
- Manage API Reference - User management and dashboard API
- Admin Console Guide - Admin UI instructions
- Authentication - API authentication methods
- Glossary - Level, Model Mapper and other concepts