Skip to content

StreamProviderError

Namespace: Vercel.AI.Util

public sealed class StreamProviderError : AiSdkError, ISerializable, IErrorMarkers

Error reported by a provider after a model response stream has started.

Inheritance: object → Exception → AiSdkError

Implements: ISerializable, IErrorMarkers

View source

StreamProviderError(string, string?, object?, int?, bool?, object?, Exception?)

Section titled “StreamProviderError(string, string?, object?, int?, bool?, object?, Exception?)”
public StreamProviderError(string message, string? type = null, object? code = null, int? statusCode = null, bool? isRetryable = null, object? data = null, Exception? cause = null)

Creates the error from provider metadata.

Parameters

Name Type Description
message string
type string
code object
statusCode int?
isRetryable bool?
data object
cause Exception

View source

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

Marker for IsInstance(object).

Value: string

View source

public object? Code { get; }

Provider-defined error code.

Value: object

View source

public object? Data { get; }

Original provider error payload.

Value: object

View source

public bool IsRetryable { get; }

Whether retrying the model call may succeed.

Value: bool

View source

public int? StatusCode { get; }

HTTP-equivalent status code.

Value: int?

View source

public string? Type { get; }

Provider-defined error type.

Value: 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

public static bool IsRetryableStatusCode(int? statusCode)

Retryable statuses are 408, 409, 429, and 500 and above.

Parameters

Name Type Description
statusCode int?

Returns: bool

View source

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