Table of Contents

Class BaseMessageRequest

Namespace
AnthropicClient.Models
Assembly
AnthropicClient.dll

Represents a message request.

public abstract class BaseMessageRequest
Inheritance
BaseMessageRequest
Derived
Inherited Members

Constructors

BaseMessageRequest(string, List<Message>, int, string?, Dictionary<string, object>?, decimal, int?, decimal?, ToolChoice?, List<Tool>?, bool, List<string>?, List<TextContent>?)

Initializes a new instance of the BaseMessageRequest class.

protected BaseMessageRequest(string model, List<Message> messages, int maxTokens, string? system, Dictionary<string, object>? metadata, decimal temperature, int? topK, decimal? topP, ToolChoice? toolChoice, List<Tool>? tools, bool stream, List<string>? stopSequences, List<TextContent>? systemMessages)

Parameters

model string

The model ID to use for the request.

messages List<Message>

The messages to send to the model.

maxTokens int

The maximum number of tokens to generate.

system string

The system prompt to use for the request.

metadata Dictionary<string, object>

The metadata to include with the request.

temperature decimal

The temperature to use for the request.

topK int?

The top-K value to use for the request.

topP decimal?

The top-P value to use for the request.

toolChoice ToolChoice

The tool choice mode to use for the request.

tools List<Tool>

The tools to use for the request.

stream bool

A value indicating whether the message should be streamed.

stopSequences List<string>

The prompt stop sequences.

systemMessages List<TextContent>

The system messages to use for the request.

Exceptions

ArgumentNullException

Thrown when the model or messages is null.

ArgumentException

Thrown when the messages contain no messages.

ArgumentException

Thrown when the max tokens is less than one.

ArgumentException

Thrown when the temperature is less than zero or greater than one.

Properties

MaxTokens

Gets the maximum number of tokens to generate.

[JsonPropertyName("max_tokens")]
public int MaxTokens { get; init; }

Property Value

int

Messages

Gets the messages to send to the model.

public List<Message> Messages { get; init; }

Property Value

List<Message>

Metadata

Gets the metadata to include with the request.

public Dictionary<string, object>? Metadata { get; init; }

Property Value

Dictionary<string, object>

Model

Gets the model ID to use for the request.

public string Model { get; init; }

Property Value

string

StopSequences

Gets the prompt stop sequences.

[JsonPropertyName("stop_sequences")]
public List<string> StopSequences { get; init; }

Property Value

List<string>

Stream

Gets a value indicating whether the message should be streamed.

public bool Stream { get; init; }

Property Value

bool

System

Gets the system message that will be used as the system prompt if no system messages are provided.

[JsonIgnore]
public string? System { get; init; }

Property Value

string

SystemMessages

Gets the system messages to send to the model to be used as the system prompt.

[JsonIgnore]
public List<TextContent>? SystemMessages { get; init; }

Property Value

List<TextContent>

SystemPrompt

Gets the system prompt that will be used for the request. If will return the system messages if they are provided, otherwise it will return the system message. If neither are provided, it will return null.

[JsonPropertyName("system")]
public List<TextContent>? SystemPrompt { get; }

Property Value

List<TextContent>

Temperature

Gets the temperature to use for the request.

public decimal Temperature { get; init; }

Property Value

decimal

ToolChoice

Gets the tool choice mode to use for the request.

[JsonPropertyName("tool_choice")]
public ToolChoice? ToolChoice { get; init; }

Property Value

ToolChoice

Tools

Gets the tools to use for the request.

public List<Tool>? Tools { get; init; }

Property Value

List<Tool>

TopK

Gets the top-K value to use for the request.

public int? TopK { get; init; }

Property Value

int?

TopP

Gets the top-P value to use for the request.

public decimal? TopP { get; init; }

Property Value

decimal?