Skip to content

GenerateTextOptions

Namespace: Vercel.AI

public class GenerateTextOptions

Options for CancellationToken). Property names follow generateText.

Inheritance: object

Derived: StreamTextOptions

View source

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

Tool names allowed on this call. Null allows every tool.

Value: IReadOnlyList<string>

View source

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

View source

[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

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 language model.

Value: IReadOnlyDictionary<string, string>

View source

public Instructions? Instructions { get; set; }

System prompt: a string, one SystemModelMessage, or an array of them. Maps to instructions.

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. Providers that own their HTTP stack use their own policy.

Value: int?

View source

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

Full prompt. Maps to 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 generation fails. Maps to onError.

Value: Func<Exception, CancellationToken, Task>

View source

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

Called when generation finishes. Maps to onFinish.

Value: Func<GenerateTextResult, CancellationToken, Task>

View source

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>

View source

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

Called after each step. Maps to onStepEnd.

Value: Func<StepResult, CancellationToken, Task>

View source

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>

View source

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>

View source

public OutputSpec? Output { get; set; }

Structured output.

Value: OutputSpec

View source

public Func<PrepareStepContext, PrepareStepUpdate?>? PrepareStep { get; set; }

Called before each step. Maps to prepareStep.

Value: Func<PrepareStepContext, PrepareStepUpdate>

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: none, minimal, low, medium, high, xhigh, or max. A provider option with the same setting wins when both are set.

Value: string

View source

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

View source

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

View source

public int? Seed { get; set; }

Seed.

Value: int?

View source

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

Stop sequences.

Value: IReadOnlyList<string>

View source

public StopCondition? StopWhen { get; set; }

When to stop the tool loop. Defaults to one step.

Value: StopCondition

View source

public string? System { get; set; }

System prompt. Instructions wins when both are set.

Value: string

View source

public double? Temperature { get; set; }

Temperature.

Value: double?

View source

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

View source

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?

View source

public ToolChoice? ToolChoice { get; set; }

Tool selection mode.

Value: ToolChoice

View source

public IReadOnlyList<Tool>? Tools { get; set; }

Tools available to the model.

Value: IReadOnlyList<Tool>

View source

public int? TopK { get; set; }

Top-k.

Value: int?

View source

public double? TopP { get; set; }

Top-p.

Value: double?

View source

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