Errors

API error codes and how to handle them

The VicSee API uses conventional HTTP status codes and returns detailed error information in JSON format.

Error Response Format

All errors follow this structure:

{
  "success": false,
  "error": {
    "code": "ERROR_CODE",
    "message": "Human-readable description"
  }
}

HTTP Status Codes

StatusDescription
200Success
400Bad Request - Invalid parameters
401Unauthorized - Invalid or missing API key
402Payment Required - Insufficient credits
403Forbidden - Access denied
404Not Found - Resource doesn't exist
429Too Many Requests - Rate limit exceeded
500Internal Error - Server-side issue
502Bad Gateway - Upstream provider error

Authentication Errors (401)

CodeMessageSolution
MISSING_AUTH_HEADERMissing Authorization headerAdd Authorization: Bearer sk-xxx header
INVALID_AUTH_FORMATInvalid Authorization formatUse Bearer prefix before your key
INVALID_KEY_FORMATInvalid API key formatKeys must start with sk-
INVALID_API_KEYInvalid or inactive API keyCheck your key or generate a new one

Request Errors (400)

CodeMessageSolution
INVALID_JSONInvalid JSON bodyCheck your JSON syntax
MISSING_MODELmodel is requiredInclude model in request body
MISSING_PROMPTprompt is requiredInclude prompt in request body
INVALID_MODELInvalid modelUse a valid model name from /api/v1/models

Credit Errors (402)

CodeMessageSolution
INSUFFICIENT_CREDITSNot enough creditsPurchase more credits or use a cheaper model

Example response:

{
  "success": false,
  "error": {
    "code": "INSUFFICIENT_CREDITS",
    "message": "Insufficient credits. Required: 60, Available: 45"
  }
}

Rate Limit Errors (429)

CodeMessageSolution
RATE_LIMITEDRate limit exceededWait until reset time, shown in response

Example response:

{
  "success": false,
  "error": {
    "code": "RATE_LIMITED",
    "message": "Rate limit exceeded. Limit: 500/day. Resets at: 2024-12-28T00:00:00.000Z"
  }
}

Check rate limit headers in any response:

  • X-RateLimit-Limit - Your daily limit
  • X-RateLimit-Remaining - Requests remaining
  • X-RateLimit-Reset - When limit resets

Task Errors (404, 403)

CodeMessageSolution
TASK_NOT_FOUNDTask not foundCheck the task ID
FORBIDDENAccess deniedYou can only access your own tasks
TASK_NOT_COMPLETETask is not completeWait for status to be success
NO_RESULTNo result availableTask may have failed silently

Server Errors (500, 502)

CodeMessageSolution
PROVIDER_ERRORAI provider not availableTry again later
GENERATION_FAILEDGeneration failedRetry the request
INTERNAL_ERRORInternal server errorContact support if persistent
PROXY_ERRORFailed to proxy contentTry downloading directly from URL

Error Handling Example

async function generate(model, prompt) {
  const response = await fetch('https://vicsee.com/api/v1/generate', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${API_KEY}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({ model, prompt })
  });

  const data = await response.json();

  if (!data.success) {
    switch (data.error.code) {
      case 'INSUFFICIENT_CREDITS':
        throw new Error('Please purchase more credits');
      case 'RATE_LIMITED':
        throw new Error('Too many requests, please wait');
      case 'INVALID_MODEL':
        throw new Error(`Unknown model: ${model}`);
      default:
        throw new Error(data.error.message);
    }
  }

  return data.data;
}