User Usage Statistics API Documentation

Overview

This API retrieves usage statistics for models within an organization, including aggregated statistics by model, daily statistics, and overall usage summary.


API Information

ItemDescription
API NameGet User Usage Statistics
API Path/api/v3/user/usage_stats
HTTP MethodPOST
Content-Typeapplication/json
AuthenticationBearer Token via Authorization header

Request Parameters

Headers

ParameterTypeRequiredDescription
AuthorizationstringYesAccess Key in format: Bearer {access_key}

Body Parameters

ParameterTypeRequiredDescription
start_timestringYesStart time in ISO 8601 format, e.g., 2025-10-01T00:00:00Z
end_timestringYesEnd time in ISO 8601 format, e.g., 2025-10-12T23:59:59Z
model_uuidstringNoModel UUID for filtering specific model usage

Request Example

{
  "start_time": "2025-10-01T00:00:00Z",
  "end_time": "2025-10-12T23:59:59Z"
}

Response Parameters

Response Structure

{
  "code": 200,
  "message": "success",
  "data": {
    "per_model_usage": [...],
    "daily_usage": [...],
    "summary": {...}
  }
}

Response Field Descriptions

Root Fields

FieldTypeDescription
codeintResponse status code, 200 indicates success
messagestringResponse message
dataobjectStatistics data object

data Object

FieldTypeDescription
per_model_usagearrayArray of aggregated usage statistics by model
daily_usagearrayArray of daily usage statistics
summaryobjectOverall usage summary

per_model_usage Array Elements

FieldTypeDescriptionExample
model_uuidstringModel UUID identifier"kwaivgi/kling-v2.0-i2v-master"
model_typestringModel type"text-to-video"
unit_pricefloat64Unit price in USD, rounded to 3 decimal places0.488
total_costfloat64Total cost in USD, rounded to 3 decimal places130.000
total_countint64Total number of invocations2660
last_used_datestringLast used date in format YYYY-MM-DD"2025-10-12"

daily_usage Array Elements

FieldTypeDescriptionExample
datestringDate in format YYYY-MM-DD"2025-10-01"
amountfloat64Total cost for the day in USD, rounded to 3 decimal places242.300
countint64Total number of invocations for the day8095
modelsarrayArray of model usage details for the daySee below

models Array Elements (under daily_usage)

FieldTypeDescriptionExample
model_uuidstringModel UUID identifier"kwaivgi/kling-v2.0-i2v-master"
amountfloat64Cost for this model on the day in USD, rounded to 3 decimal places130.000
countint64Number of invocations for this model on the day2660

summary Object

FieldTypeDescriptionExample
total_costfloat64Total cost within the time range in USD, rounded to 3 decimal places2423.000
total_requestsint64Total number of requests98765
success_requestsint64Number of successful requests95432

Response Examples

Success Response

{
  "code": 200,
  "message": "success",
  "data": {
    "per_model_usage": [
      {
        "model_uuid": "kwaivgi/kling-v2.0-i2v-master",
        "model_type": "text-to-video",
        "unit_price": 0.488,
        "total_cost": 1300.000,
        "total_count": 2660,
        "last_used_date": "2025-10-12"
      },
      {
        "model_uuid": "kwaivgi/kling-v2.1-i2v-pro",
        "model_type": "text-to-video",
        "unit_price": 0.976,
        "total_cost": 450.000,
        "total_count": 461,
        "last_used_date": "2025-10-11"
      }
    ],
    "daily_usage": [
      {
        "date": "2025-10-01",
        "amount": 242.300,
        "count": 8095,
        "models": [
          {
            "model_uuid": "kwaivgi/kling-v2.0-i2v-master",
            "amount": 130.000,
            "count": 2660
          },
          {
            "model_uuid": "kwaivgi/kling-v2.1-i2v-pro",
            "amount": 45.000,
            "count": 450
          },
          {
            "model_uuid": "wavespeed-ai/wan-2.1/t2v-720p-lora",
            "amount": 30.000,
            "count": 300
          }
        ]
      },
      {
        "date": "2025-10-02",
        "amount": 198.500,
        "count": 6543,
        "models": [
          {
            "model_uuid": "kwaivgi/kling-v2.0-i2v-master",
            "amount": 98.500,
            "count": 2015
          },
          {
            "model_uuid": "kwaivgi/kling-v2.1-i2v-pro",
            "amount": 55.000,
            "count": 564
          }
        ]
      }
    ],
    "summary": {
      "total_cost": 2423.000,
      "total_requests": 98765,
      "success_requests": 95432
    }
  }
}

Error Responses

401 - Unauthorized

{
  "code": 401,
  "message": "access_key is required"
}

Description: Access Key is not provided or invalid.


400 - Invalid Parameters

{
  "code": 400,
  "message": "invalid time range: end_time must be after start_time"
}

Description: Request parameters do not meet requirements, such as invalid time range.


400 - Time Range Exceeded

{
  "code": 400,
  "message": "time range cannot exceed 31 days"
}

Description: The query time range exceeds the 31-day limit.


500 - Server Error

{
  "code": 500,
  "message": "failed to get model usage summary: ..."
}

Description: Internal server error occurred.


Business Rules and Limitations

Time Range Restrictions

  • Required Fields: Both start_time and end_time must be provided
  • Maximum Time Range: Cannot exceed 31 days
  • Time Validity: end_time must be later than start_time
  • Date Format: ISO 8601 standard format (e.g., 2025-10-01T00:00:00Z)

Data Statistics Rules

  • Statistics Dimension: Statistics are aggregated by day (stat_date)
  • Amount Precision: All amounts are rounded to 3 decimal places using standard rounding
  • Currency Unit: US Dollars (USD)
  • Sorting Rules:
    • per_model_usage: Sorted by last used date in descending order
    • daily_usage: Sorted by date in ascending order
    • models (under daily_usage): Sorted by amount in descending order

Filtering Functionality

  • model_uuid Filter: When the model_uuid parameter is provided, all statistics (including summary) will only include data for that specific model
  • Exact Match: model_uuid uses exact matching, fuzzy queries are not supported

Authentication and Authorization

  • Authentication Method: Authentication via Access Key

Use Cases

Use Case 1: View Overall Usage

Purpose: View usage statistics for all models within an organization over a specific time period.

curl -X POST "https://api.wavespeed.ai/api/v3/user/usage_stats" \
  -H "Authorization: Bearer your_access_key" \
  -H "Content-Type: application/json" \
  -d '{
    "start_time": "2025-10-01T00:00:00Z",
    "end_time": "2025-10-12T23:59:59Z"
  }'

Use Case 2: View Specific Model Usage

Purpose: View usage statistics for a specific model only.

curl -X POST "https://api.wavespeed.ai/api/v3/user/usage_stats" \
  -H "Authorization: Bearer your_access_key" \
  -H "Content-Type: application/json" \
  -d '{
    "start_time": "2025-10-01T00:00:00Z",
    "end_time": "2025-10-12T23:59:59Z",
    "model_uuid": "kwaivgi/kling-v2.0-i2v-master"
  }'

Use Case 3: View Last 7 Days Usage

Purpose: Quickly view recent usage trends.

curl -X POST "https://api.wavespeed.ai/api/v3/user/usage_stats" \
  -H "Authorization: Bearer your_access_key" \
  -H "Content-Type: application/json" \
  -d '{
    "start_time": "2025-10-06T00:00:00Z",
    "end_time": "2025-10-12T23:59:59Z"
  }'

Data Specifications

Amount Calculation

  • Results are rounded to 3 decimal places using standard rounding

Invocation Count Statistics

  • completed_count: Successfully completed request counts
  • count (in daily_usage and models): Successfully

Best Practices

  • Reasonable Time Ranges: Use appropriate time ranges (e.g., 7 days, 30 days) to avoid excessive data retrieval
  • Model Filtering: Use model_uuid parameter when querying specific model data to reduce result set size
  • Caching: Consider implementing client-side caching for frequently accessed data
  • Rate Limiting: Be mindful of API rate limits when making frequent requests

© 2025 WaveSpeedAI. All rights reserved.