Provides detailed, structured error information for AI operations. This interface enables intelligent error handling, retry logic, and provider failover decisions.

AIErrorInfo

Since

2.47.0

Example

const errorInfo: AIErrorInfo = {
httpStatusCode: 429,
errorType: 'RateLimit',
severity: 'Retriable',
suggestedRetryDelaySeconds: 30,
canFailover: true,
providerErrorCode: 'rate_limit_exceeded'
};
interface AIErrorInfo {
    canFailover: boolean;
    context?: Record<string, any>;
    error?: any;
    errorType: AIErrorType;
    httpStatusCode?: number;
    providerErrorCode?: string;
    severity: ErrorSeverity;
    suggestedRetryDelaySeconds?: number;
}

Properties

canFailover: boolean

Indicates whether this error might be resolved by switching to another provider.

  • true: Error is provider-specific (rate limit, service down)
  • false: Error is request-specific (bad API key, invalid parameters)

Memberof

AIErrorInfo

context?: Record<string, any>

Additional context or metadata about the error. Can include provider name, error timestamps, request IDs, etc. This field is flexible to accommodate provider-specific information.

Memberof

AIErrorInfo

error?: any

Original error object thrown by the provider's SDK or API. This allows for deeper inspection if needed.

Memberof

AIErrorInfo

errorType: AIErrorType

Categorized error type for standardized error handling. This allows consistent error handling across different AI providers.

Memberof

AIErrorInfo

httpStatusCode?: number

HTTP status code returned by the provider's API. Common codes include:

  • 429: Rate limit exceeded
  • 401/403: Authentication/Authorization failure
  • 500: Internal server error
  • 503: Service unavailable

Memberof

AIErrorInfo

providerErrorCode?: string

Original error code from the provider's SDK or API. This preserves provider-specific error codes for debugging. Examples: 'rate_limit_exceeded', 'model_not_found', 'invalid_api_key'

Memberof

AIErrorInfo

severity: ErrorSeverity

Severity level indicating how the error should be handled. Used to determine whether to retry immediately, wait, or fail permanently.

Memberof

AIErrorInfo

suggestedRetryDelaySeconds?: number

Suggested delay in seconds before retrying the operation. For rate limits, this often comes from the provider's Retry-After header. If undefined, the caller should use exponential backoff or default delays.

Memberof

AIErrorInfo