Skip to content

ApiException

Namespace: Vercel.AI.Provider

public class ApiException : AiSdkException, ISerializable

The provider returned a non-success HTTP status after retries.

Inheritance: object → Exception → AiSdkException

Implements: ISerializable

Derived: AuthenticationException, BadRequestException, InternalServerException, NotFoundException, PermissionDeniedException, RateLimitException, UnprocessableEntityException

View source

public ApiException(string message, int statusCode, string? responseBody)

Creates an API exception.

Parameters

Name Type Description
message string
statusCode int
responseBody string

View source

ApiException(string, int, string?, Exception)

Section titled “ApiException(string, int, string?, Exception)”
public ApiException(string message, int statusCode, string? responseBody, Exception innerException)

Creates an API exception caused by <code class=“paramref”>innerException</code>.

Parameters

Name Type Description
message string
statusCode int
responseBody string
innerException Exception

View source

public object? ErrorData { get; init; }

The provider error parsed from the response body, when the handler could parse it. Maps to APICallError.data. Named ErrorData because Data already exists.

Value: object

View source

public bool IsRetryable { get; init; }

True when the call can be retried. Defaults to 408, 429, and 500 and above.

Value: bool

View source

public object? RequestBodyValues { get; init; }

Request body values the call was made with. Set by the response handlers.

Value: object

View source

public string? ResponseBody { get; }

Raw response body, when the provider sent one.

Value: string

View source

public IReadOnlyDictionary<string, string>? ResponseHeaders { get; init; }

Response headers, when the handler had them.

Value: IReadOnlyDictionary<string, string>

View source

public int StatusCode { get; }

HTTP status code.

Value: int

View source

public string? Url { get; init; }

URL of the failed request. Set by the response handlers.

Value: string

View source

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