Skip to content

TimeoutConfiguration

Namespace: Vercel.AI.Prompt

public sealed class TimeoutConfiguration

Timeout configuration for GenerateTextAsync and StreamTextAsync. Maps to TimeoutConfiguration. Upstream takes a number (the total timeout in milliseconds) or an object. A TimeSpan converts to the total timeout, as the number form does upstream. An expired timeout aborts the call with a TimeoutError reason.

Inheritance: object

View source

public int? ChunkMs { get; set; }

Timeout between meaningful model output chunks, in milliseconds. Streaming only. It starts with the first output chunk, so it does not limit the wait for that chunk. It ends when the model response ends. GenerateTextAsync does not support it.

Value: int?

View source

public int? FirstChunkMs { get; set; }

Timeout until the first content chunk of each step, in milliseconds. Streaming only. It starts when the provider returns the response stream of the step, so it does not limit the wait for the response itself. A chunk without output, such as response metadata or an empty delta, does not end it. GenerateTextAsync does not support it.

Value: int?

View source

public int? StepMs { get; set; }

Timeout of each complete step, in milliseconds. A step covers model generation, retries, and local tool execution. The budget starts again for each step.

Value: int?

View source

public int? ToolMs { get; set; }

Default timeout of each tool execution, in milliseconds. A tool that runs longer is cancelled and its call ends with a tool error, so the model can respond or retry. Tools overrides it for one tool.

Value: int?

View source

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

Per-tool timeouts in milliseconds. A key is the tool name followed by Ms, such as weatherMs for the tool weather, as in upstream. An entry takes precedence over ToolMs. Upstream types the keys from the tool set. C# cannot, so a key that matches no tool has no effect.

Value: IReadOnlyDictionary<string, int>

View source

public int? TotalMs { get; set; }

Total timeout for the entire call, including all steps, in milliseconds.

Value: int?

View source

GetToolTimeoutMs(TimeoutConfiguration?, string)

Section titled “GetToolTimeoutMs(TimeoutConfiguration?, string)”
public static int? GetToolTimeoutMs(TimeoutConfiguration? timeout, string toolName)

The timeout of the tool <code class=“paramref”>toolName</code> in milliseconds: its entry in Tools, else ToolMs, else null. A TimeSpan converts to the total timeout only, so it has no tool timeout. Maps to getToolTimeoutMs.

Parameters

Name Type Description
timeout TimeoutConfiguration
toolName string

Returns: int?

View source

implicit operator TimeoutConfiguration(TimeSpan)

Section titled “implicit operator TimeoutConfiguration(TimeSpan)”
public static implicit operator TimeoutConfiguration(TimeSpan timeout)

A configuration whose total timeout is <code class=“paramref”>timeout</code>, rounded up to a whole millisecond. InfiniteTimeSpan and a value longer than MaxValue milliseconds mean no timeout.

Parameters

Name Type Description
timeout TimeSpan

Returns: TimeoutConfiguration

View source

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