Error Codes

Relai uses standard HTTP status codes and returns detailed error information in the response body.

Error Response Format

{
  "error": {
    "message": "Human-readable error description",
    "type": "error_type",
    "code": "specific_error_code",
    "param": "field_name"
  }
}

HTTP Status Codes

StatusMeaning
400Bad Request — Invalid parameters
401Unauthorized — Invalid or missing API key
403Forbidden — Key doesn't have access to this resource
404Not Found — Resource doesn't exist
429Too Many Requests — Rate limit exceeded
500Internal Error — Something went wrong on our end
502Bad Gateway — Upstream provider error
503Service Unavailable — Temporary overload

Common Error Types

Authentication Errors (401)

{
  "error": {
    "message": "Invalid API key provided",
    "type": "invalid_api_key"
  }
}

Solutions:

  • Check your API key starts with rk-eu- or rk-us-
  • Verify the key hasn't been revoked
  • Ensure the Authorization header format is Bearer YOUR_KEY

Rate Limit Errors (429)

{
  "error": {
    "message": "Rate limit exceeded: 60 requests per minute",
    "type": "rate_limit_exceeded",
    "retry_after": 12
  }
}

Solutions:

  • Wait for the retry_after seconds
  • Implement exponential backoff
  • Increase your key's RPM limit in the dashboard

Insufficient Balance (402)

{
  "error": {
    "message": "Insufficient credit balance",
    "type": "insufficient_balance",
    "balance_micro": 0,
    "required_micro": 150000
  }
}

Solutions:

  • Add credits in the dashboard billing page
  • Enable auto-recharge to prevent interruptions

Region Mismatch (403)

{
  "error": {
    "message": "API key is for region EU, but request was made to US",
    "type": "region_mismatch"
  }
}

Solutions:

  • Use eu.api.llmrelai.com with rk-eu- keys
  • Use us.api.llmrelai.com with rk-us- keys

Retry Strategy

For transient errors (429, 502, 503), implement exponential backoff:

async function callWithRetry(fn, maxRetries = 3) {
  for (let i = 0; i < maxRetries; i++) {
    try {
      return await fn();
    } catch (error) {
      if (i === maxRetries - 1) throw error;
      
      const status = error.status;
      if (![429, 502, 503].includes(status)) throw error;
      
      const delay = Math.min(1000 * Math.pow(2, i), 30000);
      await new Promise(r => setTimeout(r, delay));
    }
  }
}

Getting Help

If you encounter persistent errors:

  1. Check our status page
  2. Contact support at support@llmrelai.com
  3. Include the X-Request-Id header from the response