Skip to content

StreamObjectOptions<T>

Namespace: Vercel.AI.GenerateObject

public sealed class StreamObjectOptions<T>

Options for CancellationToken). Maps to streamObject.

Type parameters

Name Description
T The result: the object, the array, or the enum value (a string).

Inheritance: object

View source

public bool AllowSystemInMessages { get; set; }

Whether system messages are allowed in Messages. Default: <a href=“https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool"&gt;false&lt;/a>, which throws an InvalidPromptException for a system message; use Instructions instead. Maps to allowSystemInMessages.

Value: bool

View source

public IReadOnlyList<string>? EnumValues { get; set; }

The enum values that the model should use. Only for enum output. Maps to enum.

Value: IReadOnlyList<string>

View source

public Func<IReadOnlyList<DownloadRequestItem>, Task<IReadOnlyList<DownloadResult>>>? ExperimentalDownload { get; set; }

Custom download function to use for URLs. By default, files are downloaded if the model does not support the URL for the given media type. The function receives one DownloadRequestItem per prompt URL, with IsUrlSupportedByModel set, and returns null for a URL the model can read itself. Maps to experimental_download.

Value: Func<IReadOnlyList<DownloadRequestItem>, Task<IReadOnlyList<DownloadResult>>>

View source

public Func<GenerateObjectRepairContext, CancellationToken, Task<string?>>? ExperimentalRepairText { get; set; }

Deprecated alias of RepairText. Maps to experimental_repairText.

Value: Func<GenerateObjectRepairContext, CancellationToken, Task<string>>

View source

public TelemetryOptions? ExperimentalTelemetry { get; set; }

Deprecated alias of Telemetry. Maps to experimental_telemetry.

Value: TelemetryOptions

View source

public double? FrequencyPenalty { get; set; }

Frequency penalty.

Value: double?

View source

public IReadOnlyDictionary<string, string?>? Headers { get; set; }

Extra headers forwarded to the model.

Value: IReadOnlyDictionary<string, string>

View source

public Instructions? Instructions { get; set; }

Instructions supplied before the prompt.

Value: Instructions

View source

public int? MaxOutputTokens { get; set; }

Maximum output tokens.

Value: int?

View source

public int? MaxRetries { get; set; }

Retries for provider calls made by this request.

Value: int?

View source

public IReadOnlyList<ModelMessage>? Messages { get; set; }

Full prompt messages.

Value: IReadOnlyList<ModelMessage>

View source

public ILanguageModel? Model { get; set; }

Explicit language model. Wins over ModelId.

Value: ILanguageModel

View source

public string? ModelId { get; set; }

Gateway model id such as openai/gpt-4.1-mini.

Value: string

View source

public Func<Exception, CancellationToken, Task>? OnError { get; set; }

Called when an error occurs during streaming. You can use it to log errors. The stream processing pauses until the callback task completes.

Value: Func<Exception, CancellationToken, Task>

View source

public Func<GenerateObjectEndEvent<T>, CancellationToken, Task>? OnFinish { get; set; }

Called when the LLM response and the final object validation are finished.

Value: Func<GenerateObjectEndEvent<T>, CancellationToken, Task>

View source

public Func<GenerateObjectStartEvent, CancellationToken, Task>? OnStart { get; set; }

Called when the streamObject operation begins, before the LLM call is made.

Value: Func<GenerateObjectStartEvent, CancellationToken, Task>

View source

public Func<GenerateObjectStepEndEvent, CancellationToken, Task>? OnStepEnd { get; set; }

Called when the model streaming step completes, with the raw accumulated text before final schema validation.

Value: Func<GenerateObjectStepEndEvent, CancellationToken, Task>

View source

public Func<GenerateObjectStepStartEvent, CancellationToken, Task>? OnStepStart { get; set; }

Called when the model call (step) begins, before the provider is called.

Value: Func<GenerateObjectStepStartEvent, CancellationToken, Task>

View source

public StreamObjectOutput Output { get; set; }

The type of the output. Default: Object.

Value: StreamObjectOutput

View source

public double? PresencePenalty { get; set; }

Presence penalty.

Value: double?

View source

public string? Prompt { get; set; }

A single user prompt.

Value: string

View source

public IReadOnlyDictionary<string, JsonElement>? ProviderOptions { get; set; }

Provider-specific options.

Value: IReadOnlyDictionary<string, JsonElement>

View source

public string? Reasoning { get; set; }

Reasoning effort.

Value: string

View source

public Func<GenerateObjectRepairContext, CancellationToken, Task<string?>>? RepairText { get; set; }

Attempts to repair text that failed JSON parsing or schema validation.

Value: Func<GenerateObjectRepairContext, CancellationToken, Task<string>>

View source

public string? Schema { get; set; }

JSON Schema for the generated object. For array output it is the schema of one element. Not supported for enum and no-schema output.

Value: string

View source

public string? SchemaDescription { get; set; }

Optional schema description forwarded to the provider.

Value: string

View source

public string? SchemaName { get; set; }

Optional schema name forwarded to the provider.

Value: string

View source

public int? Seed { get; set; }

Random seed.

Value: int?

View source

public JsonSerializerOptions? SerializerOptions { get; set; }

Serializer settings used to materialize <code class=“typeparamref”>T</code>.

Value: JsonSerializerOptions

View source

public string? System { get; set; }

System prompt. Instructions wins when both are set.

Value: string

View source

public TelemetryOptions? Telemetry { get; set; }

Telemetry configuration. Maps to telemetry.

Value: TelemetryOptions

View source

public double? Temperature { get; set; }

Temperature.

Value: double?

View source

public int? TopK { get; set; }

Top-k sampling.

Value: int?

View source

public double? TopP { get; set; }

Top-p sampling.

Value: double?

View source

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