Dashboard API

Dashboard APIs provide self-service query capabilities for users, including account status, detailed information, usage statistics, operation logs, and news notifications. The Admin (/admin) and Manage (/manage) consoles primarily use these endpoints to render data, and they are also available for third-party integrations.

All endpoints require an Authorization: Bearer sk-Xvs... header.

Base URL: https://api.xaixapi.com

Endpoint Overview

  • User status: GET /dashboard/status
  • User details: GET /dashboard/info
  • Usage billing: GET /dashboard/bill
  • Operation logs: GET /dashboard/logs
  • News notifications: GET /dashboard/news
  • System configuration: GET /dashboard/conf
  • Model list: GET /dashboard/models

User Status

Get basic status information for the current user, suitable for quick queries.

Endpoint: GET /dashboard/status

Example:

curl -H "Authorization: Bearer $API_KEY" \
  https://api.xaixapi.com/dashboard/status

Response:

{
  "object": "user_status",
  "id": 42,
  "dna": ".1.42.",
  "name": "prod-account",
  "email": "[email protected]",
  "alias": "Production Environment",
  "public_key": "...",
  "balance": 450.25,
  "manage": true,  // Can access Manage console
  "admin": true    // Can access Admin console (owner only)
}

User Details

Get detailed user information including balance breakdown, limit configurations, usage statistics, and access controls.

Endpoint: GET /dashboard/info

Example:

curl -H "Authorization: Bearer $API_KEY" \
  https://api.xaixapi.com/dashboard/info

Response:

{
  "object": "user_info",
  "user": {
    "id": 42,
    "name": "prod-account",
    "email": "[email protected]",
    "alias": "Production Environment",
    "level": 1,
    "gear": 1,
    "role": 1,
    "tier": 1,
    "factor": 1.0,
    "rates": 1.0,
    "dna": ".1.42.",
    "created_at": "2025-01-01T00:00:00Z",
    "updated_at": "2025-01-15T10:00:00Z"
  },
  "balance": {
    "total": 450.25,
    "credits": [
      {
        "amount": 400.00,
        "expires_at": "2025-02-15T00:00:00Z"
      },
      {
        "amount": 50.25,
        "expires_at": "2025-03-01T00:00:00Z"
      }
    ]
  },
  "limits": {
    "hard_limit": 5000,
    "soft_limit": 4000,
    "auto_quota": 0,
    "rpm": 100,
    "rph": 3600,
    "rpd": 10000,
    "tpm": 200000,
    "tph": 6000000,
    "tpd": 50000000
  },
  "usage": {
    "today": {
      "requests": 150,
      "tokens": 450000,
      "cost": 12.50
    },
    "month": {
      "requests": 3500,
      "tokens": 12500000,
      "cost": 285.75
    }
  },
  "restrictions": {
    "allow_ips": ["192.168.1.0/24", "10.0.0.5"],
    "allow_models": ["gpt-4*", "claude-3*"],
    "resources": ["/v1/chat/completions", "/v1/embeddings"]
  },
  "model_limits": {
    "gpt-4": {
      "rpm": 30,
      "tpm": 90000
    },
    "claude-3-opus": {
      "rpm": 20,
      "tpm": 60000
    }
  }
}

Usage Billing

Get usage statistics and billing information with date range support.

Endpoint: GET /dashboard/bill

Query Parameters:

  • date or d - Specific date (YYYY-MM-DD)
  • start or s - Start date
  • end or e - End date
  • days - Past N days (from today)

Billing Notes:

  • Query span >30 days: charged one API fee ($0.01)
  • Query span >365 days: auto-truncated to one year with additional fee ($0.05)

Examples:

# Get current month usage
curl -H "Authorization: Bearer $API_KEY" \
  https://api.xaixapi.com/dashboard/bill

# Get past 30 days usage
curl -H "Authorization: Bearer $API_KEY" \
  "https://api.xaixapi.com/dashboard/bill?days=30"

# Query by date range
curl -H "Authorization: Bearer $API_KEY" \
  "https://api.xaixapi.com/dashboard/bill?start=2025-01-01&end=2025-01-31"

Response:

{
  "object": "list",
  "data": [
    {
      "aggregation_timestamp": 1234567890,
      "n_requests": 1000,
      "n_context_tokens_total": 500000,
      "n_generated_tokens_total": 100000,
      "n_cached_tokens_total": 50000,
      "usage_details": {
        "gpt-4": {
          "requests": 100,
          "prompt": 50000,
          "completion": 10000,
          "cost": 3.5
        }
      }
    }
  ],
  "total_usage": {
    "requests": 10000,
    "prompt_tokens": 5000000,
    "completion_tokens": 1000000,
    "cached_tokens": 500000,
    "cost": 125.50
  }
}

Operation Logs

Get account operation logs with pagination and filtering support.

Endpoint: GET /dashboard/logs

Query Parameters:

  • page - Page number (default: 1)
  • size - Page size (default: 24, max: 100)
  • action - Filter by action type
  • target_id - Filter by target ID
  • status - Filter by status

Examples:

# Get recent logs
curl -H "Authorization: Bearer $API_KEY" \
  https://api.xaixapi.com/dashboard/logs

# Get paginated logs
curl -H "Authorization: Bearer $API_KEY" \
  "https://api.xaixapi.com/dashboard/logs?page=2&size=50"

# Filter specific actions
curl -H "Authorization: Bearer $API_KEY" \
  "https://api.xaixapi.com/dashboard/logs?action=add_user"

Response:

{
  "logs": [
    {
      "id": 123,
      "action": "add_user",
      "operator_id": 1,
      "target_id": 42,
      "details": "Created user with email: [email protected]",
      "ip_address": "192.168.1.100",
      "created_at": "2025-01-15 10:30:00",
      "status": "success"
    }
  ],
  "total": 150,
  "page": 1,
  "size": 24,
  "has_more": true
}

Common Action Types:

  • add_user - Create user
  • update_user - Update user
  • delete_user - Delete user
  • add_key - Add key
  • update_key - Update key
  • delete_key - Delete key
  • rotate_self - Key rotation
  • auto_config - Auto configuration

News Notifications

Get system news and user notifications. UIs display the latest entries as needed.

Endpoint: GET /dashboard/news

Example:

curl -H "Authorization: Bearer $API_KEY" \
  https://api.xaixapi.com/dashboard/news

Response:

{
  "success": true,
  "system_news": [
    {
      "title": "System Update Notice",
      "content": "The system will undergo maintenance...",
      "created_at": "2025-01-15T10:00:00Z",
      "expires_at": "2025-01-22T10:00:00Z"
    }
  ],
  "user_news": [
    {
      "title": "Account Balance Alert",
      "content": "Your account balance is low...",
      "created_at": "2025-01-15T11:00:00Z",
      "expires_at": "2025-02-15T11:00:00Z"
    }
  ],
  "dna_news": [
    {
      "title": "Team Notification",
      "content": "Important notice for your team...",
      "created_at": "2025-01-15T12:00:00Z",
      "expires_at": "2025-02-15T12:00:00Z"
    }
  ]
}

News Type Descriptions:

  • system_news - System-level news (visible to all users)
  • user_news - User-level news (specific users)
  • dna_news - DNA group-level news (users under specific DNA path)

System Configuration

Get global key thresholds and configuration parameters.

Endpoint: GET /dashboard/conf

Example:

curl -H "Authorization: Bearer $API_KEY" \
  https://api.xaixapi.com/dashboard/conf

Response:

{
  "UserMinBalance": 1.0,
  "UserApiBalance": 0.5,
  "SystemVersion": "v2.5.0",
  "Features": {
    "sign_enable": true,
    "safe_enable": true
  }
}

Model List

Get the current list of built-in/proxy-available models.

Endpoint: GET /dashboard/models

Example:

curl -H "Authorization: Bearer $API_KEY" \
  https://api.xaixapi.com/dashboard/models

Response:

{
  "models": [
    {
      "id": "gpt-4o",
      "provider": "openai",
      "context_window": 128000,
      "max_output_tokens": 16384
    },
    {
      "id": "claude-3-opus",
      "provider": "anthropic",
      "context_window": 200000,
      "max_output_tokens": 4096
    }
  ]
}

Realtime Channel (Optional)

Realtime channel for transparent proxying of upstream realtime capabilities, with the same auth and routing logic as regular proxy.

Endpoint: GET /v1/realtime (WebSocket compatible)

Description: This endpoint supports WebSocket protocol for streaming realtime interactions (e.g., OpenAI Realtime API).

Use Cases

Use Case 1: Dashboard Homepage

Combine multiple endpoints for complete overview:

# Parallel requests for complete dashboard data
curl -H "Authorization: Bearer $API_KEY" https://api.xaixapi.com/dashboard/status &
curl -H "Authorization: Bearer $API_KEY" https://api.xaixapi.com/dashboard/info &
curl -H "Authorization: Bearer $API_KEY" "https://api.xaixapi.com/dashboard/bill?days=30" &
wait

Use Case 2: Monitoring Alerts

Periodically check balance and usage:

# Check account status every hour
*/60 * * * * curl -H "Authorization: Bearer $API_KEY" \
  https://api.xaixapi.com/dashboard/info | \
  jq '.balance.total' | \
  awk '{if($1<10) print "Low balance warning!"}'

Use Case 3: Usage Analysis

Get detailed model usage analysis:

# Get current month model usage
curl -H "Authorization: Bearer $API_KEY" \
  "https://api.xaixapi.com/dashboard/bill" | \
  jq '.data[].usage_details'

Best Practices

  1. Caching Strategy: For /dashboard/status and /dashboard/info, recommend client-side caching for 5-10 minutes
  2. Pagination Handling: Operation logs can be extensive; use pagination parameters to avoid returning too much data at once
  3. Date Ranges: When querying usage, recommend date ranges not exceeding 90 days for optimal performance
  4. Error Handling: All endpoints may return 401 Unauthorized; check key validity
  5. News Polling: Recommend polling the news endpoint every 30 minutes to avoid excessive frequency
  6. Cost Control: Frequent queries for long time ranges of billing data will incur additional fees; set query periods reasonably