Returns the token count for a given inference request
Source:R/bedrockruntime_operations.R
bedrockruntime_count_tokens.RdReturns 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.
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_modelorconverserequest:For
invoke_modelrequests, provide the request body in theinvokeModelfieldFor
converserequests, provide the messages and system content in theconversefield
The input format must be compatible with the model specified in the
modelIdparameter.