Skip to content

ApiCallError

Namespace: Vercel.AI.Util

public class ApiCallError : AiSdkError, ISerializable, IErrorMarkers

A failed provider HTTP call, including retry metadata and response headers.

Inheritance: object → Exception → AiSdkError

Implements: ISerializable, IErrorMarkers

View source

ApiCallError(string, string, object, int?, IReadOnlyDictionary<string, string>?, string?, Exception?, bool?, object?)

Section titled “ApiCallError(string, string, object, int?, IReadOnlyDictionary<string, string>?, string?, Exception?, bool?, object?)”
public ApiCallError(string message, string url, object requestBodyValues, int? statusCode = null, IReadOnlyDictionary<string, string>? responseHeaders = null, string? responseBody = null, Exception? cause = null, bool? isRetryable = null, object? data = null)

Creates the error.

Parameters

Name Type Description
message string
url string
requestBodyValues object
statusCode int?
responseHeaders IReadOnlyDictionary<string, string>
responseBody string
cause Exception
isRetryable bool?
data object

View source

public const string ErrorMarker = "vercel.ai.error.AI_APICallError"

Marker for IsInstance(object).

Value: string

View source

public object? Data { get; }

Parsed provider payload.

Value: object

View source

public bool IsRetryable { get; }

Whether the call may be retried.

Value: bool

View source

public object RequestBodyValues { get; }

Request body that was sent.

Value: object

View source

public string? ResponseBody { get; }

Raw response body.

Value: string

View source

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

Response headers. Lookup is case-insensitive.

Value: IReadOnlyDictionary<string, string>

View source

public int? StatusCode { get; }

HTTP status, when the provider responded.

Value: int?

View source

public string Url { get; }

Request URL.

Value: string

View source

public string? GetHeader(string? name)

Reads a response header, ignoring case.

Parameters

Name Type Description
name string

Returns: string

View source

public static bool IsInstance(object? error)

Returns whether <code class=“paramref”>error</code> carries this error’s marker.

Parameters

Name Type Description
error object

Returns: bool

View source

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