GenerateTextOptions
Namespace: Vercel.AI
public class GenerateTextOptionsOptions for CancellationToken). Property names follow generateText.
Inheritance: object
Derived: StreamTextOptions
Properties
Section titled “Properties”ActiveTools
Section titled “ActiveTools”public IReadOnlyList<string>? ActiveTools { get; set; }Tool names allowed on this call. Null allows every tool.
Value: IReadOnlyList<string>
ApproveTool
Section titled “ApproveTool”public Func<ToolApprovalRequest, CancellationToken, Task<bool>>? ApproveTool { get; set; }Approves a tool call before it runs. A false result records an error tool result.
Value: Func<ToolApprovalRequest, CancellationToken, Task<bool>>
ExperimentalRepairToolCall
Section titled “ExperimentalRepairToolCall”[Obsolete("Use RepairToolCall instead.")]public ToolCallRepairFunction? ExperimentalRepairToolCall { get; set; }Deprecated alias of RepairToolCall. RepairToolCall wins when both are set.
Maps to experimental_repairToolCall.
Value: ToolCallRepairFunction
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 language model.
Value: IReadOnlyDictionary<string, string>
Instructions
Section titled “Instructions”public Instructions? Instructions { get; set; }System prompt: a string, one SystemModelMessage, or an array of them. Maps to instructions.
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. Providers that own their HTTP stack use their own policy.
Value: int?
Messages
Section titled “Messages”public IReadOnlyList<ModelMessage>? Messages { get; set; }Full prompt. Maps to 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 generation fails. Maps to onError.
Value: Func<Exception, CancellationToken, Task>
OnFinish
Section titled “OnFinish”public Func<GenerateTextResult, CancellationToken, Task>? OnFinish { get; set; }Called when generation finishes. Maps to onFinish.
Value: Func<GenerateTextResult, CancellationToken, Task>
OnLanguageModelCallEnd
Section titled “OnLanguageModelCallEnd”public Func<LanguageModelCallEndEvent, CancellationToken, Task>? OnLanguageModelCallEnd { get; set; }Called after each provider model call returns, before tools run and before OnStepEnd.
Maps to onLanguageModelCallEnd.
Value: Func<LanguageModelCallEndEvent, CancellationToken, Task>
OnStepEnd
Section titled “OnStepEnd”public Func<StepResult, CancellationToken, Task>? OnStepEnd { get; set; }Called after each step. Maps to onStepEnd.
Value: Func<StepResult, CancellationToken, Task>
OnToolExecutionEnd
Section titled “OnToolExecutionEnd”public Func<ToolExecutionEndEvent, CancellationToken, Task>? OnToolExecutionEnd { get; set; }Called after a tool’s Execute returns or throws, before OnStepEnd. An exception it throws is ignored.
Maps to onToolExecutionEnd.
Value: Func<ToolExecutionEndEvent, CancellationToken, Task>
OnToolExecutionStart
Section titled “OnToolExecutionStart”public Func<ToolExecutionStartEvent, CancellationToken, Task>? OnToolExecutionStart { get; set; }Called before a tool’s Execute runs. It is not called for a tool without Execute, a provider-executed call,
or a call that is invalid or not approved. An exception it throws is ignored. Maps to onToolExecutionStart.
Value: Func<ToolExecutionStartEvent, CancellationToken, Task>
Output
Section titled “Output”public OutputSpec? Output { get; set; }Structured output.
Value: OutputSpec
PrepareStep
Section titled “PrepareStep”public Func<PrepareStepContext, PrepareStepUpdate?>? PrepareStep { get; set; }Called before each step. Maps to prepareStep.
Value: Func<PrepareStepContext, PrepareStepUpdate>
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: none, minimal, low, medium, high, xhigh, or max.
A provider option with the same setting wins when both are set.
Value: string
RefineToolInput
Section titled “RefineToolInput”public IReadOnlyDictionary<string, Func<JsonElement, CancellationToken, Task<JsonElement>>>? RefineToolInput { get; set; }Refines the parsed input of a tool call, keyed by tool name, before the tool runs and before outputs and callbacks see it.
A tool without an entry keeps its parsed input. Maps to experimental_refineToolInput.
Value: IReadOnlyDictionary<string, Func<JsonElement, CancellationToken, Task<JsonElement>>>
RepairToolCall
Section titled “RepairToolCall”public ToolCallRepairFunction? RepairToolCall { get; set; }Repairs a tool call whose tool is unknown or whose input is invalid, before the call is reported or executed.
Return the repaired call, or null to keep the error. Maps to repairToolCall.
Value: ToolCallRepairFunction
public int? Seed { get; set; }Seed.
Value: int?
StopSequences
Section titled “StopSequences”public IReadOnlyList<string>? StopSequences { get; set; }Stop sequences.
Value: IReadOnlyList<string>
StopWhen
Section titled “StopWhen”public StopCondition? StopWhen { get; set; }When to stop the tool loop. Defaults to one step.
Value: StopCondition
System
Section titled “System”public string? System { get; set; }System prompt. Instructions wins when both are set.
Value: string
Temperature
Section titled “Temperature”public double? Temperature { get; set; }Temperature.
Value: double?
Timeout
Section titled “Timeout”public TimeoutConfiguration? Timeout { get; set; }Aborts the call with a TimeoutError when a timeout expires. A TimeSpan sets the total timeout.
StepMs, FirstChunkMs, and ChunkMs set the others. Maps to timeout.
Value: TimeoutConfiguration
ToolCallConcurrency
Section titled “ToolCallConcurrency”public int? ToolCallConcurrency { get; set; }Maximum number of tool calls that may execute concurrently within a step. Set to 1 to execute them one at a time in model order.
Null runs every tool call at once. Values below 1 throw InvalidArgumentError. Maps to toolCallConcurrency.
Value: int?
ToolChoice
Section titled “ToolChoice”public ToolChoice? ToolChoice { get; set; }Tool selection mode.
Value: ToolChoice
public IReadOnlyList<Tool>? Tools { get; set; }Tools available to the model.
Value: IReadOnlyList<Tool>
public int? TopK { get; set; }Top-k.
Value: int?
public double? TopP { get; set; }Top-p.
Value: double?
Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product