bedrockruntime_count_tokens: Returns the token count for a given inference request

View source: R/bedrockruntime_operations.R

bedrockruntime_count_tokensR Documentation

Returns the token count for a given inference request

Description

Returns the token count for a given inference request. This operation helps you estimate token usage before sending requests to foundation models by returning the token count that would be used if the same input were sent to the model in an inference request.

See https://www.paws-r-sdk.com/docs/bedrockruntime_count_tokens/ for full documentation.

Usage

bedrockruntime_count_tokens(modelId, input)

Arguments

modelId

[required] The unique identifier or ARN of the foundation model to use for token counting. Each model processes tokens differently, so the token count is specific to the model you specify.

input

[required] The input for which to count tokens. The structure of this parameter depends on whether you're counting tokens for an invoke_model or converse request:

  • For invoke_model requests, provide the request body in the invokeModel field

  • For converse requests, provide the messages and system content in the converse field

The input format must be compatible with the model specified in the modelId parameter.


paws.machine.learning documentation built on May 31, 2026, 1:07 a.m.