Skip to content

GatewayError

Namespace: Vercel.AI.Gateway

public abstract class GatewayError : AiSdkException, ISerializable

Base class for AI Gateway errors. The message includes [generationId] when one was returned.

Inheritance: object → Exception → AiSdkException

Implements: ISerializable

Derived: GatewayAuthenticationError, GatewayFailedDependencyError, GatewayForbiddenError, GatewayInternalServerError, GatewayInvalidRequestError, GatewayModelNotFoundError, GatewayNotFoundError, GatewayRateLimitError, GatewayResponseError, GatewayTimeoutError

View source

GatewayError(string, int, Exception?, string?, bool?)

Section titled “GatewayError(string, int, Exception?, string?, bool?)”
protected GatewayError(string message, int statusCode, Exception? cause, string? generationId, bool? isRetryable)

Creates a Gateway error.

Parameters

Name Type Description
message string
statusCode int
cause Exception
generationId string
isRetryable bool?

View source

public Exception? Cause { get; }

Underlying failure, when one was supplied.

Value: Exception

View source

public string? GenerationId { get; }

Gateway generation id.

Value: string

View source

public bool IsRetryable { get; }

Whether the caller should retry this status.

Value: bool

View source

public int StatusCode { get; }

HTTP status.

Value: int

View source

public abstract string Type { get; }

Gateway error type.

Value: string

View source

public static bool IsInstance(Exception? error)

True when <code class=“paramref”>error</code> is a Gateway error.

Parameters

Name Type Description
error Exception

Returns: bool

View source

Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product