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
Properties
Section titled “Properties”AllowSystemInMessages
Section titled “AllowSystemInMessages”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">false</a>, which throws an
InvalidPromptException for a system message; use Instructions instead. Maps to allowSystemInMessages.
Value: bool
EnumValues
Section titled “EnumValues”public IReadOnlyList<string>? EnumValues { get; set; }The enum values that the model should use. Only for enum output. Maps to enum.
Value: IReadOnlyList<string>
ExperimentalDownload
Section titled “ExperimentalDownload”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>>>
ExperimentalRepairText
Section titled “ExperimentalRepairText”public Func<GenerateObjectRepairContext, CancellationToken, Task<string?>>? ExperimentalRepairText { get; set; }Deprecated alias of RepairText. Maps to experimental_repairText.
Value: Func<GenerateObjectRepairContext, CancellationToken, Task<string>>
ExperimentalTelemetry
Section titled “ExperimentalTelemetry”public TelemetryOptions? ExperimentalTelemetry { get; set; }Deprecated alias of Telemetry. Maps to experimental_telemetry.
Value: TelemetryOptions
FrequencyPenalty
Section titled “FrequencyPenalty”public double? FrequencyPenalty { get; set; }Frequency penalty.
Value: double?
Headers
Section titled “Headers”public IReadOnlyDictionary<string, string?>? Headers { get; set; }Extra headers forwarded to the model.
Value: IReadOnlyDictionary<string, string>
Instructions
Section titled “Instructions”public Instructions? Instructions { get; set; }Instructions supplied before the prompt.
Value: Instructions
MaxOutputTokens
Section titled “MaxOutputTokens”public int? MaxOutputTokens { get; set; }Maximum output tokens.
Value: int?
MaxRetries
Section titled “MaxRetries”public int? MaxRetries { get; set; }Retries for provider calls made by this request.
Value: int?
Messages
Section titled “Messages”public IReadOnlyList<ModelMessage>? Messages { get; set; }Full prompt messages.
Value: IReadOnlyList<ModelMessage>
public ILanguageModel? Model { get; set; }Explicit language model. Wins over ModelId.
Value: ILanguageModel
ModelId
Section titled “ModelId”public string? ModelId { get; set; }Gateway model id such as openai/gpt-4.1-mini.
Value: string
OnError
Section titled “OnError”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>
OnFinish
Section titled “OnFinish”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>
OnStart
Section titled “OnStart”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>
OnStepEnd
Section titled “OnStepEnd”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>
OnStepStart
Section titled “OnStepStart”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>
Output
Section titled “Output”public StreamObjectOutput Output { get; set; }The type of the output. Default: Object.
Value: StreamObjectOutput
PresencePenalty
Section titled “PresencePenalty”public double? PresencePenalty { get; set; }Presence penalty.
Value: double?
Prompt
Section titled “Prompt”public string? Prompt { get; set; }A single user prompt.
Value: string
ProviderOptions
Section titled “ProviderOptions”public IReadOnlyDictionary<string, JsonElement>? ProviderOptions { get; set; }Provider-specific options.
Value: IReadOnlyDictionary<string, JsonElement>
Reasoning
Section titled “Reasoning”public string? Reasoning { get; set; }Reasoning effort.
Value: string
RepairText
Section titled “RepairText”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>>
Schema
Section titled “Schema”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
SchemaDescription
Section titled “SchemaDescription”public string? SchemaDescription { get; set; }Optional schema description forwarded to the provider.
Value: string
SchemaName
Section titled “SchemaName”public string? SchemaName { get; set; }Optional schema name forwarded to the provider.
Value: string
public int? Seed { get; set; }Random seed.
Value: int?
SerializerOptions
Section titled “SerializerOptions”public JsonSerializerOptions? SerializerOptions { get; set; }Serializer settings used to materialize <code class=“typeparamref”>T</code>.
Value: JsonSerializerOptions
System
Section titled “System”public string? System { get; set; }System prompt. Instructions wins when both are set.
Value: string
Telemetry
Section titled “Telemetry”public TelemetryOptions? Telemetry { get; set; }Telemetry configuration. Maps to telemetry.
Value: TelemetryOptions
Temperature
Section titled “Temperature”public double? Temperature { get; set; }Temperature.
Value: double?
public int? TopK { get; set; }Top-k sampling.
Value: int?
public double? TopP { get; set; }Top-p sampling.
Value: double?
Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product