# Class CountMessageTokensRequest | AnthropicClient
Represents a request to count the number of tokens in a message.

# Class CountMessageTokensRequest

Namespace
  AnthropicClient.Models

Assembly
  AnthropicClient.dll

Represents a request to count the number of tokens in a message.

    public class CountMessageTokensRequest

Inheritance
  object
  CountMessageTokensRequest

Inherited Members
  object.Equals(object)
  object.Equals(object, object)
  object.GetHashCode()
  object.GetType()
  object.MemberwiseClone()
  object.ReferenceEquals(object, object)
  object.ToString()

## Constructors

### CountMessageTokensRequest(string, List<Message>, ToolChoice?, List<Tool>?, List<TextContent>?)

Initializes a new instance of the CountMessageTokensRequest class.

    public CountMessageTokensRequest(string model, List<Message> messages, ToolChoice? toolChoice = null, List<Tool>? tools = null, List<TextContent>? systemPrompt = null)

#### Parameters

`model` string

  The model ID to use for the request.

`messages` List<Message>

  The messages to count the number of tokens in.

`toolChoice` ToolChoice

  The tool choice mode to use for the request.

`tools` List<Tool>

  The tools to use for the request.

`systemPrompt` List<TextContent>

  The system prompt to use for the request.

#### Exceptions

ArgumentNullException

  Thrown when `model` or `messages` is null.

ArgumentException

  Thrown when `messages` is empty.

## Properties

### Messages

Gets the messages to count the number of tokens in.

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

#### Property Value

List<Message>

### Model

Gets the model ID to be used for the request.

    public string Model { get; init; }

#### Property Value

string

### SystemPrompt

Gets the system prompt to use for the request.

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

#### Property Value

List<TextContent>

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