class Anthropic::Resources::Messages
def count_tokens(params)
- See: Anthropic::Models::MessageCountTokensParams -
Returns:
-
(Anthropic::Models::MessageTokensCount)
-
Parameters:
-
request_options
(Anthropic::RequestOptions, Hash{Symbol=>Object}, nil
) -- -
tools
(Array
) -- Definitions of tools that the model may use. -
tool_choice
(Anthropic::Models::ToolChoiceAuto, Anthropic::Models::ToolChoiceAny, Anthropic::Models::ToolChoiceTool, Anthropic::Models::ToolChoiceNone
) -- How the model should use the provided tools. The model can use a specific tool, -
thinking
(Anthropic::Models::ThinkingConfigEnabled, Anthropic::Models::ThinkingConfigDisabled
) -- Configuration for enabling Claude's extended thinking. -
system_
(String, Array
) -- System prompt. -
model
(Symbol, String, Anthropic::Models::Model
) -- The model that will complete your prompt.\n\nSee [models](https://docs.anthropic -
messages
(Array
) -- Input messages.
Overloads:
-
count_tokens(messages:, model:, system_: nil, thinking: nil, tool_choice: nil, tools: nil, request_options: {})
def count_tokens(params) parsed, options = Anthropic::MessageCountTokensParams.dump_request(params) @client.request( method: :post, path: "v1/messages/count_tokens", body: parsed, model: Anthropic::MessageTokensCount, options: options ) end