Reference Messages
messages.countTokens
Counts the input tokens of a request without running the model.
Reference#
countTokens(request, options?)#
def countTokens(request: MessageRequest, options: RequestOptions): F[TokenCount]
def countTokens(request: MessageRequest): F[TokenCount]
Parameters
request: theMessageRequestyou would send.options: optionalRequestOptionsfor this call.
Returns
final case class TokenCount private (inputTokens: Long, extras: JsonObject)
Caveats
- The fields that do not affect the input are left out of the request:
max_tokens, stop sequences, service tier, speed, inference geography, fallbacks and metadata. - In
ScriptedModel, it always returns 0.
Every signature and example on this page is copied, character for character, from the public source of anthropic4s and its Scaladoc. The complete API, every type included, is in the Scaladoc of each module.