Skip to content

AssistantModelMessage

Namespace: Vercel.AI.Provider

public sealed class AssistantModelMessage : ModelMessage

An assistant message.

Inheritance: object → ModelMessage

View source

AssistantModelMessage(IReadOnlyList<AssistantContentPart>)

Section titled “AssistantModelMessage(IReadOnlyList<AssistantContentPart>)”
public AssistantModelMessage(IReadOnlyList<AssistantContentPart> parts)

Creates an assistant message from ordered parts. The text, reasoning, and tool calls are derived from them.

Parameters

Name Type Description
parts IReadOnlyList<AssistantContentPart>

View source

AssistantModelMessage(string?, IReadOnlyList<GeneratedToolCall>?, string?)

Section titled “AssistantModelMessage(string?, IReadOnlyList<GeneratedToolCall>?, string?)”
public AssistantModelMessage(string? text, IReadOnlyList<GeneratedToolCall>? toolCalls, string? reasoning)

Creates an assistant message.

Parameters

Name Type Description
text string
toolCalls IReadOnlyList<GeneratedToolCall>
reasoning string

View source

AssistantModelMessage(string?, IReadOnlyList<GeneratedToolCall>?, string?, IReadOnlyDictionary<string, JsonElement>?)

Section titled “AssistantModelMessage(string?, IReadOnlyList<GeneratedToolCall>?, string?, IReadOnlyDictionary<string, JsonElement>?)”
public AssistantModelMessage(string? text, IReadOnlyList<GeneratedToolCall>? toolCalls, string? reasoning, IReadOnlyDictionary<string, JsonElement>? reasoningProviderOptions)

Creates an assistant message whose reasoning carries provider options, such as an OpenAI itemId for reasoning stored by the Responses API.

Parameters

Name Type Description
text string
toolCalls IReadOnlyList<GeneratedToolCall>
reasoning string
reasoningProviderOptions IReadOnlyDictionary<string, JsonElement>

View source

AssistantModelMessage(string?, IReadOnlyList<GeneratedToolCall>?, string?, IReadOnlyDictionary<string, JsonElement>?, IReadOnlyList<AssistantContentPart>?)

Section titled “AssistantModelMessage(string?, IReadOnlyList<GeneratedToolCall>?, string?, IReadOnlyDictionary<string, JsonElement>?, IReadOnlyList<AssistantContentPart>?)”
public AssistantModelMessage(string? text, IReadOnlyList<GeneratedToolCall>? toolCalls, string? reasoning, IReadOnlyDictionary<string, JsonElement>? reasoningProviderOptions, IReadOnlyList<AssistantContentPart>? parts)

Creates an assistant message that also keeps its content parts in order. When <code class=“paramref”>parts</code> is null, the parts are the reasoning, the text, and the tool calls, in that order.

Parameters

Name Type Description
text string
toolCalls IReadOnlyList<GeneratedToolCall>
reasoning string
reasoningProviderOptions IReadOnlyDictionary<string, JsonElement>
parts IReadOnlyList<AssistantContentPart>

View source

public IReadOnlyList<AssistantContentPart> Parts { get; }

The content parts in the order the model produced them, each with its own provider options.

Value: IReadOnlyList<AssistantContentPart>

View source

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

Provider-specific options for this message, such as an Amazon Bedrock cachePoint.

Value: IReadOnlyDictionary<string, JsonElement>

View source

public string? Reasoning { get; }

Reasoning text, when the provider returned it.

Value: string

View source

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

Provider options of the reasoning part, such as an OpenAI itemId.

Value: IReadOnlyDictionary<string, JsonElement>

View source

public string? Text { get; }

Assistant text.

Value: string

View source

public IReadOnlyList<GeneratedToolCall> ToolCalls { get; }

Tool calls made in this turn.

Value: IReadOnlyList<GeneratedToolCall>

View source

FromGeneratedContent(IReadOnlyList<GeneratedContent>)

Section titled “FromGeneratedContent(IReadOnlyList<GeneratedContent>)”
public static AssistantModelMessage FromGeneratedContent(IReadOnlyList<GeneratedContent> content)

Creates an assistant message from generated content, keeping order and each part’s provider metadata as its provider options. This is how a generate result is replayed as history. Sources and files have no assistant part and are skipped.

Parameters

Name Type Description
content IReadOnlyList<GeneratedContent>

Returns: AssistantModelMessage

View source

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