Skip to main content

Error format

The API uses RFC 7807 Problem Details format for all error responses:
{
  "type": "https://api.rawugc.com/errors/insufficient_credits",
  "title": "Insufficient Credits",
  "status": 402,
  "detail": "Insufficient credits. Required: 6, Available: 2",
  "instance": "/api/v1/videos/generate/req_abc123"
}
FieldDescription
typeURI identifying the error type
titleHuman-readable summary
statusHTTP status code
detailSpecific explanation for this occurrence
instanceURI identifying this specific request
errorsField-specific validation errors (for 400 responses)

Validation errors

When request validation fails, the response includes field-specific errors:
{
  "type": "https://api.rawugc.com/errors/validation_error",
  "title": "Validation Error",
  "status": 400,
  "detail": "Request validation failed",
  "errors": {
    "prompt": ["Required"],
    "model": ["Invalid enum value"]
  }
}

HTTP status codes

StatusMeaningCommon Causes
400Bad RequestInvalid parameters, malformed JSON, missing required fields
401UnauthorizedMissing or invalid API key, expired key
402Payment RequiredInsufficient credits for the requested operation
404Not FoundResource doesn’t exist or doesn’t belong to you
429Too Many RequestsRate limit exceeded (see Rate Limits)
500Internal Server ErrorUnexpected server error

Error types

Error TypeStatusDescription
authentication_error401General authentication failure
empty_api_key401Authorization header present but empty
invalid_api_key401API key is invalid or revoked
missing_authentication401No authentication credentials provided
verification_failed401API key verification failed
insufficient_scope403API key lacks required permissions
validation_error400Request body validation failed
insufficient_credits402Not enough credits for the operation
rate_limit_exceeded429Too many requests in the current window
not_found404Requested resource not found
internal_error500Unexpected server error

Handling errors

We recommend implementing retry logic with exponential backoff for 429 and 500 errors:
async function apiRequest(url, options, maxRetries = 3) {
  for (let attempt = 0; attempt < maxRetries; attempt++) {
    const response = await fetch(url, options);

    if (response.ok) return response.json();

    if (response.status === 429 || response.status >= 500) {
      const delay = Math.pow(2, attempt) * 1000;
      await new Promise(resolve => setTimeout(resolve, delay));
      continue;
    }

    // Non-retryable error
    const error = await response.json();
    throw new Error(`${error.title}: ${error.detail}`);
  }

  throw new Error('Max retries exceeded');
}